Repository navigation
fix(ppo): rebuild the critic optimizer on a warm start - #4213
Conversation
bg51717
left a comment
There was a problem hiding this comment.
Reviewed with a team of agents (rl-expert, test-agent, bug-finder, devil's-advocate); one inline comment on a doc claim contradicted by upstream Megatron-LM source.
Generated by Claude Code
A warm start takes the critic's weights from a different run, but both PPO setups routed the seed through the ordinary resume path, so they also restored that run's Adam state and LR-scheduler step count. The critic then began preconditioned by the seed run's gradient statistics and skipped its own LR warmup entirely. Since the critic feeds advantages, that bias propagates through critic -> advantage -> policy -> rollout for the rest of the run. Drop the optimizer path whenever the seed is a warm start; a real resume is untouched and still restores it. Neither backend needs anything further: Megatron turns optimizer_path=None into load_optim=False, which also keeps opt_param_scheduler out of the loaded state dict, and the AutoModel checkpointer gates its load_optimizer(scheduler=...) call on the same path. This also retires the requirement that the seed and this run agree on the value scheduler -- lr, min_lr, the scheduler block, train_global_batch_size and the train_iters budget were all compared on load and asserted on the first mismatch. The existing SingleController warm-start test asserted the old behaviour; it now pins the new one. The legacy path had no positive warm-start coverage at all, since its DummyCheckpointer short-circuited path resolution, so it gets one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: bg51717 <[email protected]>
ad103a8 to
601673b
Compare
|
/ok to test 601673b |
yuki-97
left a comment
There was a problem hiding this comment.
LGTM. I went looking for problems and did not find one.
The load path checks out against the pinned Megatron-Bridge source: optimizer_path=None becomes load_optim=False in _create_checkpoint_config, and load_checkpoint gates the optimizer and the opt_param_scheduler restore on that one flag, so the scheduler-match assertions the deleted docs section described genuinely cannot fire any more. The weights_path set / optimizer_path None combination is not new either — get_resume_paths already produced it for a seed saved with save_optimizer: false — so no untested state is introduced. Swapping the real get_resume_paths into the legacy test double is safe: that dummy's get_latest_checkpoint_path always returns None, so the warm start is the only input that ever resolves.
Two things I chased that came back negative, recorded so nobody repeats them:
- The donor's mcore
TrainState. It restores oncheckpoint.finetune, not onload_optim, and nothing here setsfinetune. But NeMo-RL never advancestrain_state, so a NeMo-RL-written seed recordsstep=0and the restore is a no-op — a checkpoint written at step 15 still lands initer_0000000. - Whether dropping the carry-over loses something worth a config knob. It does not, in practice: the Megatron critic's
train_iterscomes from this run's budget and the nine-field scheduler assert forces the LR block to match, so continuation only ever worked between runs with an identical schedule and step budget, and no config in the tree sets the key non-null.
Worth noting as independent support rather than a request: jiaqiz/ppo-dev did the same thing for the SWE-PPO campaign, gated on a provenance file in the seed. Its motivation was sharper than "stale Adam moments" — Megatron writes distributed-optimizer state as dp_reshardable, which is not in DistributedOptimizer.checkpoint_fully_reshardable_formats, so the state keys carry a dp_group_idx_{...} prefix taken from expt_model_parallel_rank for the MoE group. A seed trained under a different EP/TP/PP layout therefore fails the load outright, while the weights reshard fine. Making this unconditional removes that failure mode for everyone rather than for seeds that happen to carry the marker file.
Brings #4213 (rebuild the PPO critic optimizer on a warm start) and #4206 (strip staged token arrays from vLLM capture responses). No conflicts. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Bring main a9c3178 (25 commits since the previous merge base 702cd79) into the branch on top of the #5 submodule bump (00621c2). Conflicts: - nemo_rl/algorithms/single_controller_utils/setup.py and tests/unit/single_controller/test_setup.py: keep main's sharded Gym stacks (NVIDIA-NeMo#3373), multi-teacher MOPD (NVIDIA-NeMo#4045), critic optimizer rebuild (NVIDIA-NeMo#4213) and Mooncake storage checkpoints (NVIDIA-NeMo#3898) next to the Megatron token-capture setup guards and backend wiring; the vLLM-only capture guard is replaced by the backend-aware one. - tests/unit/models/generation/test_vllm_token_capture_hosting.py: keep main's stripped staged token arrays (NVIDIA-NeMo#4206) on top of the shared vLLM chain-cache prefix resolution. - pyproject.toml (semantic conflict, auto-merged by git): main NVIDIA-NeMo#3566 removed `exclude-dependencies = ["nvidia-cutlass-dsl-libs-base"]` in favour of per-version dependency-metadata overrides for CUTLASS DSL 4.5.x, while this branch's mcore extra pinned nvidia-cutlass-dsl[cu13]==4.8.0.dev0 (68b63da). Without the exclusion that pin drags in the pre-release nvidia-cutlass-dsl-libs-base==4.8.0.dev0, which uv refuses for a transitive dependency, so `uv lock` no longer resolves. Pin 4.6.2 instead: it is the stable release flashinfer-python 0.6.18.post1 actually requires (>=4.6.2a0), and it is the pin NVIDIA-NeMo#4139 uses for the same Megatron-Bridge bump on main. - uv.lock: regenerated from main's copy with uv 0.11.28 (the docker/Dockerfile pin), so it carries main's new git pins (Model-Optimizer, sglang, Lens, TransferQueue, nvidia-resiliency-ext, torch_memory_saver) together with the Gym and Megatron-Bridge main pins and the flashinfer index spelling from #5. `uv lock --check` passes with uv 0.11.28 and 0.12.5. Submodule pins: Automodel follows main (72daceffa); Gym (9fc05c0ff) and Megatron-Bridge (fcea83a85) stay at the #5 pins, which descend from main's. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Laura Dang <[email protected]>
Bring main a9c3178 (25 commits since the previous merge base 702cd79) into the branch on top of the #5 submodule bump (00621c2). Conflicts: - nemo_rl/algorithms/single_controller_utils/setup.py and tests/unit/single_controller/test_setup.py: keep main's sharded Gym stacks (NVIDIA-NeMo#3373), multi-teacher MOPD (NVIDIA-NeMo#4045), critic optimizer rebuild (NVIDIA-NeMo#4213) and Mooncake storage checkpoints (NVIDIA-NeMo#3898) next to the Megatron token-capture setup guards and backend wiring; the vLLM-only capture guard is replaced by the backend-aware one. - tests/unit/models/generation/test_vllm_token_capture_hosting.py: keep main's stripped staged token arrays (NVIDIA-NeMo#4206) on top of the shared vLLM chain-cache prefix resolution. - pyproject.toml (semantic conflict, auto-merged by git): main NVIDIA-NeMo#3566 removed `exclude-dependencies = ["nvidia-cutlass-dsl-libs-base"]` in favour of per-version dependency-metadata overrides for CUTLASS DSL 4.5.x, while this branch's mcore extra pinned nvidia-cutlass-dsl[cu13]==4.8.0.dev0 (68b63da). Without the exclusion that pin drags in the pre-release nvidia-cutlass-dsl-libs-base==4.8.0.dev0, which uv refuses for a transitive dependency, so `uv lock` no longer resolves. Pin 4.6.2 instead: it is the stable release flashinfer-python 0.6.18.post1 actually requires (>=4.6.2a0), and it is the pin NVIDIA-NeMo#4139 uses for the same Megatron-Bridge bump on main. - uv.lock: regenerated from main's copy with uv 0.11.28 (the docker/Dockerfile pin), so it carries main's new git pins (Model-Optimizer, sglang, Lens, TransferQueue, nvidia-resiliency-ext, torch_memory_saver) together with the Gym and Megatron-Bridge main pins and the flashinfer index spelling from #5. `uv lock --check` passes with uv 0.11.28 and 0.12.5. Submodule pins: Automodel follows main (72daceffa); Gym (9fc05c0ff) and Megatron-Bridge (fcea83a85) stay at the #5 pins, which descend from main's. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Laura Dang <[email protected]>
…test main made is_final_checkpoint a required keyword of SingleControllerActor._save_checkpoint (#4213 lifecycle changes); the rebased PR test still used the old two-argument form and failed with a TypeError in the Slurm verification run. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
…test main made is_final_checkpoint a required keyword of SingleControllerActor._save_checkpoint (#4213 lifecycle changes); the rebased PR test still used the old two-argument form and failed with a TypeError in the Slurm verification run. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
…test main made is_final_checkpoint a required keyword of SingleControllerActor._save_checkpoint (#4213 lifecycle changes); the rebased PR test still used the old two-argument form and failed with a TypeError in the Slurm verification run. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
What does this PR do ?
Makes
ppo.warm_start_value_checkpointcarry over the critic's weights only — the optimizer and LR scheduler are rebuilt.Test
PPO setup (both the legacy and SingleController paths) and checkpoint-helper unit tests: 365 passed.