TL;DR
This paper uncovers a hidden but critical design flaw in how Group Relative Policy Optimization (GRPO) aggregates token-level losses during reinforcement learning. By introducing Balanced Aggregation (BA)—which separates positive and negative responses before averaging tokens—the authors eliminate optimization biases that cause late-stage training collapse, consistently boosting performance and stability across major reasoning and coding benchmarks.
What Problem Does This Paper Address?
Reinforcement Learning with Verifiable Rewards (RLVR) is the powerhouse behind modern reasoning models like DeepSeek-R1. GRPO is widely used in this paradigm because it eliminates the need for a separate critic model by comparing a group of outputs generated from the same prompt to compute relative advantages. However, a subtle mathematical choice has been flying under the radar: how do we aggregate token-level losses into a single group loss?
The paper highlights that the two standard approaches are fundamentally biased:
- Sequence Aggregation (Standard GRPO): Averages tokens within each response first, then averages across responses. This treats every response equally, meaning a single token in a short response carries way more weight than a token in a long response, implicitly penalizing longer, detailed reasoning.
- Token Aggregation: Directly averages across all tokens in the group. While it fixes the length penalty, it introduces sign-length coupling. If incorrect (negative advantage) answers happen to be systematically longer than correct (positive advantage) ones, token aggregation accidentally overweights the negative gradients, causing severe training instability or performance collapse in later stages.
Methods
To resolve this tension, the authors propose Balanced Aggregation (BA), a simple drop-in replacement for the loss calculation step in GRPO-style algorithms.
Instead of averaging everything together blindly, BA performs the following steps:
- Partitions the generated responses within a group into two subsets based on the sign of their normalized advantages: a positive subset ($S_+$) and a negative subset ($S_-$).
- Computes the token-level mean loss separately within each subset. This preserves the benefits of token-level averaging within each category (removing the unfair penalty for longer sequences within the same sign group).
- Recombines the two subset losses using weights proportional to the sequence count of each subset ($k/G$ and $(G-k)/G$).
This mathematical formulation ensures that the overall balance between positive and negative updates remains stable, completely decoupling response length from the gradient sign balance. The authors also provide an extension for non-binary rewards in the appendix.
Datasets
- Training Data:
- DAPO-17k: Approximately 17,000 mathematical reasoning problems.
- Polaris: A larger dataset containing roughly 53,000 mathematical problems.
- Evaluation Benchmarks:
- The models were evaluated across six challenging reasoning and coding benchmarks: Math-500, AIME-2024, AIME-2025, OlympicBench, Minerva-MATH, and LiveCodeBench.
Key Insights and Ideas
- Aggregation is not a benign implementation detail: Small choices in how code loops average tokens vs. sequences radically alter the optimization landscape and can be the difference between steady improvement and total model collapse.
- The "Model-Dependent Flip": The authors explain why previous literature disagreed on whether token or sequence aggregation was better. Token aggregation shines when response-length variance is high but the positive-negative length gap is small (e.g., Qwen2.5-Math-7B). Sequence aggregation is safer when response-length variance is small but the positive-negative length gap is large (e.g., Qwen3-1.7B).
- Decoupling Sign and Length: Balanced Aggregation acts as a bridge, capturing the best of both worlds—retaining token-level granularity without letting longer bad answers swamp the gradient signal.
Key Results
- Stability and Robustness: While token aggregation often achieves high "peak" accuracy early on, it frequently suffers from severe performance degradation or collapse in later training steps. BA eliminates this drop, maintaining robust last-step accuracy.
- Quantitative Gains: On DAPO-17k with Qwen2.5-Math-7B, BA achieved the highest peak accuracy (0.3634) and maintained a strong last-step accuracy (0.3424) compared to token aggregation (which dropped to 0.3364).
As visualized across the benchmarks, BA consistently bridges the gap between peak performance and final training step stability:
Limitations and Future Work
- Scope of Tasks: The current evaluation focuses primarily on mathematical reasoning and coding tasks where rewards are strictly verifiable (binary or clear unit tests). How these aggregation biases manifest in more subjective RLHF settings (like helpfulness and harmlessness) remains an open question.
- Group Size Scaling: The paper primarily explores a standard group size of $G=16$. Exploring how these biases scale with much larger group sizes (e.g., $G=64$ or $G=128$) could yield further insights into RLVR scaling laws.
Summary updated