Skip to content

Turn off Dr GRPO reward scaling under TRL's "group" default - #11951

Merged
danielhanchen merged 2 commits into
unslothai:mainfrom
vineethsaivs:fix/dr-grpo-group-scale-rewards
Sep 27, 2026
Merged

danielhanchen merged 2 commits into
unslothai:mainfrom
vineethsaivs:fix/dr-grpo-group-scale-rewards

Conversation

@vineethsaivs

Copy link
Copy Markdown
Contributor

GRPOConfig(loss_type="dr_grpo") still divides advantages by the per-group reward std, which is the step Dr GRPO removes.

Unsloth's generated config overrides scale_rewards to False for dr_grpo, but only when it equals True. Since TRL 0.22 the default is "group", which TRL documents as the same setting as True, so the override never fires on the default. Passing True gives 'none' while the identical "group" gives 'group'.

The fix matches "group" as well. An explicit "batch" is left alone, and the hint now says None keeps scaling, which is what that branch does.

Before, on main with TRL 1.9.2: default gives 'group'. After: 'none'.

Added a case to tests/version_compat/test_trl_loss_normalization_contract.py: that file goes from 1 failed, 11 passed before the fix to 12 passed after. test_trl_grpo_fake_run.py and test_rl_config_compat.py: 35 passed, 1 skipped. Pinned ruff is clean.

The dr_grpo check only overrode scale_rewards == True. TRL 0.22 made
"group" the default and documents it as the same setting as True, so a
plain GRPOConfig(loss_type="dr_grpo") kept dividing advantages by the
per-group std. Match "group" too, and fix the hint: None keeps scaling.
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed that main in unsloth/models/rl.py only overrides scale_rewards when it is True, so the default "group" leaves Dr GRPO still dividing by the reward std. Will get this reviewed.

@danielhanchen danielhanchen self-assigned this Sep 26, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member

Review record for #11951, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#123.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 40236652ff (this PR's 9111523bd)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 40236652ff

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 40236652ff (this PR's 9111523bd).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit c0b27d2 into unslothai:main Sep 27, 2026
24 of 31 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…i#11951)

* Turn off Dr GRPO reward scaling under TRL's "group" default

The dr_grpo check only overrode scale_rewards == True. TRL 0.22 made
"group" the default and documents it as the same setting as True, so a
plain GRPOConfig(loss_type="dr_grpo") kept dividing advantages by the
per-group std. Match "group" too, and fix the hint: None keeps scaling.

* Trim Dr GRPO comments and drop unreachable scale_rewards skip

---------

Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants