fix bug of GRPO default setting #113
Open
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.
Fix Double Normalization Bug in GRPO Training
Summary
This PR fixes a critical bug in the GRPO training script where advantage values were being normalized twice at different granularities, leading to biased gradient estimates and potentially degraded training performance.
Problem Description
Issue 1: Double Normalization
The training pipeline performs normalization twice:
First normalization (Actor-side, Episode-level) - Line 692-696:
critic_type2="grpo":(reward - group_mean) / group_stdcritic_type2="drgrpo":(reward - group_mean)critic_type2="rloo": Uses leave-one-out mean subtractionSecond normalization (Learner-side, Transition-level) - Line 1005-1018:
norm_return=True, normalizes again using global statistics across all transitions(advantages - global_mean) / global_stdThis double normalization is redundant and mathematically incorrect.
Issue 2: Subsampling Between Normalizations
Between the two normalizations, there is a random subsampling step (Line 233-240):
Problem: The second normalization operates on a biased subset of the originally normalized data:
Issue 3: Granularity Mismatch
The two normalizations operate at different granularities:
First normalization: Episode-level
group_rewards = [4.0, 2.0]→normalized = [+1.0, -1.0]Second normalization: Transition/Step-level
Consequence: Longer episodes become over-represented in the second normalization, biasing the mean and standard deviation toward these episodes and breaking the episode-level comparison that GRPO/RLOO/Dr.GRPO rely on.
Root Cause
The
norm_return=Truedefault was incorrectly applied from standard PPO settings. However, in the GRPO/Dr.GRPO/RLOO setting:norm_returnlogicSolution
Set
norm_return=Falseby default (Line 114) to disable the second normalization in the learner.Changes
examples/train_oat/train_oat_grpo.pynorm_return: bool = True→norm_return: bool = False