PR #4200 · issues #4558, #4557 · stacked on #4124 (what forest training is) · permalinks at c9c1b020
Forest checkpoint/resume is not supported initially (config.py at the base). The list of model calls picked for training lived only inside one request, so a retry or restart had nothing to rebuild from.What the ledger is. An RL object, not a Gym one: RolloutRecoveryLedger in nemo_rl/experience/rollout_recovery.py. The RL rollout manager owns one. It is RL's notebook of every prompt group that has been sent to Gym but not yet trained on: for each rollout, which attempt is current, whether it finished, its reward, and the receipt Gym sent back. Gym only supplies the receipt; it keeps no ledger. RL writes the ledger to rollout_recovery.pt at each checkpoint and reads it on resume.
At a checkpoint, two things are saved. Groups still generating go into the ledger: one record per rollout (a sibling), holding Gym's receipt, the reward, and now the selection (logical_selection, written in state_dict, recovery schema 4). Finished groups are saved as rows in the replay buffer; forest rows carry owner tags that say which rollout each row belongs to. On resume, prepare_for_restart keeps finished siblings and regenerates the rest. The retry path now reads the selection back from the ledger (rollout_manager.py) instead of from the request.
The two paths share one ledger, one TQ snapshot and one restart rule. They split in two places only: the attempt record gains logical_selection, and replay restore checks owner tags instead of "one row per rollout" (replay_buffer.py). Ordinary schema-3 files still load; forest files older than schema 4 are refused.
🔴 C2 review comment — single_controller.py:1222-1234 (mode and padding check)
Where the change lands: RL only. No Gym change: the receipt Gym already sends is enough.
The PR makes four changes:
logical_selection is a new field on each attempt record (file format 3 → 4), and rollout_manager.py reads it from there instead of from a dict that lived only in one request. First hunk below.load_state_dict accepts groups whose rows carry owner tags, instead of insisting on one row per rollout. Step 4 in the figure.UnresolvedCaptureAcknowledgement), and that now applies to every capture run, not just forest runs. Second hunk.@@ rollout_manager.py L2477-L2484 · _generate_for_finalization_attempt logical_selections=( - tuple(rollout_selections[i] for i in range(len(rollout_ids))) + tuple( + sibling.current_attempt.logical_selection + for sibling in self._recovery_ledger.get_group( + group_id + ).siblings + ) if self._forest_training @@ rollout_manager.py (base L2243-L2259, head L2244-L2252) · generate_for_finalization except Exception as error: - if ( - self._forest_training - and classify_rollout_failure(error) is not FailureClass.INFRA - ): + if isinstance(error, UnresolvedCaptureAcknowledgement): raise reason = type(error).__name__ if classify_rollout_failure(error) is FailureClass.INFRA: infra_attempts += 1 last_infra_error = error - # Forest selections are request-local until checkpoint recovery - # persists them. Drop this abandoned group through the usual - # bounded policy; do not redispatch and lose sealed selections. - if self._forest_training: - break if infra_attempts >= policy.max_infra_attempts: break @@ config.py (base L1516-L1521) · validate_single_controller_config - if master_config.checkpointing["enabled"]: - raise ValueError("Forest checkpoint/resume is not supported initially") - if master_config.rollout_checkpointing.snapshot_attempt_interval_s is not None: - raise ValueError( - "Forest rollout checkpoint/resume is not supported initially" - ) @@ setup.py (base L1349-L1350) · setup_single_controller trainer_checkpoint_path = checkpointer.get_latest_checkpoint_path() - if token_capture_cfg.forest_training and trainer_checkpoint_path is not None: - raise ValueError("Forest checkpoint/resume is not supported initially")
Also in the PR: every Megatron resume now restores the saved random-number state (load_rng), for all algorithms, not only forest runs.
forest_training and the padding size match the checkpoint; and run CI on the head, which has not run yet. No CI test runs a forest save, kill and resume end to end yet.