Skip to content

feat(cc): support SingleController checkpoint and resume - #4200

Merged
terrykong merged 7 commits into
mainfrom
aroshanghias/cc-checkpoint-resume-20260918
Oct 30, 2026
Merged

terrykong merged 7 commits into
mainfrom
aroshanghias/cc-checkpoint-resume-20260918

Conversation

@aroshanghias-nvd

@aroshanghias-nvd aroshanghias-nvd commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

CC runs can now resume through the shared SingleController checkpoint path. The recovery ledger persists attempt receipts and selected-call metadata, so restart restores published segment rows and reconstructs unfinished groups without repeating sealed siblings. Logical-owner metadata, execution padding, and replacement reserves survive recovery. Every Megatron training resume, for every algorithm, now loads saved RNG when the parallel layout supports it and preserves it through reference-model and wrapper initialization; fresh runs and PEFT warm starts are unchanged.

This PR targets main and builds on merged #4124. Recovery supports schemas 2 through 5; forest recovery requires schema 5 plus saved forest-mode and execution-padding metadata. Schema 4 contains the renamed capture receipts from #4124, without forest selection. Receipt-free v2/v3 checkpoints remain readable; pre-v4 token-capture receipts are rejected with instructions to restart the rollouts. Restore rejects changes to either setting before replay rows are loaded, including when no unfinished groups remain. Earlier experimental forest checkpoints without the current schema and compatibility metadata require a fresh run; ordinary schema-4 capture checkpoints remain supported. Failed captures may retain empty selections and pending call IDs; healthy empty selections are rejected, and pending calls remain outside attempt cleanup ownership. Forest groups support bounded data retries as well as infrastructure retries, using persisted selection metadata and fresh attempt identities. An unresolved capture acknowledgement now stops ordinary capture runs too, rather than being retried as a data error; uncertain writes are neither cleared nor redispatched.

The refresh preserves mandatory empty replacement-reserve sidecars through the current checkpoint storage helpers and refreshes the worker RNG fixture for current initialization. It also adopts Gym’s parent_resolution configuration rename. This schema-alignment follow-up does not change dependencies, the Gym pin or the lockfile.

Main-merge follow-up at a6f0977f8: aligned with the refreshed #4124, preserving agent-routing metadata, schema-5 forest state and legacy ordinary recovery. 1,172 Mac CPU tests passed. Focused type, formatting and lint checks passed; the inherited recipe minimize check passed on #4124. No new GPU validation is claimed.

Schema-alignment validation at 00fb150d6: 879 CPU tests passed on Mac, including 26 forest-recovery checks, legacy ordinary checkpoints and ordinary schema-4 captured receipts. Focused pinned Pyrefly, formatting and lint checks passed. The stack merge preserves the exact validated source tree.

Prior validation: 853 CPU tests passed on the foundation refresh before the configuration rename; the final inherited rename passed 318 focused checkpoint CPU tests. Native TQ continuation exactly matched uninterrupted controls in all four cases: healthy and failed captures at bootstrap and trainer-checkpoint boundaries, with captured media and interrupted publication. Twelve native checkpoint configuration cases also passed.

Eight-GPU trainer validation: model, optimizer, scheduler, and RNG restoration matched exactly. A controlled repeatability check reproduced the next-update divergence with timed Mamba/Triton autotuning (2,262 state-fingerprint differences on the second restart). With kernel choices pinned, both independent restarts matched the uninterrupted next update bit for bit, with zero state or kernel-choice differences. The checkpoint code was identical in both arms; pinning is a private validation setting, not a product change. The inherited parent-resolution rename leaves the tested policy worker, Megatron setup, and runtime pins unchanged. These bounded checkpoint checks are separate from the 20-step harness qualification on #4124 and full repository CI.

Review follow-up validation: 861 CPU tests passed across checkpointing, replay, recovery races, setup, and rollout management. Disabling compatibility validation makes all six mode/padding regressions fail; removing the obsolete-snapshot guard also fails its message-specific test. Both requested GPU resume scripts already belong to the CI:L1 suites; execution on the updated head remains pending.

