Repository navigation
fix(sc): allow forced ratio with ready_first for GRPO, and one-epoch PPO - #5079
Conversation
|
/ok to test e438af7 |
|
/ok to test 30022fe |
|
/ok to test 84afc6e |
mehraakash
left a comment
There was a problem hiding this comment.
Verdict: approve. Nothing blocks merge; no correctness bug found, and the central argument holds. On the SingleController GRPO path there is exactly one optimizer step per RL step on every sub-path (full-batch, streaming chunks, forest), so a forced ratio is identically the computed one, and the importance-sampling ratio the loss builds from the training forward is the same number a prev_logprobs pass would have produced. The removed ready_first check never protected GRPO; the CISPO carve-out already rested on this. The new ppo_epochs=1 guard closes a real pre-existing hole in both trainers (legacy default is 4 epochs), is reachable, and rejects no shipped config. The 11 tests the PR adds or changes pass on CPU; each fails if its validator line is reverted.
Design calls that look right: encoding the rule once per trainer, beside the sibling batch-size check in each trainer's own style, is the established pattern here, and a single home is not reachable because the rule spans loss_fn and ppo and the two trainers have unrelated MasterConfig classes. The two-line replacement comment that points at the PPO guard is the right shape. The convergence evidence is adequate: the computed ratio logging exactly 1.0 under ready_first is the mechanism itself, so 14 steps suffice.
Inline: one docs sentence, one optional reorder of the new check, one optional test parametrisation.
Two PR-body wording notes, no code change: prev_logprobs are not recomputed under a forced ratio, the pass is skipped (logprob_passes_required) and the loss reuses the training forward; and "for every sampler, in both trainers" is a little broad, since the async PPO launcher (examples/run_ppo.py) still rejects a forced ratio, so the new legacy assert governs synchronous PPO in practice. Pre-existing and optional: the sampler table at docs/guides/single-controller.md L477 says no ready_first recipe ships, but grpo-llama3.1-8b-instruct-2n8g-ready-first-single-controller.yaml does.
Generated by Claude Code
… GRPO The ready_first sampler rejected force_on_policy_ratio=true unless use_cispo was set, on the grounds that batches mix weight versions. The mixing is between generation and trainer weights, which the importance sampling correction ready_first already requires handles. The PPO ratio compares the trained weights with the weights that computed prev_logprobs, and on the SingleController GRPO path those are the same: one RL step is exactly one optimizer step, and prev_logprobs are recomputed by the trainer within the step. The ratio is therefore 1, and forcing it does not change the update. Keep the rejection for PPO, which can take several optimizer steps per rollout batch, and keep requiring use_importance_sampling_correction. Signed-off-by: Sriharsha Niverty <[email protected]>
A forced ratio equals the true PPO ratio only on the first optimizer step taken on a rollout batch. Full-batch PPO runs ppo_epochs steps on the same batch, so with force_on_policy_ratio=true epochs 2..N trained without any trust region. Neither the SingleController nor the legacy PPO trainer checked this, and ppo_epochs defaults to 4. Reject force_on_policy_ratio=true with ppo_epochs != 1 in both trainers, for every sampler. The ready_first sampler's PPO-specific forced-ratio rejection is now covered by this rule, so ready_first only requires use_importance_sampling_correction, and one-epoch PPO may force the ratio with it. Signed-off-by: Sriharsha Niverty <[email protected]>
84afc6e to
623613e
Compare
A streaming PPO config with the default ppo_epochs now gets the streaming message, which names the fix that works. Also cover acceptance under both samplers, keep the ready_first doc clauses together, and list the shipped ready_first exemplar. Signed-off-by: Sriharsha Niverty <[email protected]>
|
/ok to test 623613e |
|
Thanks for the review. Addressed in cf044de:
|
|
/ok to test cf044de |
|
/ok to test ba64159 |
The
ready_firstsampler rejectsforce_on_policy_ratio=trueunless CISPO was in use, on the grounds that batches mix weight versions. However, the mixing is between generation and trainer weights, which the importance sampling correctionready_firstalready requires handles. On the SingleController GRPO path, one RL step is exactly one optimizer step, andprev_logprobsare recomputed by the trainer within the step.Keep the rejection for PPO, which can take several optimizer steps per rollout batch, and keep requiring
use_importance_sampling_correction.What does this PR do ?
force_on_policy_ratio=truewith theready_firstsampler for GRPO. Previously this requireduse_cispo=true.ppo.ppo_epochs=1wheneverforce_on_policy_ratio=true, in both the SingleController and the legacy trainer, for every sampler.Why
A forced ratio equals the true PPO ratio only on the first optimizer step taken on a rollout batch.
prev_logprobsare recomputed by the trainer before that update. The ratio is always 1, so forcing it doesn't change the update. The weight-version mixingready_firstintroduces is between generation and trainer weights, which the required importance-sampling correction already handles.ppo_epochsoptimizer steps on the same batch (default 4). With a forced ratio, epochs 2..N trained without any trust region, and neither trainer checked for it. One-epoch PPO, including streaming PPO, keeps the ratio exact and may now force it withready_firsttoo.Validation
Multi-node MoE GRPO,
ready_firstlag 1: with the computed ratio, the logged ratio was exactly 1.0 on every step. With a forced ratio, reward and grad norm matched (reward 0.832 vs 0.830 over 14 steps).Tests
test_setup.py: GRPO withready_firstand a forced ratio is accepted.test_ppo_setup.py: PPO with a forced ratio andppo_epochs=4is rejected underin_orderandready_first; withppo_epochs=1it is accepted withready_first. Missing importance-sampling correction is still rejected.test_ppo.py: legacy PPO setup rejects a forced ratio withppo_epochs=4before allocating resources.