Repository navigation
fix(rollout): redispatch checkpoint-refused siblings independently - #4710
Closed
macandro96 wants to merge 18 commits into
Closed
macandro96 wants to merge 18 commits into
macandro96 wants to merge 18 commits into
Conversation
Signed-off-by: Anish Mahishi <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
…fast on stranded ones A legacy_agent environment server only relays /run, so its environment participant never holds the episode; the Simple Agent's legacy session does. The commit summary counted only environment exports as owned, so every in-flight Workplace episode looked unexported and the drain waited for replies that cannot arrive while Gym is prepared. Every periodic checkpoint timed out. When no environment participant exported an episode, a legacy agent session (a record with an episode step boundary) now owns it. The adapter reads the agent's committed records through Gym's digest-checked store. A parked agent session that nobody owns fails the checkpoint immediately instead of waiting out the drain deadline. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…oint refusals An attempt was marked DISPATCHED before it waited at the dispatch gate, so a checkpoint could count an attempt that cannot reach Gym until the checkpoint releases the gate; its drain could only time out, fatally at a trainer checkpoint. A /run that reached Gym after prepare closed admission was refused with 409 checkpoint_parked, charged as a data failure, and stayed DISPATCHED while it retried behind the closed gate. The ledger now marks an attempt DISPATCHED inside the gate admission, in the same mutation as the Ray submission. NemoGym takes /run failures as Gym sidecar rows so a checkpoint_parked refusal names its row without ending the stream. The refused attempt returns to RESERVED with its identity and is re-sent once admission reopens, spending no row attempt and no data budget. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
Two-process crash/restore test for a Workplace Assistant turn. Phase one publishes a bootstrap rollout snapshot that holds one turn after its calendar mutation, then is killed; phase two restores it and must dispatch that episode once, as Gym attempt + 1 on its original replica, and train every step exactly once with no invalid or poisoned rows. The turn is captured deterministically: the Gym checkpoint test agent holds the first post-mutation boundary until a real checkpoint parks it, and the rows force a single calendar_create_event whose sentinel the selector requires exactly once in the saved Workplace state. The selector copies the chosen bootstrap snapshot before step 1's trainer checkpoint prunes it, and phase two drops every trainer checkpoint so the restore starts from that anchor. The hook records dispatches once the ledger marks them, plus any checkpoint refusals, and patches run_rollout so RolloutManager's NeMo-Gym type checks still hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…kpoint Abandoning or discarding a group drops its attempts from the recovery ledger, but an episode Gym already admitted keeps running. Gym exports it at the next commit, outside the candidate set, and every checkpoint fails until the episode finishes on its own. The ledger now records each dropped attempt Gym may still hold (dispatched, or reserved with restored Gym state), in memory only. With dispatch closed and before preparing Gym, while Gym is still idle (it refuses a retire once a checkpoint is open), the controller retires them and forgets only what it retired, so a drop recorded meanwhile waits for the next checkpoint. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
Signed-off-by: Ananth Subramaniam <[email protected]>
…ing the run Three ways a Gym checkpoint could take the run down with it: - Control calls had no RL-side timeout. Gym enforces deadline_ts only once it runs a call, so an actor with a stuck event loop, or a call Ray never scheduled, left the coordinator waiting forever with dispatch admission closed. Each call is now bounded by its own deadline plus a short reply grace; an unanswered instance is reported as a TimeoutError and its Ray call is cancelled. Giving up is safe: Gym's lease reopens a parked deployment if the resume is lost too. - The periodic rollout checkpoint treated every Gym failure as a broken invariant and ended training. A checkpoint that could not park, went unanswered, hit a dead actor, or failed in Gym's control plane changed nothing RL holds, so it is now retried under a gym_unavailable reason, still bounded by max_consecutive_failures. Ownership, topology and reply mismatches still abort. Gym's CoordinationError cannot be pickled and reached RL as an untyped UnserializableException, so the adapter raises a picklable GymCheckpointUnavailable in its place for live checkpoint calls. - Rollout deadlines kept ticking while Gym held rollouts parked, so a long checkpoint could time out healthy rollouts as soon as it resumed. The request-deadline registry now tracks named holders (ported from #4266), and a Gym checkpoint holds its own pause from closing admission until Gym resumes, without releasing a colocated engine's pause. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
Parking a turn checkpoint waits for every in-flight agent and environment step to reach a boundary, but the prepare deadline reused token_capture.control_timeout_s, which bounds each control-plane call. The only way to give long steps time to park was to loosen unrelated token-capture RPC deadlines. rollout_recovery.gym_prepare_timeout_s (default 300 s) now sets the prepare deadline alone; renew, commit, retire, restore and resume keep the control timeout. Gym extends its lease from each call's deadline, so a longer prepare cannot let the lease lapse. The value is operational, so it is left out of the bootstrap fingerprint. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
With turn-level recovery, a trainer checkpoint parked Gym and committed its state inside the trainer save. A Gym prepare that missed its deadline, or a transient Gym control error, therefore failed the save and ended the run; the periodic snapshot path already retries those. The trainer checkpoint now saves weights, dataloader, TQ and the recovery ledger without pausing Gym, and marks itself with gym_restart_fallback.json: it holds no Gym state. Gym state lives only in rollout snapshots. The trainer save wakes the snapshot pump, which waits for the checkpoint to be durable off the training loop and then captures Gym anchored to it, with the gym_unavailable retry and max_consecutive_failures budget it already has. The trainer cut no longer counts as a rollout snapshot, so that snapshot is not skipped for lack of data-plane mutations. Restore prefers the newest rollout snapshot. A trainer checkpoint restored on its own restarts its unfinished turn-level rollouts from their tasks; one with neither Gym state nor the marker is refused. A reserved attempt that continued earlier restored Gym state, and that this restart did not restore again, starts over as well. Ported from the trainer-boundary fallback in #4117, without its forced boundary snapshot, which blocked training on the asynchronous weight write. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…tart fallback Turn recovery now keeps Gym state only in rollout snapshots: the trainer checkpoint never pauses Gym, marks itself with gym_restart_fallback.json and wakes the snapshot loop. Document that, the restore of a trainer checkpoint without a later snapshot, and rollout_recovery.gym_prepare_timeout_s. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…de key Address review feedback on turn-level rollout recovery: - Derive a group's recovery granularity from its persisted restore level instead of storing both; recovery_granularity is no longer persisted. Schema 4 is new in this change, so no released checkpoint carries it. - GymCheckpointEpisode.capture_key is the single source of Gym's attempt-qualified key; the ledger and the controller use the wire type directly instead of converting tuples at each call. - Refuse turn recovery behind an environment server other than legacy_agent: typed servers build EpisodeId from the restored "<id>-a<N>" key, which Gym rejects, so every restored turn would restart until its row budget ran out. - Reject target-level overrides with target_level=turn: Gym exports every live episode, so a coarser route would fall outside the commit scope. - Mint the Gym checkpoint control token per run, classify a failed environment-server episode by Gym's terminal flag, and keep the /run timing on refused rows. - Abandon a reserved Gym attempt that this restart did not restore again. - Pass gym_instance_id and dispatch_recorder to run_rollout explicitly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
Move the event writer and the ledger-group lookup that the turn, sibling and rollout recovery hooks each copied into _single_controller_hook_utils.py, drop the turn hook's unused delegate passthrough, and forward gym_instance_id and dispatch_recorder from the sibling hook. The sibling recovery script now checks the persisted restore_level, since recovery_granularity is no longer saved. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
Note that only the current rollout_recovery.pt schema can be resumed and that target-level overrides are rejected with target_level=turn, since a checkpointing Gym deployment exports every live episode. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…lacing them Gym runs every row of a /run as its own task, and a stream that ends early cancels none of them. The sibling retry re-sent the missing rows under the same rollout ID while the old copies were still running in Gym, and a prompt-group retry left the old episodes for the next checkpoint to export. When a stream ends without some rows, the rows that never came back (and that Gym did not refuse at admission) are abandoned in the recovery ledger and queued for retirement, then retired immediately under dispatch admission, so no checkpoint is active and Gym accepts an idle retire. A failed retire is not fatal: the episodes stay queued and the next checkpoint retires them before it commits. A sibling re-send now runs as a fresh attempt under a new rollout ID; attempts that never reached Gym keep their identity. Prompt-group recovery retires and re-raises so the existing cohort retry takes over. The streamed-completion identity check reads the current gate ID from the ledger, and the functional-test hook resolves its group by ID and forwards the new recorder hooks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…the checkpoint gym_checkpoint.json recorded actor instances, episodes and staging keys, but not the Gym participants whose state each instance committed. Gym restores each live participant from its own state, so a participant missing from the restored deployment had its state silently dropped, and one the checkpoint never saw started empty, while the restore succeeded. The manifest now records each instance's participants: server name, kind, state directory and records digest, taken from the commit replies the adapter already validates. Before Gym installs anything, the adapter requires the live deployment to match exactly and each participant's state on disk to carry the committed digest. A mismatch leaves Gym untouched. A manifest without participant topology is rejected on load. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…y rollout After a Gym commit, the checkpoint waits for the few episodes Gym did not export because their reply is already on the wire. It did so by rebuilding the full Gym inventory from the ledger every 50 ms. That scan is synchronous and scales with every live rollout -- about 0.2 s per pass at 200k rollouts -- so it blocked the event loop that delivers those very replies, while every rollout stayed parked behind the checkpoint. The drain now checks only the pending episodes, through a ledger lookup that applies the same ownership rule as the inventory, and sleeps until the next data-plane mutation finishes instead of polling. Every ledger change runs inside a barrier mutation, so that wakeup cannot miss one. The barrier wakes these waiters on their own condition, leaving mutations queued behind a checkpoint undisturbed. The drain's timeout and stranded-session errors now report a count and a short sample rather than every episode identity. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
Contributor
Author
|
/ok to test e077bb1 |
macandro96
force-pushed
the
amahishi/ckpt-v2-gym-integration
branch
from
October 15, 2026 02:17
cf124ff to
4558c22
Compare
4 tasks done
macandro96
force-pushed
the
amahishi/ckpt-v2-gym-integration
branch
from
October 17, 2026 20:06
4558c22 to
f1a8f46
Compare
Contributor
Author
|
Folded into #4501 as 29dad27 ( Porting it onto the reworked #4501 changed a few things:
The unit lanes and the turn and sibling recovery functional tests pass on #4501. |
3 of 4 tasks
jQizhang
added a commit
that referenced
this pull request
Nov 10, 2026
Automodel 0.8.0 routes standard HF safetensors base loads through DCP (0bfcada01, #3616), whose planner requires every requested key. The PPO value model (and a reward model trained from a base LM) is a *ForTokenClassification/*ForSequenceClassification built on a *ForCausalLM checkpoint, so its new score head is absent and multi-GPU loads fail with "Missing key in checkpoint state_dict: score.bias" (test_value_worker_init_and_get_values[2gpu_dp2|2gpu_tp2sp]). Until NVIDIA-NeMo/Automodel#4710 lands, wrap Checkpointer.load_model: on init loads of standard HF state dicts, find the keys of heads the model adds to its checkpoint's architecture (same rule as #4710) that the checkpoint lacks, and skip exactly those for this load through skip_task_head_prefixes_for_base_model, which ModelState already honors with a non-strict init load. Heads the checkpoint carries, such as a trained reward model's, still load; any other missing key still fails. Tests: a base-LM checkpoint leaves the new score head at init while the backbone loads, and a saved score head loads; a tripwire fails once the unpatched load stops raising. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: larkzhang-nv <[email protected]>
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When checkpoint admission refuses part of a prompt group, the collector currently waits for the original result stream to finish before resending those rows. A cohort verifier such as GenRM can keep accepted siblings waiting for the refused siblings, so the stream never finishes and those siblings are never dispatched.
This change schedules refused rows independently and resubmits them when the dispatch gate reopens, with bounded backoff if Gym is still closed. Accepted siblings continue on the original stream. Refusals preserve row identities and do not consume the row-failure retry budget.
Stacked on #4501, targeting
amahishi/ckpt-v2-gym-integrationatcf124ff9eaea61d5e0bac38f76becfc18924ae8b.Changes
No new configuration or Gym changes are required.
Validation
test_rollout_generation_failures.py,test_rollout_recovery.py, andtest_rollout_redispatch.py, using the base branch's pinned Gym revision.The commit includes a DCO sign-off.