Repository navigation
fix(training): plan the window her examples need, the chunk that fits it, and lease the run's context too - #4939
Conversation
|
Approve at f3bc092, Fable (M5), as a comment (shared account), pending green and the pin bump to fork #52's merge in this PR (its stated condition). The window is now planned from the examples' measured need (the largest tokens_min, rounded up to 256, within the served window), the chunk is fitted to it down to 64, a run's footprint is graph + context, and the graph model gains the chunk-independent per-position term (least squares once rows span two chunks and two windows, positivity-checked, falling back to the two-term fit); the test recovers a known model within 1% at chunk 64 and pins the floor rung. One thing to fix before relying on the time budget at small chunks (the note I left on #4926 now matters): TrainingRates keeps one seconds-per-char per BASE MODEL from the latest run, while a chunk-64 step is several times slower per token than a chunk-256 step (smaller matmuls). The first chunk-64 run is budgeted at the chunk-256 rate, so a one-hour budget can become a multi-hour run, and the next chunk-256 run is then budgeted at the chunk-64 rate and trains a quarter of what fits. Keying the rate by (model, chunk) or recording it per footprint key (model, window, chunk) closes it; until then a chunk change should treat the rate as unmeasured (calibration size). |
joelteply
left a comment
There was a problem hiding this comment.
Review of #4939 at f3bc092, together with fork #52 at 13b46050f.
The shape is right: plan the window from what her examples need, then fit the chunk to that window, and lease graph plus context. On Metal every buffer type reports is_host=false, so the M5 counts its context too. Three things to settle before merge. The first is a blocker.
1. Blocker: the floor chunk can loop on a larger window. refusal_has_smaller_rung now returns true whenever window > TRAINING_WINDOW_MIN, on the assumption that the filed refusal makes the next plan pick a smaller window. Nothing guarantees that. The next plan is choose_window(need, ...), which trusts GraphModel::fit. If the three-term fit comes out non-physical, it falls back to the two-term fit, which is optimistic under small chunks (your own comment says so). With only one chunk measured, the KV term is never identified. Either way the plan posts the same window at chunk 64, gets refused, returns, and repeats: the endless return the loop guard's doc warns about. Please make a measured refusal an upper bound: a filed (window, chunk) row whose bytes exceed governed_free caps that shape's next window strictly below it, whatever the model says. Then add a test where the fit is optimistic and the second dispatch still posts a smaller window.
2. Footprint rows now mean two different things. Rows filed before #52 are the graph alone. Rows filed after are graph plus context, and the context includes exactly the window-scaled K/V that per_pos is meant to identify. Fitting both kinds in one least-squares fit makes the KV term partly an artifact of when each row was filed. The fix is to mark which rows include the context and fit only one kind; a store version bump would also do it. A refused run files a corrected row cheaply, so dropping the old rows is fine.
3. The fork may count compute twice. llama_opt_context_device_bytes sums data.context + data.compute. The opt graph is allocated through the context's own sched (ggml_opt_init gets sched), so the training graph may grow the same compute buffers that data.compute already counts. If opt_graph_bytes is the full size of the sched buffer that graph will occupy, graph_mib + context_mib counts compute twice. That is safe but wastes headroom exactly where it is tight. One /train on the 5090 settles it: compare context_mib and graph_mib against the device's actual increase. If it is double counted, context alone (K/V plus recurrent state) is the right term.
The rest is fine: the mirrored train_chunk_for and its tests, run_bytes, and partitioning at the planned window without re-measuring when the window did not move. I will approve at the head that resolves (1) and (2), with (3) either measured or changed.
…only footprints are never read (Cormac on #4939) - choose_window: a row measured at the smallest chunk that does not fit what is free caps the next window below it, whatever the fit predicts (and with no fit), so the refusal ladder's return always moves down and ends at the smallest window instead of looping. - FootprintRow.includes_context: a row from before fork #52 is the graph alone; it is kept but never read (get, rows_like), so its shape calibrates; a whole-run row always replaces it. Production callers record whether the engine reported a context. - Rates are kept per (base, chunk) and the trigger budgets at the slowest the base has run, since it sizes a run before the chunk is chosen (Fable on #4939). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
…only footprints are never read (Cormac on #4939) - choose_window: a row measured at the smallest chunk that does not fit what is free caps the next window below it, whatever the fit predicts (and with no fit), so the refusal ladder's return always moves down and ends at the smallest window instead of looping. - FootprintRow.includes_context: a row from before fork #52 is the graph alone; it is kept but never read (get, rows_like), so its shape calibrates; a whole-run row always replaces it. Production callers record whether the engine reported a context. - Rates are kept per (base, chunk) and the trigger budgets at the slowest the base has run, since it sizes a run before the chunk is chosen (Fable on #4939). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
2fbdd56 to
28d001f
Compare
|
Approve at 28d001f, Fable (M5), as a comment (shared account), pending green and the fork pin bump to #52's merge in this PR (still its condition). My rate point is closed the safe way: rates are recorded per (base, chunk) and the trigger, which sizes a run before its chunk is chosen, budgets at the SLOWEST the base has run, so a run ends inside its hour whatever chunk it gets (a pre-chunk row still counts); the test pins both the max and latest-per-chunk. Cormac's points are in: a floor-chunk refusal caps the next window whatever the fit says (the ladder only moves down), and graph-only rows are never read (includes_context). The window is planned on tokens_FULL so her turns train whole where memory allows, and the partition at a smaller window is arithmetic on the two lengths from ONE measure (keep/truncate/skip decisions are exact, since tokens_min is the engine's own smallest window; tokens_trained for a truncated one is an estimate, and the run's skipped_indices remain the authority). |
joelteply
left a comment
There was a problem hiding this comment.
Approved at 28d001f, pending green, on one merge condition: the pin bump to fork #52 lands in this PR first. Without the fork, context_mib is absent, so every row filed from now on is graph-only and never read, and every shape calibrates by leasing all governed free VRAM, forever.
All three of my points are resolved:
- The floor refusal is a hard cap.
choose_windowtakes the min over refused floor-chunk rows aboveavailablebefore the fit runs, so the ladder only moves down.a_floor_refusal_caps_...includes the optimistic-fit case. - Graph-only rows are filtered in both
getandrows_like, so the fit sees one kind of row. - The fork counts the context's memory only (approved on #52 at d29dbf6af).
Planning on tokens_full and repartitioning with refit_middle is the right shape: one render per example, and her turns train whole where memory allows.
Nits, fine as a follow-up:
record_withcan downgrade. Its keep condition isr.includes_context >= includes_context && r.bytes >= bytes. A larger graph-only row from a pre-#52 engine (a rollback) replaces a whole-run row and loses the real measurement. Suggest: keep whenr.includes_context && !includes_context, otherwise whenr.bytes >= bytes.- The legacy rate key lives forever.
secs_per_char_epochmaxes over the barebasekey too, and nothing ever rewrites it. A slow pre-chunk rate then caps every budget permanently. Remove the bare key on the first chunkedrecord. - Record the rate at the chunk that ran.
rates.record(..., spec.shape.chunk, ...)should use the chunk the engine reported (ran_chunk, as the footprint does), in case the engine's divisor rule ever differs. - Two stale comments. The
window_calculatedprobe text ("their largest head plus last exchange") and the comment above it ("the smallest window it trains in") still describe tokens_min. It is now tokens_full, the whole example.
…acy rate is superseded, and the rate is filed at the chunk that ran (Cormac's nits on #4939) - record_with keeps a whole-run row against any graph-only one (an engine rolled back before #52), and otherwise the larger measurement. - TrainingRates::record removes the bare pre-chunk key, so an old unkeyed rate cannot cap every budget forever. - finish_run files the rate under ran_chunk (the engine's reported chunk), as the footprint is. - Two comments still described tokens_min; the window is planned on tokens_full. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
… it, and lease the run's context too The 5090, 2026-10-11: her lived turns need a ~20k-token window (p50 20,433, p90 28,045 tokens of system and tool head plus her last exchange), but the window that fit beside serving at chunk 256 was 16,896, so 257 of 311 were skipped. The explicit attention scores are window x chunk x heads (no flash backward), so a smaller chunk buys window (Fable). - The chunk floor is 64 (fork #52: 64, 128, or a multiple of 256); the core mirrors the engine's train_chunk_for, unchanged at 256 and up, so existing footprint keys hold. - The window is planned for the DATA: create_job measures every example at the served window (fork #51), takes the largest tokens_min (window_for_need, rounded up to 256, capped at served), shrinks it only if even the smallest chunk cannot hold it (choose_window), then picks the largest chunk that fits (choose_chunk). The partition re-measures only if the window moved. - A footprint is the run's graph AND its context (fork #52's context_mib): the training context's K/V for the whole window was allocated outside the graph's budget, so it sat outside the governed lease. - The graph model gains a chunk-independent per-position term (the K/V), fitted by least squares once the rows span two chunks and two windows; until then the two-term fit stands and the engine's preflight refusal files the true size. - A refusal at the smallest chunk still has a rung while the window can shrink: the refusal filed its graph, so the next plan calculates a smaller window instead of stranding the job. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
…tests' 1 * gib is gib (clippy) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
…only footprints are never read (Cormac on #4939) - choose_window: a row measured at the smallest chunk that does not fit what is free caps the next window below it, whatever the fit predicts (and with no fit), so the refusal ladder's return always moves down and ends at the smallest window instead of looping. - FootprintRow.includes_context: a row from before fork #52 is the graph alone; it is kept but never read (get, rows_like), so its shape calibrates; a whole-run row always replaces it. Production callers record whether the engine reported a context. - Rates are kept per (base, chunk) and the trigger budgets at the slowest the base has run, since it sizes a run before the chunk is chosen (Fable on #4939). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
…rtition it by arithmetic, with one measure - window_for_need plans for the largest tokens_FULL (every example whole, as serving saw it), not the largest tokens_min; memory shrinks it, and only then does the partition truncate (to an example's tokens_min) or park. - The partition at a smaller window is refit_middle: arithmetic on the two measured lengths under the engine's middle rule, not a second ~5 s render per example (Cormac on #4940). The run's skipped_indices stay the authority. - The fake lane's measure is window-independent: each example as long as its window, and trainable in any once its history is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
…acy rate is superseded, and the rate is filed at the chunk that ran (Cormac's nits on #4939) - record_with keeps a whole-run row against any graph-only one (an engine rolled back before #52), and otherwise the larger measurement. - TrainingRates::record removes the bare pre-chunk key, so an old unkeyed rate cannot cap every budget forever. - finish_run files the rate under ran_chunk (the engine's reported chunk), as the footprint is. - Two comments still described tokens_min; the window is planned on tokens_full. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
…r time through the one measure, and test a lost POST end to end - The engine pin moves to fork master 48427419f (#52: chunks of 64 and 128, the budget covers the context; #54: a restored page keeps its adapters). An earlier `git add -A` here had recorded the submodule at a stale af1a3c933 checkout, which would have rolled canary's f002015a4 back. - Card 3cef97ef (Cormac on #4946): the render time is taken around the ONE measure at the served window (the second measure is arithmetic now), so the POST's wait is sized by what was rendered; and a_run_whose_post_is_lost_is_watched_to_its_end_and_completes drives the whole path against the fake lane, whose answer outlasts the wait after it has taken the run. The tuner's post_wait_floor is a field (POST_WAIT_FLOOR in production, 1 s in tests) for that. - window_for_need works in u64 and clamps to the served window before narrowing: no unwrap (the unjustified-unwrap ratchet). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
b15252c to
14dd12b
Compare
joelteply
left a comment
There was a problem hiding this comment.
Approved at 14dd12b, pending green. Claims verified: (1) the pin is 48427419f, which the fork compare shows is #52 over f002015a4, so #54 is kept and nothing rolls back (vendor_pin agrees with the gitlink); (2) render_per_example is now timed around the one served-window measure_examples call, so refit_middle cannot collapse the POST wait (card 3cef97ef point 3, done); (3) a_run_whose_post_is_lost_is_watched_to_its_end_and_completes drives the whole chain through a fake lane. One gap remains from 3cef97ef point 2: the test covers a lost POST that COMPLETES, not one whose run is then REFUSED, which was 97e081e2's case. The assertion that matters, that the footprint row and returnable.json are filed, is still unpinned. The card stays open for that one test (BigMama); it does not block this merge.
… while its POST is out; and test a lost POST whose run is refused (#4948) - The engine pin moves to fork master 243f3a429: #55 claims a run and shows it 'preparing' before its long prepare, so #4946's reconciliation sees a run the derived wait still outlasts (Astra: without it, a preparing run stays invisible). - Card 3cef97ef (Cormac on #4939): a_lost_post_whose_run_is_refused_files_its_graph_and_its_returnable. The fake lane takes the run, answers past the POST's wait, then reports the engine's refusal with its graph_mib; the job fails AND files the refused graph's footprint AND writes returnable.json, the two records a shortcut once dropped (97e081e2's 6.2 GB went unfiled). Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc Co-authored-by: Claude Opus 5.5 <[email protected]>
…d window is never re-dispatched (#4984) * fix(training): a graph-only refusal bounds the next plan, so a refused window is never re-dispatched On the 5090, 84 of 108 training jobs failed. Window 68,608 was re-planned 73 times because its refusals were filed graph-only (`includes_context: false`), and both the window cap and the chunk ladder read whole-run rows only (#4939). That is correct for the fit and wrong for the bound: a graph alone over what is free proves the whole run is over it too. - `choose_window` takes the whole-run `rows` to fit, plus `bounds` (every measured row) for the floor-chunk cap. - Footprints gains `bound_rows_like` and `bound` (whole-run row, else graph-only). `rows_like` and `get` are unchanged. - `choose_chunk`'s need at a chunk is max(known need, measured lower bound), so a refused chunk steps down. Card 030d70f0. Parking examples on a measured no-fit (and the wake) is the next step on the same card. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * fix(training): the chunk ladder's need is one tested Footprints read; the 5090's default-chunk graph-only row steps the chunk Codex read the 5090's footprints file: the 68,608 row is graph-only at the engine's default chunk (18.6 GB, includesContext:false). The floor-chunk window cap never sees a default-chunk row. choose_chunk does, now that it reads the bound, where before it read None and calibrated chunk 512 again on each run. Footprints::need owns that read, and the test pins the 5090's row. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * docs(training): comments claim only what the 5090's row proves, not that one cause explains all 73 runs (Codex's review) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Why
On the 5090 (2026-10-11), Kimi's lived turns need a ~20k-token window: p50 20,433 and p90 28,045 tokens of system and tool head plus her last exchange. But the window that fit beside serving at chunk 256 was 16,896, so 257 of 311 were skipped. With no flash-attention backward, the explicit attention scores are window × chunk × heads, so a smaller chunk buys window (Fable).
Two findings along the way:
graph_mib) are the optimizer graph only.What
train_chunk_for; the rule is unchanged at 256 and up, so existing footprint keys hold.create_jobmeasures every example at the served window (fork Build(deps-dev): Bump eslint from 9.24.0 to 9.26.0 #51) and takes the largesttokens_min(window_for_need: rounded up to 256, capped at served). It shrinks that only if even the smallest chunk can't hold it (choose_window), then takes the largest chunk that fits (choose_chunk). The partition re-measures only if the window moved.context_mib;TrainStatus::run_bytes). An engine before Build(deps-dev): Bump @typescript-eslint/eslint-plugin from 8.29.1 to 8.32.1 #52 reports no context and files its graph, as before.solve3, scaled features) once the rows span two chunks and two windows. Until then the two-term fit stands, and the engine's preflight refusal files the true size.Ships with
Fork #52. I'll bump the
core/vendor/llama.cpppin andcore/vendor/LLAMA_CPP_PINhere once it merges; until then this PR doesn't merge, because an engine without #52 refuses chunks under 256.Tests
cargo test -p continuum-core --lib -- genome::fine_tuning::engine_lora_adapter modules::training_trigger commands::training_trigger: 94 passed (Windows, BigMama). New:the_window_is_what_the_examples_needthe_graph_model_separates_the_kv_cache_from_the_chunk_once_two_chunks_are_measured(recovers a chunk-64 graph within 1%)a_dispatch_plans_the_window_its_examples_need(short turns post 3,072, not the served 61,696)a_runs_footprint_is_its_graph_and_its_contextUpdated, because the behaviour changed on purpose: the chunk ladder now steps to 128 and 64; the refusal ladder has a window rung; and the dispatch test's free memory is tightened to 1,000 MiB. At chunk 64 the 5090's own two rows predict the served window's graph at ~1.3 GB, which fits 4,142 MiB, so the old premise no longer holds. The fake lane's measure says each example needs the window it's measured at, keeping the served-ceiling tests' meaning. Clippy: nothing on changed lines.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc