How the new rollout-checkpoint classes fit together, and whether the shape is clean
NVIDIA-NeMo/RL #5011, part 1 of 11 in the partial-checkpointing stack.
All permalinks pin the PR head 7171e5d.
Before
About 30 save and restore methods sat on the single controller itself, with "is Gym present?" checks inside them.
This PR
The controller now owns three objects and calls them from 6 of its methods, 15 calls in all. Gym-specific code sits behind one of the three.
Status
The shape is clean. Calls go one way, down. A few extra pieces are flagged in review comments (C3, C5). None is a bug.
Two pages on this PR, one question each. This one: what calls what.
Read the figure top to bottom. The top box is the controller and the methods of its own that make calls.
Each green arrow is a call, labelled with the method it calls. The middle row holds the three objects the controller owns: one that restores, one that saves, and one for the environment (Gym, or a do-nothing stand-in).
The bottom row is the Gym chain under the environment object. Most of that chain existed before this PR.
Is this a good design?
What is clean
Calls go one way: controller โ three objects โ Gym. Nothing below calls up into the controller. It reads the controller's step counters through one callback, read_progress().
The saver and the restorer never call each other. They share only RolloutParts, and the only thing in it they change is RolloutRuntimeState.
All Gym-specific checkpoint code now sits behind one object. The do-nothing backend replaces the old "is Gym present?" checks in the controller.
The controller's whole contact with checkpointing is 15 calls in 6 of its methods.
What to watch
C5:GymEnvironmentSnapshot.check_against_cut only calls back into its parent's validate_cut. That is the one arrow that points back up.
C3: the controller's setup code (L713โL749) is copied by hand into a test helper. Both copies must be edited together.
Gym is four hops deep: environment object โ coordinator โ Ray actor โ adapter. Only the first hop is new. The other three came with #4500, so this PR is not the place to merge them.
The recovery ledger is the shared hub: the restorer, the saver and the Gym object all read it, and it lives in RolloutManager.
So what. The split is sound, and it is the right shape to build the next 10 PRs on. The extra pieces are small and each has a review comment.
None of them changes behavior, so they can be fixed in this PR before later PRs copy the pattern.