NVIDIA-NeMo/RL #5056
(part 4 of the rollout-checkpointing stack, on top of
#5049). Permalinks pin the PR head dea7ae5a.
Two pages on this PR, one question each. This one: what the PR changes at the deadline.
When the deadline is due, the train loop saves a trainer checkpoint at the end of that step. Publishing it calls
trainer_checkpoint_published(),
which wakes a background task to snapshot the environment. Before this PR, the loop then hit break, and teardown
cancelled that task before it could save.
This PR has the train loop take the snapshot itself, in
save_at_deadline(), before it breaks.
The PR also adds a key that decides whether the environment is snapshotted after every trainer checkpoint, or only at the deadline.
Turn-level recovery no longer needs a timer
(rollout_snapshots_enabled() turns snapshots on for it):
| Environment state is saved | snapshot_on_trainer_checkpoint | snapshot_attempt_interval_s |
|---|---|---|
| After every trainer checkpoint, and at the deadline (default) | true | null |
| Only at the deadline — no pause of the environment during training | false | null |
| Also on a timer (here every 300 s) | true | 300 |
Where it lands: RL only. The deadline branch of the train loop in
single_controller.py,
the new save_at_deadline(),
and setup checks in setup.py.
@@ single_controller.py L3258-L3265 · _train_pump (deadline branch, as in the PR) if should_save_by_timeout: + if self._master_config.checkpointing["enabled"]: + # The trainer checkpoint holds no environment state, and no + # later step will wake the pump to snapshot it. + await self._finish_pending_save(blocking=True) + await self._rollout_snapshots.save_at_deadline() print("Timeout has been reached, stopping training early", flush=True) break
_finish_pending_save publishes step_7 first when the save is still finishing in the background,
because a snapshot must point at a published trainer checkpoint. The review asks for these cuts (none are in the PR yet):
save_at_deadline() repeats the try / log / re-raise code of the background loop. One shared _attempt() helper saves about 12 lines.save_reserve_seconds (below), merge a duplicate test, share setup across three new tests, and keep the docs to one table.tmp_step_N, while the weights are still being written. The last save then takes the longer of the two instead of their sum, and the branch above goes away (C6 then no longer applies; how the overlap works).Review comments: C2 · snapshots.py:960C1 · timer.py:466C5 · single-controller.md:235C6 · test_checkpointing.py:1679C7 · test_checkpointing.py:2858C8 · test_setup.py:1377C4 · snapshots.py:949 — GPU runC9 · single_controller.py:3272 — overlap
checkpoint_must_save_by for both saves. The review asks to delete that reserve rather than document it.