PR #5080 · related:
#4171 (the same flag for the regular trainer),
#5079 (ready_first + forced ratio)
· permalinks pinned to 8cb3b94a
loss_fn.seq_logprob_error_in_loss: true at startup, so it always ran a separate policy-logprob forward just to find the bad rows.grpo.seq_logprob_error_threshold). Rejected rows get no gradient. The baseline is the group's average reward that each row's reward is compared with. Dotted words have a short explanation: hover or tap them.With the flag off, SingleController runs a separate forward pass to get the trainer's logprobs, finds the rejected rows, and zeroes them in sample_mask before computing advantages
(advantage_stage.py).
With the flag on, logprob_passes_required turns that pass off.
The loss makes the same check from the training forward it already runs, zeroes the rejected rows, and reports how many tokens it kept
(loss_functions.py).
The Megatron worker adds those counts up over all chunks and all DP ranks, then divides the gradient by them
(_finish_train_step_body).
One group of 4 rows with 6, 5, 7 and 8 answer tokens (26 total). Row 1's sequence error is 2.9, over the 2.0 threshold.
The two lanes end at the same gradient, S / 21: the sum over kept tokens divided by the number of kept tokens. That is the same result as dropping row 1 before training
(why, for the regular trainer).
They differ in one place. Under masked_reward_policy: exclude, row 1 still counts in the group average when the flag is on, because the baseline is set before the loss sees the row. The regular trainer does the same thing with the flag on, so the PR keeps the two trainers in step.
validate_single_controller_config rejects the flag for PPO and for
forest training, then reuses the regular trainer's checks (threshold set, token-level loss, no MTP, draft, KL-in-reward, or distillation).
With the flag on, the controller's own seq-error range metrics are gone; the count of rejected rows comes from the loss as num_masked_seqs_by_logprob_error, as in the regular trainer.
Review comments: C2 · exclude sentence — grpo.md:695 C4 · shared survivor-count helper — megatron_policy_worker.py:2333 C5 · one "skip the extra forward?" rule — config.py:1009 C6 · error on an unlisted metric — loss/utils.py:44
ready_first with a forced ratio, which this branch alone still rejects unless CISPO is on; #5079 lifts that.