Group Relative Policy Optimization (GRPO): Mathematical Foundations, Group Baseline Advantage, Critic-Free Policy Gradients, and Reasoning Scaling

Reinforcement learning from human feedback (RLHF) and reinforcement learning with verifiable rewards (RLVR) have become central to post-training large language models. For years, the default policy optimization algorithm in LLM alignment was Proximal Policy Optimization (PPO). While PPO offers stable policy updates through clipped surrogate objectives and Generalized Advantage Estimation (GAE), it introduces severe computational and architectural overhead when scaled to hundred-billion-parameter

7 min
Group Relative Policy Optimization (GRPO): Mathematical Foundations, Group Baseline Advantage, Critic-Free Policy Gradients, and Reasoning Scaling

Reinforcement learning from human feedback (RLHF) and reinforcement learning with verifiable rewards (RLVR) have become central to post-training large language models. For years, the default policy optimization algorithm in LLM alignment was Proximal Policy Optimization (PPO). While PPO offers stable policy updates through clipped surrogate objectives and Generalized Advantage Estimation (GAE), it introduces severe computational and architectural overhead when scaled to hundred-billion-parameter foundation models.

Group Relative Policy Optimization (GRPO), introduced by Shao et al. in the DeepSeekMath framework and subsequently deployed to train DeepSeek-R1-Zero and DeepSeek-R1, modifies the actor-critic paradigm. By eliminating the separate critic (value) model and replacing token-level value estimation with a group-relative baseline computed across multiple candidate rollouts, GRPO reduces GPU memory footprints while stabilizing reinforcement learning for mathematical and logical reasoning tasks.

GRPO Architectural Schematic

The Value Network Bottleneck in Standard PPO

In standard PPO applied to autoregressive language models, training typically requires four separate neural networks to reside in memory or coordinate across distributed ranks:

  • Policy Model (Actor, πθ\pi_\theta): The active language model being trained.
  • Reference Model (πref\pi_{ref}): A frozen copy of the supervised fine-tuned (SFT) model used to compute Kullback-Leibler (KL) divergence penalties.
  • Reward Model (rϕr_\phi): A model (or programmatic scoring function) that evaluates the quality of completions.
  • Value Model (Critic, VψV_\psi): A network, typically of identical parameter scale to the actor, initialized from the reward model and trained to predict the expected cumulative reward from each intermediate token state st=(q,o<t)s_t = (q, o_{<t}).

Maintaining a value network matching the size of a 70-billion or 671-billion parameter actor creates major engineering friction. First, the critic doubles the active parameter count that requires optimizer states (such as AdamW first and second moments), forward passes, and backward gradient computation. Second, predicting token-level value functions in generative language tasks is notoriously unstable: value prediction error frequently diverges during long chain-of-thought generations, propagating noisy advantage estimates through Generalized Advantage Estimation.

Mathematical Formulation of GRPO

GRPO resolves the critic bottleneck by removing the value network VψV_\psi entirely. Instead of learning a parametric state-value estimator, GRPO estimates the baseline dynamically from a group of sampled responses to the same input query.

1. Group Sampling and Reward Assignment

For each prompt qq drawn from the training distribution P(Q)P(Q), GRPO samples a group of GG distinct completions {o1,o2,,oG}\{o_1, o_2, \dots, o_G\} from the previous policy πθold\pi_{\theta_{old}}.

Each completion oio_i is evaluated by a scoring function to produce a scalar reward rir_i. This reward can be generated by neural preference models, deterministic rule-based verifiers, or a weighted combination of both:

ri=rverifiable(q,oi)+αrformat(q,oi)r_i = r_{verifiable}(q, o_i) + \alpha r_{format}(q, o_i)

2. Group-Normalized Advantage Estimation

Rather than computing token-wise temporal difference errors δt=rt+γV(st+1)V(st)\delta_t = r_t + \gamma V(s_{t+1}) - V(s_t), GRPO computes a single advantage A^i\hat{A}_i for each response oio_i by standardizing the rewards across the group of GG candidates:

A^i=rimean({r1,r2,,rG})std({r1,r2,,rG})+ϵ\hat{A}_i = \frac{r_i - \text{mean}(\{r_1, r_2, \dots, r_G\})}{\text{std}(\{r_1, r_2, \dots, r_G\}) + \epsilon}

Where:

  • mean({r1,,rG})=1Gj=1Grj\text{mean}(\{r_1, \dots, r_G\}) = \frac{1}{G} \sum_{j=1}^G r_j acts as an empirical estimate of the expected reward V(q)V(q) for prompt qq.
  • $\text{std}(\{r_1, \dots, r_G\}) = \sqrt{\frac{1}{G} \sum_{j=1}^G (r_j - \text{mean}(\mathbf{r}))^2}$ normalizes the advantage scale across easy and difficult prompts.
  • ϵ\epsilon is a small numerical constant (typically 10410^{-4} or 10810^{-8}) preventing division by zero when all outputs receive identical rewards.

