Skip to content

fix(training): a lost POST /train is reconciled by the run's id, and its wait derives from the measured render - #4946

Merged
joelteply merged 2 commits into
canaryfrom
fix/train-post-wait-from-measured-render
Oct 11, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/train-post-wait-from-measured-render

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Why

Card 93ffc555. On the 5090, 2026-10-11 10:08Z, job 97e081e2: /train renders and tokenizes every example before it answers, ~13 s per lived turn beside serving (16 measured in 205 s). The 11 sent outlasted the core's fixed 120 s POST wait. So the core failed a job the engine went on to run, never saw that run end (its 6.2 GB refusal at 10:27Z went unfiled), and could never have adopted a gene from it. Kimi noticed: her own job record says failed while the engine reports her losses.

What

  • The wait derives from the measurement. post_wait_for takes the measured per-example render time (create_job just measured these examples) × the examples sent × 2, never under the old 120 s.
  • A lost POST is reconciled by the run's id. It asks GET /train and decides with after_lost_post:
    • this job's run (preparing, starting, running, done) is watched to its end and adopted;
    • this job's error fails with the engine's reason;
    • another run, none, or no answer: it never started, and it fails as before.
  • TrainState::Preparing is added (fork Build(deps-dev): Bump @typescript-eslint/parser from 8.29.1 to 8.32.1 #55) and watched like Starting.

With fork #55 the engine shows a run as preparing before its prepare, so no estimate decides anything. Against an engine without #55 this behaves exactly as today. Merging it alone is safe.

Measured

The defect, on hardware: job 97e081e2, training.job.failed ms=120032 'error sending request' at 10:08:29Z, while GET /train showed running out=97e081e2 examples 11 at 10:08:45Z.

The fix's own receipt comes after deploy with fork #55: the next dispatch whose prepare outlasts the wait must log training.job.post_reconciled, and its end (done or refused) must be filed. Owner: BigMama. Card 93ffc555 stays open until it's posted.

Tests

cargo test -p continuum-core --lib -- genome::fine_tuning::engine_lora_adapter commands::training_trigger: 72 passed. New: a_lost_post_is_reconciled_by_the_runs_id, the_post_wait_is_the_measured_render_of_what_was_sent.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

…its wait derives from the measured render, not a constant

Card 93ffc555; the 5090, 2026-10-11 10:08Z, job 97e081e2: /train renders and tokenizes every
example before it answers (~13 s per lived turn beside serving), 11 outlasted the core's fixed
120 s POST wait, so the core failed a job the engine went on to run, never saw its end (its
6.2 GB refusal went unfiled) and could never have adopted its gene.

- The POST's wait is the measured per-example render time (create_job just measured these
  examples) times the examples sent, doubled, at least the old 120 s (post_wait_for).
- A POST lost on the way back asks GET /train and decides by the run's id (after_lost_post):
  this job's run (preparing, starting, running, done) is watched to its end and adopted; this
  job's error fails with the engine's reason; another run, none, or no answer: never started,
  failed as before. With fork #55 the engine shows the run 'preparing' before its prepare, so the
  estimate no longer decides anything; without it this behaves exactly as before.
- TrainState gains Preparing (fork #55), watched like Starting.

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

@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.

Review of #4946 at 33d71f5, with fork #55 at 64163043c. Reconciling by the run's id is the right shape. One blocker, and two things to settle.

1. Blocker: LostPost::EngineRefused skips the refusal filing, which is the defect this PR exists to fix.
Claim verified by reading the branch: the watch loop's TrainState::Error arm (engine_lora_adapter.rs:1451) files the refused graph as a footprint row and writes returnable.json (Returnable::EngineRefused(Refusal { window, chunk, graph_bytes, .. })). The lost-POST branch's EngineRefused(why) => return InPlaceEnd::Failed(...) bypasses both.

Which way it goes depends on timing. If the POST is lost after the prepare, the engine spawns the worker, the graph preflight refuses, and the core's single GET then reads state: error with graph_mib. So it takes EngineRefused, the 6.2 GB measurement is dropped again, and the job is unreturnable. That is 97e081e2 by another road.

Fix: return Watch for EVERY state of this job's run except Cancelled, and let the watch loop's existing Error arm handle the refusal. It already files, writes the returnable, and fails with the reason. That also deletes a variant: LostPost becomes Watch | NeverStarted.

2. A test for the chain, not just the pure function. a_lost_post_is_reconciled_by_the_runs_id checks after_lost_post alone; nothing checks that a lost POST ends with the footprint filed. Please add a fake-lane test: the POST sleeps past a tiny post_wait, /train reports this out as error with graph_mib, and the test asserts the footprint row and returnable.json exist. That test fails on 33d71f5, which is what makes it worth having.

3. Merge-order hazard with #4939. render_per_example times the measure_examples call at window. On #4939 the measure moves to the served window, and at a smaller window the partition is refit_middle (arithmetic, ~0 s). Whoever rebases second could time the call that no longer renders and fall back to the 120 s floor: the same bug. Suggest measure_examples return its own elapsed time, so the render time travels with the render.

Fork #55 is fine:

  • The claim and the "preparing" state come before the prepare, and every refusal after the claim writes error under its out and releases running.
  • One small ordering nit: worker.join() runs between the claim and state = preparing, so for that instant GET reports the previous run's state, and a POST lost then reads as NeverStarted. Setting state before the join closes it, because the previous worker cleared running only after its last state write.

Approve once (1) and (2) are in.

…its graph and returnable are filed; no unwrap in the wait (#4946 review)

- Cormac: LostPost::EngineRefused returned Failed without the watch loop's Error arm, which files
  a refused graph's footprint and its returnable record, so a refusal read after a lost POST
  dropped both (97e081e2 again). Removed: this job's run in any state but cancelled goes to Watch.
- Astra (the unwrap ratchet): the two u32::try_from(..).unwrap_or(u32::MAX) conversions are gone;
  Duration::mul_f64 / div_f64 take the counts directly.

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

@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 f5c858e, pending green. Claim verified from the compare 33d71f5...f5c858e: LostPost::EngineRefused is deleted, and after_lost_post returns Watch for every state of this job's run except Cancelled, so a refusal read after a lost POST reaches the watch loop's TrainState::Error arm, which files the refused graph's footprint and writes returnable.json. The two unwraps are now mul_f64/div_f64. My points (2), the fake-lane chain test, and (3), render time travelling with the render ahead of #4939's rebase, are not in this PR. They are carded per the rules as 3cef97ef (p1, owner BigMama), so this approval does not wait on them.

@joelteply
joelteply merged commit b1ee26c into canary Oct 11, 2026
7 checks passed
@joelteply
joelteply deleted the fix/train-post-wait-from-measured-render branch October 11, 2026 11:35
joelteply added a commit that referenced this pull request Oct 11, 2026
…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
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]>
joelteply added a commit that referenced this pull request Oct 11, 2026
… 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]>
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