What keeps running, and what waits, while RL saves a turn snapshot
NVIDIA-NeMo/RL #4500
(Gym turn-level rollout recovery). Read from the code at head 341b9ad; Gym at 120d516.
Step numbers match page 3.
Before
A rollout snapshot held TQ writes only while it saved TQ. Nothing paused Gym.
This PR
With target_level: turn, a Gym phase comes first: new Gym runs wait and runs already in Gym park, then the same TQ save runs.
Status
Proposed in this PR, with open review findings. Nothing measures how long the Gym phase lasts, and trainer checkpoints wait for it. review comment — single_controller.py:4727
Four pages on this PR. This one: which parts of training keep running during a snapshot.
Background. A snapshot runs in its own task,
_rollout_checkpoint_pump, not in the
train pump or the rollout pump. (The train pump does save TQ and the ledger itself, inside every
trainer checkpoint,
but with no Gym phase. With turn, that save does not count as a rollout snapshot; the train pump
wakes this task
to take one tied to the new checkpoint.) Nothing tells the other pumps to stop. They wait only when they reach something the
snapshot holds. The snapshot holds three things: the
dispatch gate,
Gym itself (parked), and the
TQ barrier.
Dotted words have a short explanation: hover or tap them.
Ten parts, three phases
Each row name links to the code that decides that row. On main, the
middle column already happened at every rollout snapshot; the left column is what turn adds.
The three places the trainer actually waits
It runs out of data. No new rollouts finish while Gym is parked. If the buffer empties during the Gym
phase, the trainer has nothing to train on.
Every TQ write during the TQ save. Claiming a batch
(claim_for_training), the
advantage writeback (:5873) and end-of-step cleanup
(:3503) are all TQ writes. The GPU math in between
keeps going. Refit comes after the cleanup (:3670), so
it runs late too.
A trainer checkpoint waits for the whole snapshot. It takes the same lock
(:5300 vs
:4823), held from the first Gym step until the
snapshot folder is renamed. If refit was put off for that save
(:3713-3728), the generation engines stay
asleep for that time too. The lock was shared on main; the Gym phase makes the wait longer.
review comment — single_controller.py:4727
It goes the other way too: the snapshot gives way to the trainer. It is skipped while an optimizer step is
being committed, and thrown away if a train step finishes during the Gym phase.
review comment — single_controller.py:4906
So what. A turn snapshot stops rollout production, not training. Training slows only when
it runs out of buffered data, hits a TQ write during the TQ save, or tries to save a trainer checkpoint. The timers
that watch single rollouts are paused. The stall watchdog is not, but any finished train step resets it, and by
default it only warns. review comment — config.py:719