Every token in completion oio_i is assigned the sequence-level advantage A^i,t=A^i\hat{A}_{i,t} = \hat{A}_i. This formulation directly reflects relative performance: completions scoring above the group average receive positive advantages (A^i>0\hat{A}_i > 0), reinforcing their token probabilities, while completions performing below the group average receive negative advantages (A^i<0\hat{A}_i < 0), suppressing their trajectories.

3. Clipped Surrogate Objective

The policy parameters θ\theta are optimized by maximizing the GRPO surrogate objective:

JGRPO(θ)=EqP(Q),{oi}i=1Gπθold(Oq)[1Gi=1G1oit=1oi(min(ρi,tA^i,  clip(ρi,t,1ε,1+ε)A^i)βDKL(πθπref))]\mathcal{J}_{GRPO}(\theta) = \mathbb{E}_{q \sim P(Q), \{o_i\}_{i=1}^G \sim \pi_{\theta_{old}}(O|q)} \left[ \frac{1}{G} \sum_{i=1}^G \frac{1}{|o_i|} \sum_{t=1}^{|o_i|} \left( \min \left( \rho_{i,t} \hat{A}_i, \; \text{clip}(\rho_{i,t}, 1-\varepsilon, 1+\varepsilon) \hat{A}_i \right) - \beta D_{KL}(\pi_\theta || \pi_{ref}) \right) \right]

Where:

  • $\rho_{i,t} = \frac{\pi_\theta(o_{i,t} \mid q, o_{i,<t})}{\pi_{\theta_{old}}(o_{i,t} \mid q, o_{i,<t})}$ represents the importance sampling probability ratio between the current policy and the rollout policy.
  • ε\varepsilon is the PPO clipping parameter (typically set to 0.1 or 0.2), bounding the update to prevent destructive policy shifts.
  • β\beta is the regularization coefficient controlling drift from the reference model.
  • oi|o_i| is the sequence length of completion oio_i, ensuring that long generations do not disproportionately dominate gradient updates relative to concise outputs.

4. Unbiased Analytical KL Divergence Approximation

In conventional RLHF implementations, the KL divergence penalty is often subtracted directly from token rewards inside the rollout phase. In GRPO, the KL divergence is integrated directly into the objective function. To calculate this penalty stably without introducing high sample variance, DeepSeekMath employs the non-negative unbiased estimator described by John Schulman:

DKL(πθπref)=πref(oi,tq,oi,<t)πθ(oi,tq,oi,<t)logπref(oi,tq,oi,<t)πθ(oi,tq,oi,<t)1D_{KL}(\pi_\theta || \pi_{ref}) = \frac{\pi_{ref}(o_{i,t} \mid q, o_{i,<t})}{\pi_\theta(o_{i,t} \mid q, o_{i,<t})} - \log \frac{\pi_{ref}(o_{i,t} \mid q, o_{i,<t})}{\pi_\theta(o_{i,t} \mid q, o_{i,<t})} - 1

Setting k=πrefπθk = \frac{\pi_{ref}}{\pi_\theta}, the function f(k)=klog(k)1f(k) = k - \log(k) - 1 satisfies f(1)=0f(1) = 0 and f(k)>0f(k) > 0 for all k1k \neq 1. This property guarantees that the penalty term is strictly positive whenever the active policy drifts from the reference policy, eliminating negative KL artifacts caused by finite-sample log-ratio approximations.

Verifiable Rule-Based Rewards and Reasoning Scaling

A critical property of GRPO is its synergy with rule-based reward systems in formal domains like mathematics, formal logic, and software engineering.

In traditional open-ended generation tasks, reward models must evaluate nuanced human preferences, which leaves them vulnerable to reward hacking (adversarial exploitation of reward model blind spots). In contrast, reasoning domains allow deterministic verification:

  • Accuracy Rewards: Binary scoring (1.0 for correct final answer, 0.0 for incorrect) extracted via regex parsers or validated with symbolic math engines (such as SymPy) and unit-test execution harnesses.
  • Format Rewards: Structural enforcement requiring the model to enclose its intermediate scratchpad within explicit markers, such as <think> and </think> tags, penalizing outputs that fail structural syntax constraints.

Emergence of Extended Reasoning Trajectories

When large models are trained via GRPO on verifiable tasks without intermediate supervised step-by-step demonstrations (as demonstrated in DeepSeek-R1-Zero), policy gradients driven by group-relative advantages induce emergent behaviors:

  1. Autonomous Search Exploration: When faced with difficult problems, rollouts that generate exploratory reasoning paths eventually stumble upon correct solutions. Standardizing within the group assigns high positive advantages to these successful reasoning paths and negative advantages to incorrect short answers.
  2. Self-Reflection and Error Correction: The model learns to generate reflective pivot phrases (such as "Wait, let me recalculate that" or "This leads to a contradiction, let us try an alternative substitution") without human demonstration data.
  3. Dynamic Thinking Budgets: Generation lengths naturally expand as the policy allocates more computation to difficult prompts, effectively discovering test-time compute scaling through reinforcement learning exploration.

PPO vs. GRPO: Architectural and Computational Comparison

The structural differences between PPO and GRPO translate directly to training throughput and infrastructure requirements:

  • Memory Footprint: PPO requires memory for Actor weights, Critic weights, Actor optimizer states, Critic optimizer states, Reference model weights, and Reward model weights. GRPO requires memory only for Actor weights, Actor optimizer states, Reference model weights, and (optionally) Reward model weights. Eliminating the critic removes roughly 40% to 50% of the active VRAM allocated to trainable parameters and optimizer states.
  • Baseline Estimation: PPO relies on a learned parametric neural value network Vψ(st)V_\psi(s_t), which suffers from value function approximation error and non-stationary targets. GRPO uses a non-parametric empirical mean 1Grj\frac{1}{G} \sum r_j across GG sampled completions for the prompt.
  • Advantage Computation: PPO uses Generalized Advantage Estimation (GAE) across temporal tokens with discount factor γ\gamma and smoothing parameter λ\lambda. GRPO applies sequence-level reward standardization riμσ+ϵ\frac{r_i - \mu}{\sigma + \epsilon} across the sampled group.
  • Sample Efficiency vs. Group Size: GRPO requires generating multiple completions per prompt (G4G \ge 4, with G=16G=16 to G=64G=64 common in practice). While generating GG completions increases forward-pass rollout computation, generation can be executed with highly optimized inference engines (e.g., vLLM or SGLang) with KV caching, while the heavy backpropagation pass operates over a streamlined single-model graph.

Engineering Considerations and Limitations

Deploying GRPO in production pipelines involves specific algorithmic trade-offs:

  • Reward Variance in Small Groups: If the group size GG is too small (e.g., G=2G=2), the sample variance of the group standard deviation is high, leading to unstable advantage estimates. If all GG completions for a query fail or all succeed with identical scores, the numerator (riμr_i - \mu) becomes zero, yielding zero gradient updates for that prompt.
  • Credit Assignment Granularity: Assigning a sequence-level advantage uniformly to all tokens in oio_i provides coarse credit assignment compared to fine-grained process-based reward models (PRMs). However, empirical results indicate that across sufficiently large training batches, policy gradient updates aggregate over token distributions to guide search behavior effectively.
  • Length Normalization: Dividing token losses by sequence length oi|o_i| prevents gradient magnitude distortion across variable-length completions, preventing the optimization objective from favoring degenerate, repetitive output loops.

Group Relative Policy Optimization demonstrates that scaling reinforcement learning for reasoning does not require complex actor-critic infrastructure. By combining group-level baseline normalization with deterministic verifiers, GRPO provides a stable, memory-efficient framework for post-training LLM reasoning engines.

Sources

Written by

More to read

  • OpenAI Unveils Jalapeño Custom Inference Chip Benchmarks at Hot Chips 37

    OpenAI presented the first architecture and benchmark disclosures for its custom inference chip, code-named Jalapeño, during the 37th Hot Chips conference. In published test data and technical disclosures, OpenAI reported that Jalapeño achieves 1.5x to 1.9x higher performance per watt and 1.7x to 3.6x lower end-to-end latency compared to Nvidia Blackwell GB200 and GB300 systems on production LLM workloads. Developed in co-design partnership with Broadcom, Jalapeño represents OpenAI's initial ha

    1 min
  • Nvidia Agrees to Acquire Hugging Face for 2.9 Billion

    Nvidia has agreed to acquire Hugging Face for $12.9 billion, according to reporting from The Information. Parallel reports from Business Insider, Bloomberg, and Reuters confirm that the companies engaged in advanced acquisition negotiations valuing the open-source artificial intelligence hub between $12.9 billion and $13 billion. The transaction marks the largest software and developer platform acquisition in Nvidia's history, placing the primary distribution nexus for open-weight foundation mo

    1 min
  • GraphRAG Frameworks and Architectures in Production: Comparing Microsoft GraphRAG, LightRAG, Neo4j GenAI, and Kùzu

    Standard dense retrieval-augmented generation (RAG) relies on vector embeddings to retrieve top-k chunks based on cosine similarity. While effective for point-lookup queries against localized text segments, dense vector search breaks down under two common production workloads: multi-hop relational reasoning across disconnected documents and global corpus-wide summarization. When answering questions that require traversing relationship paths across disparate data points, or synthesizing broad th

    1 min