Skip to content

fix(sc): allow forced ratio with ready_first for GRPO, and one-epoch PPO - #5079

Merged
terrykong merged 4 commits into
mainfrom
sc-ready-first-forced-ratio
Nov 7, 2026
Merged

terrykong merged 4 commits into
mainfrom
sc-ready-first-forced-ratio

Conversation

@snivertynv

@snivertynv snivertynv commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The ready_first sampler rejects force_on_policy_ratio=true unless 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 correction ready_first already requires handles. On the SingleController GRPO path, one RL step is exactly one optimizer step, and prev_logprobs are 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 ?

  • Allows force_on_policy_ratio=true with the ready_first sampler for GRPO. Previously this required use_cispo=true.
  • For PPO, requires ppo.ppo_epochs=1 whenever force_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.

  • GRPO on SingleController: each RL step is exactly one optimizer step, and prev_logprobs are recomputed by the trainer before that update. The ratio is always 1, so forcing it doesn't change the update. The weight-version mixing ready_first introduces is between generation and trainer weights, which the required importance-sampling correction already handles.
  • PPO: full-batch PPO runs ppo_epochs optimizer 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 with ready_first too.

Validation

Multi-node MoE GRPO, ready_first lag 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 with ready_first and a forced ratio is accepted.
  • test_ppo_setup.py: PPO with a forced ratio and ppo_epochs=4 is rejected under in_order and ready_first; with ppo_epochs=1 it is accepted with ready_first. Missing importance-sampling correction is still rejected.
  • test_ppo.py: legacy PPO setup rejects a forced ratio with ppo_epochs=4 before allocating resources.

@snivertynv snivertynv self-assigned this Nov 4, 2026
@snivertynv snivertynv added the CI:L1 Run doctests, unit tests, and functional tests label Nov 4, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 4, 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.

@snivertynv

Copy link
Copy Markdown
Contributor Author

/ok to test e438af7

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 4, 2026 15:05
@snivertynv snivertynv changed the title fix(sc): allow force_on_policy_ratio with the ready_first sampler for GRPO fix(sc): allow forced ratio with ready_first for GRPO Nov 4, 2026
@snivertynv

Copy link
Copy Markdown
Contributor Author

/ok to test 30022fe

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 4, 2026
@snivertynv snivertynv changed the title fix(sc): allow forced ratio with ready_first for GRPO fix(sc): allow forced ratio with ready_first for GRPO, and one-epoch PPO Nov 4, 2026
@snivertynv

Copy link
Copy Markdown
Contributor Author

/ok to test 84afc6e

@terrykong terrykong added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L1 Run doctests, unit tests, and functional tests labels Nov 5, 2026

@mehraakash mehraakash 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.

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

Comment thread docs/guides/single-controller.md Resolved
terrykong
terrykong previously approved these changes Nov 6, 2026
@terrykong
terrykong enabled auto-merge (squash) November 6, 2026 05:35
… 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]>
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]>
terrykong
terrykong previously approved these changes Nov 6, 2026
@terrykong

Copy link
Copy Markdown
Collaborator

/ok to test 623613e

@snivertynv

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed in cf044de:

  • Docs: took the suggested reorder, so the ready_first clauses stay together and the forced-ratio rule comes last.
  • Moved the forced-ratio epoch check below the streaming-PPO block, so a streaming config with the default ppo_epochs gets the streaming message first.
  • Parametrized the acceptance test over in_order and ready_first.
  • Pre-existing table: the streaming ready_first row now links grpo-llama3.1-8b-instruct-2n8g-ready-first-single-controller.yaml ("four of the five modes").
  • PR body: the logprob pass is skipped under a forced ratio and the loss reuses the training forward, and the epoch rule is scoped to SingleController plus synchronous legacy PPO, since async PPO already rejects a forced ratio.

@terrykong
terrykong disabled auto-merge November 6, 2026 15:14
@terrykong
terrykong enabled auto-merge (squash) November 6, 2026 15:46
@terrykong

Copy link
Copy Markdown
Collaborator

/ok to test cf044de

@snivertynv

Copy link
Copy Markdown
Contributor Author

/ok to test ba64159

@terrykong
terrykong merged commit cc2329e into main Nov 7, 2026
96 checks passed
@terrykong
terrykong deleted the sc-ready-first-forced-ratio branch November 7, 2026 09:18
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.

3 participants