Repository navigation
Conversation
Port GRPO weight checkpointing into the single-controller loop: - setup: build a CheckpointManager, load the latest checkpoint's GRPOSaveState (or defaults), propagate pretrained_checkpoint into the policy config, and pass weights/optimizer resume paths into _build_trainer; carry save_state in SingleControllerBundle. - actor: restore _trainer_version/_train_steps/_max_rollout_version and consumed_samples/total_valid_tokens from save_state; after each train step, save on save_period, last step, or checkpoint_must_save_by timeout (top-k metric_name supported), and stop early on timeout. - tests: add test_sc_checkpointing.py; update setup and rollout-pump tests for the new bundle field. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: haitian-nvidia <[email protected]>
Extend SC checkpointing (phase 2 of checkpointing-plan.md) so resumed runs continue from the saved dataset position instead of replaying prompts from the top: - Save: snapshot StatefulDataLoader.state_dict() synchronously on the actor event loop (race-free vs the rollout pump iterating the same dataloader) and write train_dataloader.pt via asyncio.to_thread between policy save_checkpoint and finalize_checkpoint, matching the legacy order. - Restore: setup_single_controller loads train_dataloader.pt via load_dataloader_state (dataset-swap guard included) right after the dataloader is built; pre-phase-2 checkpoints without the file resume with a fresh position and a warning instead of crashing. - Epoch: the rollout pump's epoch counter is now persisted as current_epoch in training_info.json and restored on resume. Signed-off-by: haitian-nvidia <[email protected]>
Extend SC checkpointing to persist and restore the TQReplayBuffer across a
restart, so committed-but-untrained rollout groups survive a resume instead
of being regenerated. Active only when over_sampling=True; under the strict
quota (over_sampling=False) the restored window can never be completed, so
the buffer is intentionally not saved there.
- state_dict snapshots the ready slots on the event loop, then fetches each
group's rows from the DataPlane into a {partition_id, saved_capacity,
groups} envelope.
- load_state_dict validates the envelope and truncates to the current
capacity before any DataPlane write, then re-puts each group and returns
the restored count. Load only loads: staleness is left to the train pump's
first sampler.evict, which drops out-of-window restored groups and
releases their capacity permits.
- run() restores the buffer before the pumps start and acquires one
_buffer_capacity permit per restored group; truncation guarantees the
count never exceeds capacity, so the acquisitions cannot block (a blocking
acquire here would hang run() with no pump to release).
- save writes replay_buffer.pt between the dataloader save and
finalize_checkpoint; SingleControllerBundle now carries
last_checkpoint_path.
Signed-off-by: haitian-nvidia <[email protected]>
yuki-97
approved these changes
Jul 14, 2026
yuki-97
left a comment
Contributor
There was a problem hiding this comment.
thanks for supporting this, LGTM and merged into SC branch.
yuki-97
pushed a commit
that referenced
this pull request
Jul 15, 2026
Signed-off-by: haitian-nvidia <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
6 of 25 tasks
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.
What does this PR do?
Adds checkpoint save/restore to the single-controller (SC) RL loop, so a run can
resume from the latest checkpoint instead of starting over. It reuses the legacy
GRPO checkpoint machinery (
CheckpointManager,GRPOSaveState,load_dataloader_state) and keeps the same on-disk layout, extending it to thestate SC owns:
CheckpointManager, loads the latestGRPOSaveState(or defaults),propagates
pretrained_checkpoint, and passes the weights/optimizer resumepaths into
_build_trainer. The actor restores_trainer_version/_train_steps/_max_rollout_versionandconsumed_samples/total_valid_tokens, and after each train step saves onsave_period, the last step, or acheckpoint_must_save_bytimeout (top-kmetric_namesupported), stopping early on timeout.train_dataloader.ptis written on save andrestored via
load_dataloader_stateon setup;current_epochis persistedand restored.
TQReplayBuffer):state_dictfetches each ready group'srows from the DataPlane into an envelope;
load_state_dictvalidates andtruncates to the current capacity before any DataPlane write, then re-puts
each group.
run()restores it before the pumps start.Notable design points
over_sampling=True. Under thestrict quota (
over_sampling=False) each weight version gets exactly onedispatched batch and the pump never re-dispatches. A checkpoint can only hold
committed groups, so a partially-committed window could never be completed
on resume — the train pump would wait forever for groups that will never
arrive (an immediate stall under
force_in_order). Instead, resume restores_max_rollout_version = current_step - 1and regenerates the whole windowfrom the restored dataloader position. With
over_sampling=Truethere is noquota: restored groups are surplus, missing ones are regenerated by the
free-running pump, and stale ones are evicted — so persisting the buffer is
safe and saves wasted generation.
run()acquires one_buffer_capacitypermit perrestored group before the pumps start; if the restored count exceeded
capacity, that acquisition would hang
run()forever (no pump is running yetto release a permit).
load_state_dict's truncation to the currentmax_buffered_rolloutsguaranteesK <= capacity, asserted before acquiring— this closes a resume deadlock when resuming onto a smaller-capacity config.
state_dictsnapshot is taken synchronously on the event loop beforeany
await, so it cannot be torn by the rollout pump committing into the samebuffer concurrently.
matching legacy — they are regenerated on resume.
support (missing
train_dataloader.pt/replay_buffer.pt) resumes with afresh dataloader position / empty buffer and a warning, not a crash.
Testing
test_sc_checkpointing.py+test_tq_replay_buffer.py— counterrestore, save triggers, dataloader position round-trip, and replay-buffer
round-trip / preflight validation / permit accounting (incl. the
K == capacityno-hang case).tests/functional/grpo_checkpoint_single_controller.sh— atwo-run save→restart on 2 GPUs (Qwen3-0.6B, Megatron), verifying
weights/dataloader/replay-buffer restore and resume at the correct step
(step 2 → resume → step 4).
🤖 Generated with Claude Code