NVIDIA-NeMo/RL #5079
· fix(sc): allow forced ratio with ready_first for GRPO, and one-epoch PPO · permalinks pin the PR head 84afc6e
· background: the #4670 page on the same flag
ready_first sampler rejected force_on_policy_ratio: true unless CISPO was on, even for GRPO, where it is safe. PPO accepted it with ppo_epochs: 4 (the default), where epochs 2–4 train with no trust region. Neither trainer checked.ready_first rejection. Adds one rule in both PPO trainers: a forced ratio needs ppo.ppo_epochs: 1.What the flag does. force_on_policy_ratio: true skips the extra trainer forward that
computes prev (the trainer's log-probs before this step's update). The loss then uses
curr.detach() in its place
(loss_functions.py L779-L780),
so the PPO ratio is 1 and is never clipped
(clipped_pg.py L152-L155).
ready_first that gap is large, so the sampler requires use_importance_sampling_correction: true. The forced ratio keeps this term, as TIS(sg[πθ] / πgen).One rollout batch, sampled by vLLM one weight version behind the trainer (what ready_first allows).
The trainer starts at weights W0. Each optimizer step moves it on: W1, W2, W3.
The sampler never decides this. ready_first only makes term (1) bigger, and TIS already
handles that. What decides is the number of optimizer steps on one batch. SingleController pins that to one
for every algorithm, and only PPO's ppo_epochs can raise it. value_training_mode
and critic_ppo_epochs change only the critic.
Where the change lands: RL only, setup checks only. No loss or trainer code changes.
single_controller_utils/config.py
and ppo.py,
plus tests and one docs paragraph. Legacy async PPO already rejects the forced ratio
(run_ppo.py L67-L68), so it needs nothing.
@@ single_controller_utils/config.py base L1735-L1742 · validate_single_controller_config, ready_first block if not master_config.loss_fn.use_importance_sampling_correction: raise ValueError("the ready_first sampler requires ...use_importance_sampling_correction=true") - if ( - master_config.loss_fn.force_on_policy_ratio - and not master_config.loss_fn.use_cispo - ): - raise ValueError( - "the ready_first sampler requires " - "loss_fn.force_on_policy_ratio=false unless loss_fn.use_cispo=true" - ) + # TIS corrects generation staleness; a forced ratio stays exact with one + # optimizer step per batch (enforced for PPO in _validate_algo_settings). @@ single_controller_utils/config.py L1426-L1433 · _validate_algo_settings, PPO-only branch + # A forced ratio equals the true one only on the first optimizer step taken + # on a batch; later epochs would train without any trust region. + if master_config.loss_fn.force_on_policy_ratio and algo_cfg.ppo_epochs != 1: + raise ValueError( + "loss_fn.force_on_policy_ratio=true requires ppo.ppo_epochs=1, got " + f"ppo.ppo_epochs={algo_cfg.ppo_epochs}. Set " + "loss_fn.force_on_policy_ratio=false to run multiple policy epochs." + ) @@ ppo.py L539-L542 · setup, force_on_policy_ratio block "force_on_policy_ratio requires train_global_batch_size == num_prompts_per_step * num_generations_per_prompt" ) + # Later epochs on the same batch would train without any trust region. + assert ppo_config.ppo_epochs == 1, ( + f"force_on_policy_ratio requires ppo.ppo_epochs=1, got {ppo_config.ppo_epochs}" + )
The first hunk is the one the CISPO-only exception
(#4670) had already loosened; this PR removes the rest of it.
The second and third close the gap the #4670 page noted: "PPO's ppo_epochs is not checked".
No shipped PPO config sets force_on_policy_ratio: true, so no recipe breaks.
The review ran the changed tests on CPU (all pass) and reverted each source change one at a time; each revert
made at least one new test fail.
Review comments (two small cleanups; visible to others once the review is published): C1 · single-controller.md:465 · sentence order C2 · test_ppo_setup.py:440 · match the full message
ready_first with
force_on_policy_ratio: true and skip the extra prev forward pass. The update is the same,
since the true ratio is 1 anyway. The author's multi-node MoE run matched (reward 0.832 vs 0.830 over 14 steps).
PPO users who set the flag must also set ppo.ppo_epochs: 1. Before this PR, the default of 4 silently
trained 3 of every 4 epochs with no clip.