Closes #4558
Closes #4557

@copy-pr-bot

copy-pr-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Sep 18, 2026
@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-capture-redesign-20260914 branch 2 times, most recently from 083ece0 to 33ad46e Compare September 30, 2026 16:43
@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-checkpoint-resume-20260918 branch 2 times, most recently from 6609363 to 1ede30d Compare October 5, 2026 20:58
@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 1ede30d

@aroshanghias-nvd aroshanghias-nvd added the CI:L1 Run doctests, unit tests, and functional tests label Oct 5, 2026
@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-checkpoint-resume-20260918 branch from 1ede30d to 72235d7 Compare October 6, 2026 01:18
@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-capture-redesign-20260914 branch from c617a2c to 46d9f6a Compare October 7, 2026 21:56
@aroshanghias-nvd
aroshanghias-nvd marked this pull request as ready for review October 15, 2026 16:21
@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-checkpoint-resume-20260918 branch 3 times, most recently from c9c1b02 to 63631ae Compare October 20, 2026 18:44
@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 63631ae

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 5039e3d

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test a9b7cd9

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-checked at 93d1e8f. Thanks for the rebase and the fixture fix: the RNG unit test's missing names and the stale forest-guard docs are both fixed, so I dropped those two comments.

Before merge

  1. Run CI on the head. The last /ok to test was for a9b7cd9; two commits landed after it, and only the bookkeeping checks (DCO, copyright, title) ran on 93d1e8f. Please run /ok to test 93d1e8ffa77322304ac649a4743bf112316ec5dc. The RNG change in (C5) touches every Megatron resume, so also confirm the existing resume tests pass: sft_resume_diamond.sh and grpo_checkpoint_single_controller.sh.

