Repository navigation
fix(grpo): use rank-penalized rewards in the advantage numerator - #646
Open
David-Wu1119 wants to merge 1 commit into
Open
David-Wu1119 wants to merge 1 commit into
David-Wu1119 wants to merge 1 commit into
Conversation
With `rank_penalty` set, GRPOGroupedAdvantage rescales each reward by its likelihood rank (the unlikeliness reward of arXiv:2506.02355) and computes the group mean and std from the rescaled rewards, but the advantage itself was still computed from the raw `exp.reward`. With binary rewards every correct response then received the same advantage regardless of its rank, so the option shifted the baseline but never favoured unlikely correct responses, which is its whole purpose. Compute the advantage from the same (possibly rank-penalized) rewards that the group statistics use. Behaviour without `rank_penalty` is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
This branch has not been deployed
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.
Description
Bug.
GRPOGroupedAdvantagewithrank_penaltyset (advantage_fn_args: {rank_penalty: ...}) applies the unlikeliness reward of arXiv:2506.02355 (Sec. 4.1): each reward is rescaled by1 - rank_penalty * rank / G, where higher-likelihood responses get larger ranks. The group mean and std are computed from the rescaled rewards, but the advantage was still computed from the rawexp.reward:With binary rewards, every correct response in a group therefore gets the same advantage whatever its rank. The option only shifts the baseline and never favours the less likely correct responses, which is what the paper's modified reward
r_iis for (the advantage is computed fromr_i).Reproduce. One group, rewards
[1, 1, 0, 0], mean log-probs[-0.1, -2.0, -0.5, -1.0],rank_penalty=0.25: onmainboth correct responses get the same advantage; the unlikely one (-2.0) should get the larger one.Fix. Compute the advantage from the same (possibly rank-penalized) rewards the group statistics use. Without
rank_penaltythe result is unchanged.Tests. New
tests/algorithm/advantage_fn_test.py::TestGroupedAdvantageFn::test_grpo_rank_penalty_advantages_use_adjusted_rewardschecks the advantages against(r_i - mean(r)) / (std(r) + eps)on the adjusted rewards. It fails onmainand passes with this change.tests/algorithmandtests/common/rewardspass (108 tests, CPU).pre-commitpasses on the changed files. No GPU or model-weight tests were run.Checklist
Please check the following items before code is ready to be reviewed.
tests/algorithmandtests/common/rewardswere run; GPU and Ray tests were not)🤖 Generated with Claude Code