Forcing the policy ratio to 1 is exact only on the first optimizer step, whatever the sampler

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

Before
SingleController's 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.
This PR
Drops the ready_first rejection. Adds one rule in both PPO trainers: a forced ratio needs ppo.ppo_epochs: 1.
Status
Fixed by this PR. The review found no bugs. It asks for two small cleanups (end of page).

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).

\mathcal{L}(\theta)=-\frac{1}{N}\sum_{t}\; \htmlClass{t1}{\underbrace{\mathrm{TIS}\!\left(\frac{\pi_{\text{prev}}(o_t)}{\pi_{\text{gen}}(o_t)}\right)}_{\text{(1) fixes sampler lag}}} \cdot \htmlClass{t2}{\underbrace{\min\!\Big(r_t A_t,\;\mathrm{clip}(r_t,1-\varepsilon,1+\varepsilon)\,A_t\Big)}_{\text{(2) trust region},\;\; r_t=\pi_\theta(o_t)/\pi_{\text{prev}}(o_t)}}

Which runs get more than one optimizer step per batch

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.

GRPO on SingleController: 1 optimizer step per batch step 1 · weights W0 true r = W0 / W0 = 1 forced r = 1 same config.py L1714: batch = 1 optimizer step, every algorithm Streaming chunks add up gradients and still take one step. Was rejected with ready_first before this PR. Now allowed. PPO, ppo_epochs: 4 (the default), forced ratio epoch 1 · weights W0 true r = W0 / W0 = 1 forced r = 1 same epoch 2 · weights W1 true r = W1 / W0, clipped forced r = 1, no clip no trust region epoch 3 · weights W2 true r = W2 / W0 forced r = 1 no trust region epoch 4 · weights W3 true r = W3 / W0 forced r = 1 no trust region PPO, ppo_epochs: 1, forced ratio (now required) epoch 1 · weights W0 true r = forced r = 1 same SingleController: config.py L1426-L1433 raises ValueError legacy trainer: ppo.py L539-L542 asserts at setup Both fire before any GPU work, for every sampler. forced ratio equals the true one forced ratio is wrong: the update is not clipped Term (1) handles vLLM's lag in every box.

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.

What the PR changes

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

So what. GRPO users on SingleController can now combine 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.