Skip to content

fix(ppo): rebuild the critic optimizer on a warm start - #4213

Merged
yuki-97 merged 1 commit into
NVIDIA-NeMo:mainfrom
bg51717:fix/ppo-critic-warm-start-fresh-optimizer
Sep 21, 2026
Merged

yuki-97 merged 1 commit into
NVIDIA-NeMo:mainfrom
bg51717:fix/ppo-critic-warm-start-fresh-optimizer

Conversation

@bg51717

@bg51717 bg51717 commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

What does this PR do ?

Makes ppo.warm_start_value_checkpoint carry 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.

@bg51717
bg51717 requested review from a team as code owners September 19, 2026 19:26
@copy-pr-bot

copy-pr-bot Bot commented Sep 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Sep 19, 2026
@bg51717 bg51717 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Sep 19, 2026

@bg51717 bg51717 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/guides/ppo.md Resolved
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]>
@bg51717
bg51717 force-pushed the fix/ppo-critic-warm-start-fresh-optimizer branch from ad103a8 to 601673b Compare September 20, 2026 10:24
@bg51717

bg51717 commented Sep 20, 2026

Copy link
Copy Markdown
Member Author

/ok to test 601673b

@bg51717
bg51717 requested a review from yuki-97 September 20, 2026 14:44

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on checkpoint.finetune, not on load_optim, and nothing here sets finetune. But NeMo-RL never advances train_state, so a NeMo-RL-written seed records step=0 and the restore is a no-op — a checkpoint written at step 15 still lands in iter_0000000.
  • Whether dropping the carry-over loses something worth a config knob. It does not, in practice: the Megatron critic's train_iters comes 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.

@yuki-97
yuki-97 merged commit 094a932 into NVIDIA-NeMo:main Sep 21, 2026
85 checks passed
yfw added a commit that referenced this pull request Sep 21, 2026
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]>
@yfw yfw mentioned this pull request Sep 22, 2026
4 tasks done
lauradang added a commit to lauradang/RL that referenced this pull request Sep 22, 2026
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]>
lauradang added a commit to lauradang/RL that referenced this pull request Sep 29, 2026
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]>
pthombre added a commit that referenced this pull request Oct 1, 2026
…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]>
pthombre added a commit that referenced this pull request Oct 7, 2026
…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]>
pthombre added a commit that referenced this pull request Oct 8, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants