Repository navigation
Log GRPO policy_loss at the optimizer-window scale for every loss type - #7042
Closed
behroozazarkhalili wants to merge 4 commits into
Closed
behroozazarkhalili wants to merge 4 commits into
behroozazarkhalili wants to merge 4 commits into
Conversation
…ss type The grpo, sapo, bnpo, dr_grpo and luspo branches capture policy_loss before dividing by the gradient accumulation normalizer, so the logged value is the optimizer-window loss. The cispo, dapo and vespo branch folds that normalizer into its token-count denominator before the capture, so its policy_loss was one micro-batch contribution, half the value of the other branches at gradient_accumulation_steps=2. The capture now multiplies back by the accumulation factor in train mode; the returned loss is unchanged. The regression test recomputes each of the three objectives and the entropy term from the model's own log probabilities and checks both the returned micro-batch loss and the logged policy_loss. On the previous code every row reports exactly half the expected value. Fixes #7011
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This was referenced Sep 4, 2026
Collaborator
Author
|
Closing this one myself. It came from reading the code, not from a failure in a real training run, and per the discussion on #6862 that isn't the bar for this repo. If someone hits this in practice, the branch is still here and I'm happy to reopen it with a reproduction. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GRPO logged
policy_lossat different scales depending on the loss type. I restored the optimizer window scale for CISPO, DAPO, and VESPO during training while leaving the returned loss unchanged. The regression tests independently compute the objective and check both values, failing on the base code and passing with the fix.Fixes #7011.
Note
Low Risk
Metrics-only adjustment with no change to the backward loss; limited to GRPO logging for three loss types plus a unit test.
Overview
Fixes inconsistent
policy_lossmetrics forcispo,dapo, andvespoinGRPOTrainer._compute_loss. Those branches folded gradient accumulation andsteps_per_generationinto the loss normalizer before recordingpolicy_loss, so logs reflected a single micro-batch contribution while other loss types logged the pre–gradient-accumulation (optimizer-window) scale.The change multiplies the detached
policy_lossbycurrent_gradient_accumulation_stepsin train mode (1.0 in eval) after that normalization. Returned loss and optimization are unchanged—only what gets appended to_metrics["train"]["policy_loss"]is rescaled.Adds
test_policy_loss_uses_optimizer_window_scale, parametrized over the three loss types, with hand-built inputs and explicit expectations for both_compute_lossoutput and the loggedpolicy_lossundergradient_accumulation_steps=2andsteps_per_generation=4.Reviewed by Cursor Bugbot for commit bd5fb1f. Bugbot is set up for automated code reviews on this repo. Configure here.