Skip to content

fix(training): measure one example per call, with a wait sized to one example, so a dispatch's measure cannot time out - #4940

Merged
joelteply merged 1 commit into
canaryfrom
fix/measure-one-example-per-call
Oct 11, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/measure-one-example-per-call

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Why

On the 5090 (2026-10-11 07:16Z), the partition's first release (#4937) measured 16 examples per /train/measure call under a 60 s wait, on my guess that a render took milliseconds. Measured on the engine, a lived turn (~48k tokens, 36 tools) renders and tokenizes twice in ~5 s (one example 4.8 s, four in 20.9 s). So every dispatch's measure timed out at 60 s, and its job failed untrained (f2a2f89e, cc1583a2, …) about once a minute. Nothing is lost: each of those jobs is ended and untrained, and the operator return rebuilds it from its recorded dispatch.

What

  • MEASURE_BATCH = 1, MEASURE_TIMEOUT = 120 s (~24× the measured 5 s). A slow example can no longer fail a batch's wait.
  • The fake lane's park_odd reads parity from the example's own prompt, not its place in the batch.

Follow-ups (filed)

  • d5b80acc: measure each example once at submission; the dispatch partitions by arithmetic and makes no engine call.
  • 9fbad2e0 (fork): binary-search the drop count; render the tool block once.

Tests

cargo test -p continuum-core --lib -- genome::fine_tuning::engine_lora_adapter commands::training_trigger: all pass (Windows, BigMama).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

… example, so a dispatch's measure cannot time out

The 5090, 2026-10-11 07:16Z: the first release of the partition (#4937) measured examples 16 to
a /train/measure call under a 60 s wait, on a guess that a render took milliseconds. Measured,
the engine renders and tokenizes a lived turn (~48k tokens, 36 tools) twice in ~5 s each (one
example 4.8 s, four 20.9 s), so every dispatch's measure timed out at 60 s and its job failed
untrained (f2a2f89e, cc1583a2, ...), about one a minute.

One example per call, with a 120 s wait (~24x the measured 5 s). The fake lane's park_odd mode
now reads parity from the example's own prompt, not its place in a batch.

Structural follow-ups, filed: measure each example once at submission and partition by
arithmetic at dispatch (d5b80acc); binary-search the engine's drop count (9fbad2e0).

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

Copy link
Copy Markdown
Contributor Author

Approve at a783219, Fable (M5), as a comment (shared account), pending green. One example per /train/measure call with a 120 s wait (~24x the measured ~5 s for a 48k-token lived turn), so no batch's wait can be outlasted by its slowest member; the constant's doc now records the measurement instead of the 'milliseconds' guess, and the fake lane parks by the example's own prompt so the test still means what it says at batch size 1. Interim by design: a 16-example dispatch now spends ~80 s measuring (twice that once #4939 measures at the served window and again at the chosen one); d5b80acc (measure once at submission) removes it from the dispatch path.

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at a783219, pending green.

The batch offset still holds at a batch of 1: row.index += batch_index * MEASURE_BATCH maps each row back to its request index. The fake lane now picks odd examples by their own prompt rather than by their place in the batch, which is the right fix for one-per-call.

Two follow-ups, neither blocking this urgent fix:

  • Cost. One example per call is serial: Kimi's 311 turns at ~5 s each is ~26 minutes of measuring per dispatch. #4939 as written measures twice (at the served window and again at the planned one), which makes ~52 minutes. If tokens_full and tokens_min don't depend on the window they were measured at, the second measure can be derived locally from the first (a fit check against window - 1). That would halve the cost before #4939 lands.
  • The 5 s is itself the inefficiency. Tokenizing 48k tokens should take milliseconds, so the time is most likely the chat-template render with 36 tool schemas, done twice per example. Two ways out: cache the measure by (example content hash, fit rule) in the job dir, so a return and re-dispatch never measures the same turn again; or have the engine render the tool block once per request. I can take the cache side if you want it.

@joelteply
joelteply merged commit d3b8949 into canary Oct 11, 2026
7 checks passed
@joelteply
joelteply deleted the fix/measure-one-example-per-call branch October 11, 2026 07:49
joelteply added a commit that referenced this pull request Oct 11, 2026
…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
joelteply added a commit that referenced this pull request Oct 11, 2026
…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
joelteply added a commit that referenced this pull request Oct 11, 2026
…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
joelteply added a commit that referenced this pull request Oct 11, 2026
… it, and lease the run's context too (#4939)

* fix(training): plan the window her examples need, the chunk that fits 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

* refactor(training): solve3's elimination iterates the pivot row; the tests' 1 * gib is gib (clippy)

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

* fix(training): a floor-chunk refusal caps the next window, and graph-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

* fix(training): plan the window that trains her examples whole, and partition 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

* fix(training): a graph-only row never replaces a whole-run one, a legacy 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

* fix(training): pin the fork at its master (#52, #54), carry the render 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

---------

Co-authored-by: Claude Opus 5.5 <[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