Inline comments

  1. (C2) A resume can run with a different forest mode or forest padding than the checkpoint was saved with. Record both at save time and check them on restore.
  2. (C3) The obsolete_empty checkpoint test passes even with its guard deleted; match on the error message.
  3. (C5) Drop the "Forest recovery" doc subsection. Move its two general lines (the capture-write stop and the RNG change on every Megatron resume) into the main recovery section, and keep the one forest limit (older CC checkpoints can't be resumed) in the context-compaction guide.
  4. (C6) Low priority: rebuild RolloutSelection from every saved field.
  5. (C8) Low priority: several new errors name the problem but not the value or rollout behind it. Add what is already in scope (schema found vs. needed, gate_id, group ID) so a failure can be triaged from the log.

PR description

  1. "retaining ordinary schema-2/3 recovery support": the code accepts {3, 4} (rollout_recovery.py#L47); schema 2 was not supported at the base either.
  2. Not mentioned: forest groups now get data retries as well as infra retries, and an unresolved capture acknowledgement now stops ordinary capture runs too (before, it was a retried data error).
  3. "Megatron policy RNG survive[s] recovery" reads as forest-only. Say that every Megatron resume, for every algorithm, now restores RNG (C5).
  4. The description no longer links any issue. Add Closes #4558 and Closes #4557. This PR targets #4124's branch, not main, so GitHub will not close them on merge; close them by hand after #4124 lands.

Follow-up (not blocking this PR)

  1. The 8-GPU bit-for-bit restart check in the description is good evidence, but no CI test runs a forest save → kill → resume yet. The CC functional script turns checkpointing off (grpo_async_gym_single_controller.sh#L123). Once #4124's Gym pin carries #3368 + #4128, add a context-compaction variant of grpo_checkpoint_single_controller.sh.

What works well

  1. The ledger is now the one source of truth for selections (the request-local dict is gone), which is what makes retry and resume possible, and UnresolvedCaptureAcknowledgement is a clean typed stop. The unit tests are thorough.

Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-4200-forest-resume.html

Generated by Claude Code

Comment thread nemo_rl/algorithms/single_controller.py Resolved
Comment thread nemo_rl/experience/rollout_recovery.py Resolved
Comment thread docs/guides/single-controller.md Resolved
Comment thread nemo_rl/algorithms/single_controller.py Resolved
@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 5fc2fa8

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: a14eed0 (PR #4200 from aroshanghias/cc-checkpoint-resume-20260918)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of aroshanghias/cc-capture-redesign-20260914 branch (fast-forward)

All submodule changes look good! ✨

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test a14eed0

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 00fb150 (PR #4200 from aroshanghias/cc-checkpoint-resume-20260918)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of aroshanghias/cc-capture-redesign-20260914 branch (fast-forward)

All submodule changes look good! ✨

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 00fb150

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test a6f0977

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: a6f0977 (PR #4200 from aroshanghias/cc-checkpoint-resume-20260918)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of aroshanghias/cc-capture-redesign-20260914 branch (fast-forward)

All submodule changes look good! ✨

@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-checkpoint-resume-20260918 branch from a6f0977 to 77f5564 Compare October 28, 2026 20:45
@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 77f5564

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 77f5564 (PR #4200 from aroshanghias/cc-checkpoint-resume-20260918)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of aroshanghias/cc-capture-redesign-20260914 branch (fast-forward)

All submodule changes look good! ✨

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 4d4e7dc

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 40a0dbc

Base automatically changed from aroshanghias/cc-capture-redesign-20260914 to main October 30, 2026 07:31
Persist rollout selections with receipts and reward metadata through retries
and cold restart. Restore logical replay ownership with schema-3 compatibility
for ordinary recovery and schema 4 for forests.

Restore policy RNG during Megatron resume and preserve it across reference-model
initialization. Preserve current capture refusal handling, metadata validation,
partial batches and setup-time router checks when integrating the foundation.

Validate with 1,690 CPU tests covering replay/checkpoint recovery, selection
persistence, retries, staging custody, controller setup and RNG handling. Lint
and formatting pass; distributed runtime qualification is separate.

Signed-off-by: Ali Roshan Ghias <[email protected]>
Reject incompatible replay settings before restoring rows, including checkpoints with no unfinished groups. Tighten corruption assertions, preserve all saved selection fields, improve recovery diagnostics, and clarify the scope of Megatron RNG restoration.

Signed-off-by: Ali Roshan Ghias <[email protected]>
@aroshanghias-nvd
aroshanghias-nvd force-pushed the aroshanghias/cc-checkpoint-resume-20260918 branch from 40a0dbc to 2eb829e Compare October 30, 2026 16:29
@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 2eb829e

@terrykong
terrykong enabled auto-merge (squash) October 30, 2026 20:15
@terrykong
terrykong merged commit d415d45 into main Oct 30, 2026
300 of 304 checks passed
@terrykong
terrykong deleted the aroshanghias/cc-checkpoint-resume-20260918 branch October 30, 2026 22:48
macandro96 added a commit that referenced this pull request Oct 31, 2026
…to 5

Turn-level recovery changes the rollout-recovery ledger's shape: a group
records its restore level instead of its recovery granularity, and each
attempt records its Gym instance and attempt. Main had meanwhile moved to
schema 4 for token-capture receipts (#4124) and schema 5 for forest
selections (#4200), so this shape is schema 6. Accepting schema 6 only would
fail any run resumed from a checkpoint main wrote; main itself loads schema
2 checkpoints again since #4551.

Schemas 2 to 5 now load and are rewritten in the schema 6 shape. A group's
recovery_granularity becomes its restore level; the values are the same.
Each attempt starts with no Gym turn state, as a new attempt does, because
those schemas predate it. An old checkpoint that already carries a restore
level, Gym attempt state or the turn level is refused rather than guessed
at. Main's per-version rules (receipts before schema 4, the forest selection
from schema 5) still apply to the version the checkpoint was written with.

Signed-off-by: Anish Mahishi <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
macandro96 added a commit that referenced this pull request Oct 31, 2026
…to 5

Turn-level recovery changes the rollout-recovery ledger's shape: a group
records its restore level instead of its recovery granularity, and each
attempt records its Gym instance and attempt. Main had meanwhile moved to
schema 4 for token-capture receipts (#4124) and schema 5 for forest
selections (#4200), so this shape is schema 6. Accepting schema 6 only would
fail any run resumed from a checkpoint main wrote; main itself loads schema
2 checkpoints again since #4551.

Schemas 2 to 5 now load and are rewritten in the schema 6 shape. A group's
recovery_granularity becomes its restore level; the values are the same.
Each attempt starts with no Gym turn state, as a new attempt does, because
those schemas predate it. An old checkpoint that already carries a restore
level, Gym attempt state or the turn level is refused rather than guessed
at. Main's per-version rules (receipts before schema 4, the forest selection
from schema 5) still apply to the version the checkpoint was written with.

Signed-off-by: Anish Mahishi <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
macandro96 added a commit that referenced this pull request Nov 2, 2026
…to 5

Turn-level recovery changes the rollout-recovery ledger's shape: a group
records its restore level instead of its recovery granularity, and each
attempt records its Gym instance and attempt. Main had meanwhile moved to
schema 4 for token-capture receipts (#4124) and schema 5 for forest
selections (#4200), so this shape is schema 6. Accepting schema 6 only would
fail any run resumed from a checkpoint main wrote; main itself loads schema
2 checkpoints again since #4551.

Schemas 2 to 5 now load and are rewritten in the schema 6 shape. A group's
recovery_granularity becomes its restore level; the values are the same.
Each attempt starts with no Gym turn state, as a new attempt does, because
those schemas predate it. An old checkpoint that already carries a restore
level, Gym attempt state or the turn level is refused rather than guessed
at. Main's per-version rules (receipts before schema 4, the forest selection
from schema 5) still apply to the version the checkpoint was written with.

Signed-off-by: Anish Mahishi <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
yfw added a commit that referenced this pull request Nov 2, 2026
…kind-advantages

Main added rollout recovery schema v4 (token-capture receipts, #4124) and
v5 (logical_selection, #4200), so failure_kind moves to schema v6. The
ledger still loads v2 to v5, with failure_kind=None.

Conflicts kept both sides: failure_kind next to logical_selection in the
ledger, SiblingSealResult and both seal calls; infra_failure next to the
Forest fields in ReassemblyRequest; the infra metric next to the logical
owner counts; the infra sample_mask next to the sampler top-k copy.

Main moved row building into _publish_rows, so finalize_group now passes
infra_failure in. With forest_training, each segment row takes its
rollout's flag, and infra_failure_sample_rate counts rollouts.

Tests: the v3 load test is now a v5 load test; the finalizer test sets
capture_key, as main's receipts need; a new Forest test checks that the
segment rows of a flagged rollout get sample_mask 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
macandro96 added a commit that referenced this pull request Nov 12, 2026
…rest training

Turn-level recovery (#4500) continues a restored episode as its next
attempt (<rollout_id>-a<N>) and keeps the calls the earlier attempt made,
still staged under that attempt's key. Forest training's ownership checks
(#4124, #4200) predate this and required every manifest row to be staged
under the current attempt's key. So every continued episode that had made
a model call before the checkpoint failed with "Forest recovery has
foreign staging ownership"; the rollout manager counted a data retry and
regenerated the episode from its prompt without logging why. Training
stayed correct, but turn (and prefix) recovery saved nothing under
forest training.

Accept a row staged under the current attempt or an earlier attempt of
the same rollout, the rule Gym's rebuild already applies through each
carried row's source_capture_key, at all four Forest ownership checks:
the recovery ledger, the finalizer request, selected-call planning and
logical-row finalization. Rows of another rollout or a later attempt are
still refused.

Also print each data retry with its error, so a prompt that is silently
regenerated shows why in the log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L1 Run doctests, unit tests, and functional tests Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context compaction: support trainer and rollout checkpoint/resume Context compaction: retry a failed prompt group instead of dropping it

3 participants