Skip to content

A shutdown save never checkpoints a bucket an operation still holds: no lost retire or candidate - #6223

Merged
joelteply merged 1 commit into
canaryfrom
3326eb71/trainer-shutdown-save-state-s-quiesce-ra
Nov 22, 2026
Merged

joelteply merged 1 commit into
canaryfrom
3326eb71/trainer-shutdown-save-state-s-quiesce-ra

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Card 3326eb71 (Cormac's audit, 2026-11-22; introduced in #5928): the runtime runs drain() ->
save_state() -> shutdown(), and the trigger's drain only stop_admitting()s, counting in-flight
operations without waiting. save_state's quiesce then checkpointed each seated learner holding only
the engine lock, so its commit_checkpoint -> project -> record_learned read-modify-write of whole
submission rows could race a gated operation still running on that bucket and lose a retire's
is_pending=false, or undo a record_candidate. Waiting for those operations is not an option: each
shutdown phase is under a timeout, and a cancelled quiesce is worse than the race.

Quiesce now takes each learner's bucket gate with try_acquire (never waits: it holds the engine lock,
and every pass takes a bucket gate before an engine lock). Held by an operation in flight, her
checkpoint is skipped and counted unpublished (training.in_place.shutdown_gate_held; the journal
keeps her progress), and her learner still pages out (no pass can use her under the engine lock).

Test (live_engine): a learner seated on a real engine, her bucket gate held as an operation in
flight, the save's quiesce leaves her checkpoint unpublished and still stops her. Run against
llama-server built at canary's pin 126b9c1c (CPU): live_engine 4/4. With the gate check removed,
that test fails and the other three pass. Full dreaming lib 113/113; ratchets pass.

Co-Authored-By: Claude Opus 5.5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…no lost retire or candidate

Card 3326eb71 (Cormac's audit, 2026-11-22; introduced in #5928): the runtime runs drain() ->
save_state() -> shutdown(), and the trigger's drain only stop_admitting()s, counting in-flight
operations without waiting. save_state's quiesce then checkpointed each seated learner holding only
the engine lock, so its commit_checkpoint -> project -> record_learned read-modify-write of whole
submission rows could race a gated operation still running on that bucket and lose a retire's
is_pending=false, or undo a record_candidate. Waiting for those operations is not an option: each
shutdown phase is under a timeout, and a cancelled quiesce is worse than the race.

Quiesce now takes each learner's bucket gate with try_acquire (never waits: it holds the engine lock,
and every pass takes a bucket gate before an engine lock). Held by an operation in flight, her
checkpoint is skipped and counted unpublished (training.in_place.shutdown_gate_held; the journal
keeps her progress), and her learner still pages out (no pass can use her under the engine lock).

Test (live_engine): a learner seated on a real engine, her bucket gate held as an operation in
flight, the save's quiesce leaves her checkpoint unpublished and still stops her. Run against
llama-server built at canary's pin 126b9c1c (CPU): live_engine 4/4. With the gate check removed,
that test fails and the other three pass. Full dreaming lib 113/113; ratchets pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply merged commit 81869c9 into canary Nov 22, 2026
13 checks passed
@joelteply
joelteply deleted the 3326eb71/trainer-shutdown-save-state-s-quiesce-ra branch November 22, 2026 14:50
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