Skip to content

feat(genome): a training job asks the engine for the exact walk, with half the free host memory to keep - #4841

Merged
joelteply merged 2 commits into
canaryfrom
feat/train-exact-walk
Oct 7, 2026
Merged

joelteply merged 2 commits into
canaryfrom
feat/train-exact-walk

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What: a training job now asks the engine for the exact walk (fork CambrianTech/llama.cpp #47): one optimizer step per window, on the gradient of the window's whole loss.

Why: the plain walk steps per chunk and stops the gradient at every chunk boundary. Measured with #47's test-walk-exact (the SGD step read off the adapter, so step = −lr·g, compared against one graph over the whole window):

1.5B (attention) 0.8B (hybrid, Kimi's architecture)
plain walk cosine 0.81, norm 2.1 cosine 0.83, norm 2.1
exact walk cosine 0.998, norm 0.995 cosine 0.998, norm 1.000

What's sent:

  • exact: true
  • walk_host_budget_mib: TRAINING_HOST_SHARE (one half) of the host memory memory_pressure::current_available_bytes() reads free. The other half stays for the serving engine's file cache (BigMama's page-fault loop, 2026-10-06). When the monitor hasn't read the host yet, no budget is sent rather than an invented one (test).

The engine checkpoints a hybrid's state more sparsely to fit the budget, shrinks its gradient horizon to fit the device and reports it (walk_horizon in its status), and refuses by name when the K/V gradient alone doesn't fit. An engine before #47 ignores both keys and trains the plain walk, so this is safe to land before the engine deploys.

Tests: the_exact_walk_keeps_half_the_free_host_memory, plus the end-to-end dispatch test asserting exact: true on the posted body. engine_lora_adapter 18/18.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

… half the free host memory to keep

The plain walk steps per chunk and stops the gradient at every chunk boundary: on the 1.5B its
step agreed with the true full-window gradient at cosine 0.81 (fork #47's test-walk-exact). The
exact walk takes ONE step per window on the window's whole gradient, carried back through every
chunk's cached K/V and a hybrid's recurrent state (cosine 0.998 on the 1.5B and on the hybrid
0.8B). The job now sends exact: true, and walk_host_budget_mib: TRAINING_HOST_SHARE (one half)
of the host memory the pressure monitor reads free, so the serving engine's file cache keeps
the rest (BigMama's page-fault loop, 2026-10-06). The engine checkpoints a hybrid's state more
sparsely to fit, shrinks its gradient horizon to fit the device and reports it, and refuses by
name when the K/V gradient alone does not fit. An engine before #47 ignores both keys and trains
the plain walk, as this core asked before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply

Copy link
Copy Markdown
Contributor Author

Review at c64253d (Fable). The shape is right: one named share, sent explicitly and not an env var, with a test that pins it. One blocking issue:

Low free memory gives an unbounded walk. exact_walk_host_budget_mib maps both 'monitor unread' and 'under 1 MiB free' to None, and None means the engine keeps whatever the window needs (8.3 GB at 63k on the 27B). So the worse the memory pressure, the less the walk is bounded, and that is the page-cache eviction that put BigMama's engine in a fault loop for an hour. The test even pins it (Some(1 << 20) → None, 'never a zero cap'). Under pressure the answer should be a refusal by name, not no limit:

  • available known but under a MiB: send the floor (walk_host_budget_mib: 1). The engine then refuses the window by name ('needs X MiB, over its budget of 1'), the job fails with a reason, and nothing gets thrashed.
  • monitor unread: don't ask for the exact walk at all (exact: false, the plain walk, whose memory is chunk-bounded), or wait for the first reading. Either is better than unbounded.
    Then make the test say that: a tiny free figure gives a budget the engine refuses, and an unread monitor never gives an unbounded exact walk.

Non-blocking: exact: true with an engine before #47 is a no-op, as the doc says, so this can merge before the pin bump. Its effect starts at the bump; worth one line in the PR so nobody reads training numbers from the window between the two as exact-walk numbers.

…ry sends the floor (Fable on #4841)

An unread monitor and 'under a MiB free' both mapped to no budget, which is unbounded: the
tighter memory was, the less the walk was bounded. Now under pressure the job sends the 1 MiB
floor, which the engine refuses by name, and an unread monitor trains the plain (chunk-bounded)
walk (exact: false). walk_request(reading) is the one decision, tested for both arms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply

Copy link
Copy Markdown
Contributor Author

Fixed: under pressure the job sends the 1 MiB floor (the engine refuses by name), and an unread monitor sends exact: false (the plain, chunk-bounded walk). walk_request(reading) is the single decision, tested for both arms; the end-to-end test asserts the unread arm it actually runs in. engine_lora_adapter 18/18.

@github-actions github-actions Bot added size: M and removed size: S labels Oct 7, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Approve at 7b35fc3 (Fable). The blocker is resolved exactly as it should be. A read host never gets an unbounded walk (.max(1): the floor, which the engine refuses by name, so tighter memory bounds it more). An unread host trains the plain, chunk-bounded walk and says so with a named probe (training.job.exact_walk_skipped). walk_request makes the two arms one decision, and the tests pin 0 bytes, 1 MiB, 36 GiB and unread. Merge on green; it takes effect when the engine pin carries #47.

joelteply added a commit that referenced this pull request Oct 7, 2026
…, and the walk itself (fork #40, #43, #45, #46, #47)

2d4d63bbb -> 5e3961b10 on feat/props-weight-residency:
- #40 the walk: decode context into the cache, train each reply chunk against the cached prefix
  (memory chunk x window, so a 63k window trains on one GPU beside serving)
- #45 per-step graphs start each optimizer period from zero gradients (the accumulators were never
  zeroed: every step applied the sum of every gradient since the run began)
- #46 CONCAT backward slices a contiguous gradient (V's gradient through the training
  attention's transpose was read from the wrong elements)
- #47 the exact walk: one optimizer step per window on the gradient of the window's whole loss,
  through every chunk's cached K/V and a hybrid's recurrent state; host budget, state
  checkpointing, adaptive horizon (cosine 0.998 vs one graph, 1.5B and hybrid 0.8B, at f32, f16
  and q8_0 caches; end to end through /train: eval 0.283 -> 0.215 on the 1.5B, 0.284 -> 0.245 on
  the hybrid)
- #43 Metal: OUT_PROD multiplies in float staging

Requested by core #4841 (exact: true with a host budget).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply
joelteply merged commit 905f948 into canary Oct 7, 2026
7 checks passed
@joelteply
joelteply deleted the feat/train-exact-walk branch October 7, 2026 02:12
joelteply added a commit that referenced this pull request Oct 7, 2026
…, and the walk itself (fork #40, #43, #45, #46, #47) (#4845)

2d4d63bbb -> 5e3961b10 on feat/props-weight-residency:
- #40 the walk: decode context into the cache, train each reply chunk against the cached prefix
  (memory chunk x window, so a 63k window trains on one GPU beside serving)
- #45 per-step graphs start each optimizer period from zero gradients (the accumulators were never
  zeroed: every step applied the sum of every gradient since the run began)
- #46 CONCAT backward slices a contiguous gradient (V's gradient through the training
  attention's transpose was read from the wrong elements)
- #47 the exact walk: one optimizer step per window on the gradient of the window's whole loss,
  through every chunk's cached K/V and a hybrid's recurrent state; host budget, state
  checkpointing, adaptive horizon (cosine 0.998 vs one graph, 1.5B and hybrid 0.8B, at f32, f16
  and q8_0 caches; end to end through /train: eval 0.283 -> 0.215 on the 1.5B, 0.284 -> 0.245 on
  the hybrid)
- #43 Metal: OUT_PROD multiplies in float staging

Requested by core #4841 (exact: true with a host budget).


Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

Co-authored-by: Claude Opus 5.5 <[email protected]>
joelteply added a commit that referenced this pull request Oct 10, 2026
…sends a chunk whose measured footprint fits the governed VRAM (card d6dae498, Kimi's 04:34Z refusal) (#4894)

* fix(genome): the exact walk is its own footprint shape, and the core sends the engine a chunk whose measured footprint fits the governed VRAM (card d6dae498)

Kimi's first exact-walk job on the 5090 (fe334d8f, 2026-10-10 04:34Z) refused in 8 s:
"the graph needs 9236.1 MiB more on CUDA0, over the 3418.0 MiB it may add". The 3418
MiB was the core's own lease: the footprint registry's Shape is keyed by (model, window,
rank, targets, depth), so a plain-walk measurement from before #4841 turned the exact
walk on was leased for an exact run whose chunk graph (GRAD leaves for the cached K/V
over the horizon) is several times larger. And the core sent no chunk, so the engine took
512 for every job (server-train.cpp: "INTERIM: a caller that sends no chunk gets 512
until the core passes the lease's S (Fable)"); fork #49's horizon retry cannot shrink a
graph the chunk's own activations dominate.

Shape gains `exact` and `chunk`. The key keeps every older row readable for what it was
(the plain walk at the engine's own chunk for that window; the suffix appears only for a
shrunken chunk or the exact walk), so an exact run never leases a plain-walk number and
calibrates instead. The core mirrors the engine's chunk rule (train_chunk_for), chooses
the largest chunk whose measured footprint fits the governed VRAM now (choose_chunk: a
measured-too-large chunk halves and asks that shape; an unmeasured one calibrates; the
smallest stands and the governor waits), sends it as "chunk", and files the run's graph
under the chunk the engine reports it ran (state["chunk"], else the mirrored rule). The
planned probe names exact and chunk.

Tests: the mirrored chunk rule; the key's compatibility and separation; choose_chunk on
the 5090's numbers (12.6 GB at 512 against 6.2 GB free -> 256); a run filed under the
window AND the chunk that ran (a 61,696 ceiling is 241 blocks, prime: chunk 256).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(genome): a refused run files the graph the engine's preflight measured, under the chunk it ran, so the next dispatch steps the chunk down (BigMama on #4894)

Footprints were filed by a finished run only (finish_run needs a finite loss), so a
refused calibration filed nothing and every later dispatch calibrated at the same chunk
and was refused the same way. The refusal IS the measurement: the engine's preflight
sizes the graph before refusing it and reports graph_mib on an error too. The in-place
run now carries its shape and the footprints path, and on TrainState::Error files the
reported graph under the window and chunk the engine reports it ran (probe
training.job.footprint_from_refusal). choose_chunk then steps down on the next dispatch.

The ungoverned (test) admission carries the free VRAM a chunk is fitted against, and the
fake engine gains a "refused" mode reporting the 5090's shape. Test: refused at 512 files
12,654 MiB under the shape; the next dispatch of the same request posts chunk 256
against 6 GiB free.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(genome): for_test keeps its cfg(test) gate (the inserted sibling had taken the attribute; the lib build broke)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant