Who calls what when a Gym-aware rollout snapshot is saved, and when it is restored
The full stack: #4264 (ad3c9cb, the actor calls) →
#4265 →
#4266 (98b3b6c, the Single Controller). Gym links pin f4fcf8c.
Before
A rollout snapshot held RL's own state and TQ. Gym was told nothing, so an unfinished multi-turn rollout started over after a crash.
This stack
Each snapshot also pauses Gym at turn boundaries and has every Gym server save its part into the same folder; restore loads it back and continues each rollout from its last finished turn.
Status
All three PRs open, under review. Off by default.
Nine pages on this stack — this one: who calls what when a snapshot is saved and restored.
Three layers. The Single Controller decides when to save and owns the snapshot folder. It never talks to Gym directly: it calls the
NemoGym actor, which calls each Gym server over HTTP. The Gym servers are the policy model server (passes model calls to vLLM), the agent server (runs the
multi-turn loop), and the resource server (tool and environment state). Blue arrows are Ray calls inside RL, orange are HTTP calls to Gym, green are
files written or read. Dotted words have a short explanation: hover or tap them.
Saving
Rollouts are paused from step 1 to step 5: new Gym rollouts are not sent, and Gym refuses new model calls. RL's own cut (step 3) runs under the
data-plane barrier, after Gym has finished writing, and the folder is published with one rename only when every part is on disk. Code:
_prepare_and_commit_gym_checkpoint,
_save_rollout_checkpoint_locked, and the actor side in
prepare_checkpoint /
commit_checkpoint.
Restoring
Setup on the driver loads TQ first, then has Gym load its state while everything stays paused. Only after the Single Controller has loaded its own
bookkeeping and given each unfinished rollout a new run n+1 does it resume Gym. A rollout that used a restart-only resource is thrown away and starts over.
Code: setup.py:1872-1990, single_controller.py:770-797.
What is saved, and who loads it back
In the snapshot folder
Written by
Loaded by
agent state, plus the continuation index (continuations.jsonl)
manifest: Gym's commit result and the topology fingerprint
Single Controller
setup, to check before loading
One line of a continuation index (fields from Gym's
AgentContinuationRoot; values as in Gym's own tests). It says: rollout
p7_g2 was parked during its first run (run 0, Gym key p7_g2), its last finished turn ended with model call call-2,
and it depends on version 3 of the tools server's state. On restore, Gym sets it up again as run 1 and it continues after call-2.
So what. Gym never decides when to checkpoint and RL never touches Gym's files directly: the Single Controller drives, the
actor fans out, each server saves and loads only its own part. The cost is the pause: rollouts wait from step 1 to step 5, which includes Gym's drain
(up to prepare_timeout_s, 300 s by default), Gym's commit, RL's cut and the rename. The stack has no timing numbers for that pause yet.