GRPO (Group Relative Policy Optimization) is a reinforcement learning method for training language models. For each prompt, the model samples a group of answers, a reward model scores each one, and policy gradient updates make higher-advantage trajectories more likely. GRPO estimates advantage from group statistics with no learned critic, cutting memory overhead compared with PPO.
DeepSeek introduced GRPO in DeepSeekMath and trained DeepSeek-R1 with it. It works with any reward model, typically a sparse outcome verifier, and DAPO is the variant that matters most in practice.
Where GRPO comes from
DeepSeek introduced GRPO in February 2024 in DeepSeekMath as "a variant of Proximal Policy Optimization (PPO), that enhances mathematical reasoning abilities while concurrently optimizing the memory usage of PPO." That run used a learned reward model and 64 outputs per question.
DeepSeek's DeepSeek-R1 paper, first posted in January 2025, reported training R1 and R1-Zero with GRPO. R1-Zero used rule-based accuracy and format rewards, keeping neural reward models out because they "are susceptible to reward hacking during large-scale reinforcement learning".
R1-Zero established a landmark result: a model can learn strong process-level reasoning strictly from outcome-level rewards. Our own post-training stack runs asynchronous GRPO on Miles.
How GRPO works
GRPO samples a group of completions per prompt, scores them with a reward model, and updates the policy toward higher-advantage trajectories. Each step repeats 5 stages:
- Sample a batch of prompts and generate G completions per prompt (64 in DeepSeekMath, 16 in R1-Zero).
- Score each completion with a reward model, whether a dense process-level scorer or a binary outcome verifier.
- Under outcome supervision, compute each completion's advantage as its reward minus the group mean, divided by the group standard deviation, and every token in the completion shares it. With process-level rewards, DeepSeekMath sets each token's advantage to the sum of the normalized step rewards from that token onward.
- Apply a clipped policy gradient that raises the probability of positive-advantage trajectories and lowers negative-advantage ones. Clipping removes the incentive to move a token's new-to-old probability ratio past 1 ± ε, which limits drift across multi-step or off-policy updates.
- Optionally add a KL penalty against a reference policy (0.04 in DeepSeekMath; 0.001 in R1-Zero, refreshing the reference every 400 steps). With the penalty on, a group whose rewards are all equal adds only the KL term's gradient.
The GRPO advantage formula
Under outcome supervision, the GRPO advantage is A_i = (r_i - mean(r)) / std(r), where r holds the rewards of a prompt's G completions. Python's standard library computes advantages for 2 groups of 8, adding eps to prevent dividing by 0:
import statistics def group_advantages(rewards, eps=1e-6): """GRPO's advantage: each reward minus the group's mean, divided by the group's standard deviation.""" mean = statistics.fmean(rewards) std = statistics.pstdev(rewards) return [round((r - mean) / (std + eps), 2) for r in rewards] # 8 answers to 1 prompt: 2 right (reward 1) and 6 wrong (reward 0)print(group_advantages([1, 1, 0, 0, 0, 0, 0, 0])) # 8 answers, all right: no spread, so every advantage is 0 and the prompt adds no gradientprint(group_advantages([1, 1, 1, 1, 1, 1, 1, 1]))
Running that script prints 2 lines of advantages:
[1.73, 1.73, -0.58, -0.58, -0.58, -0.58, -0.58, -0.58][0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
In the first group, 2 answers score 1 and 6 score 0 (mean 0.25, population standard deviation about 0.43), giving advantages of 1.73 and -0.58. Sample standard deviation shifts the scale while keeping sign and order identical.
In the second group, all 8 answers score 1 (the same holds if all 8 score 0), so every advantage is 0.0 and that prompt adds 0 policy gradient. DAPO's Dynamic Sampling exists specifically to filter out those uniform-reward groups.
Reward models and verifiers
GRPO always pairs the policy with a reward model. "Reward model" is the general term for whatever scores a trajectory; a verifier is a reward model returning a sparse binary reward on the final outcome, such as a passing test or exact match.
Rewards can also be dense and process-level, scoring intermediate steps along the trajectory. GRPO works with either kind. In practice, teams mostly use sparse outcome verifiers, and DeepSeek's R1-Zero result showed that outcome-level rewards alone can teach strong process-level behavior.
PPO vs GRPO vs DPO
PPO, GRPO, and DPO differ in online generation, memory footprint, and learning signal. PPO learns a critic to score tokens, GRPO normalizes rewards within a sampled group, and DPO optimizes directly over static preference pairs.
| PPO | GRPO | DPO | |
|---|---|---|---|
| What you supply | Prompts and a reward model (often from human rankings) | Prompts and a reward model (often a rule-based verifier) | Preferred and rejected answer pairs per prompt |
| Models in memory | Policy, learned critic, reward model, reference | Policy, reward model (if learned), reference (if KL is on) | Policy and reference |
| Generates online | Yes | Yes, a group per prompt | No, fixed dataset |
| Learning signal | Advantage from rewards and learned critic | Advantage from group mean and std | Classification loss on chosen vs rejected answer |
| Fits best | RLHF with a learned critic | Tasks with a reliable verifier or reward model | Existing preference pairs |
GRPO vs PPO
GRPO replaces PPO's learned critic with group statistics across sampled answers to the same prompt. PPO's critic predicts expected future reward per token. DeepSeekMath calls it "typically another model of comparable size as the policy model", which "brings a substantial memory and computational burden." GRPO uses the group's mean reward, the scored answer included, as its baseline.
The DeepSeek-R1 paper compared both on MATH using DeepSeek-Coder-V2-Lite. With GAE λ at 0.95 (the usual open-source default), PPO did considerably worse than GRPO, and at λ = 1.0 it came close. DeepSeek called GRPO "a more practical alternative, especially when training large-scale models with constrained resources."
GRPO vs DPO
GRPO generates and scores fresh completions online, while DPO trains offline on static preference pairs. Stanford researchers introduced DPO in 2023 with "only a simple classification loss" that raises preference for chosen over rejected answers relative to a reference, "eliminating the need for sampling from the LM during fine-tuning".
That can make offline DPO cheaper when clean preference pairs already exist; the policy learns from the supplied pairs, including any earlier errors they contain, without generating new answers during training. GRPO pays for online generation so the model adapts to live reward feedback.
DAPO: the GRPO variant that matters
DAPO (Decoupled Clip and Dynamic Sampling Policy Optimization) is the GRPO variant that matters in practice because it fixes vanilla GRPO's main failure modes. Many GRPO variants have appeared since DeepSeekMath, and most are close relatives with small normalization or clipping tweaks.
Introduced in March 2025 by researchers at ByteDance Seed, Tsinghua AIR and the University of Hong Kong, DAPO reached 50 points on AIME 2024 from the Qwen2.5-32B base model using open-source code built on verl. It drops the KL penalty and adds 4 techniques to base GRPO:
- Clip-Higher raises the upper clip bound so low-probability tokens can grow, keeping the policy's entropy from collapsing.
- Dynamic Sampling discards prompts whose completions all score the same (0 advantage, 0 gradient) and keeps sampling until batches have live variance.
- Token-Level Policy Gradient Loss averages the loss over all tokens together, so every token counts the same whatever the length of its completion. That drops the per-completion averaging that Understanding R1-Zero-Like Training showed favors shorter correct answers and longer wrong ones.
- Overlong Reward Shaping adjusts rewards for outputs near or at the length cap so truncated rollouts add less reward noise.
Does GRPO need reasoning traces?
GRPO needs no reasoning traces in the dataset because the model generates its own chain of thought during rollouts. With an outcome reward, every generated token inherits the completion's advantage, so reasoning that leads to above-average answers is reinforced. DeepSeek-R1-Zero's rule-based rewards checked final answers and designated reasoning tags.
SFT on target answers without the model's chain of thought can collapse reasoning quality, whereas RL trains on the model's own trajectories, chain of thought included. SFT vs RL covers when to choose each method.
Training an agent with GRPO
Training an agent with GRPO requires a closed-loop environment paired with a reward model, where the agent's actions change the next state. SFT trains open loop on expert data and suffers from exposure bias at deployment, while closed-loop RL forces the model to recover from its own errors.
Building environments that imitate the real world is the hardest part of agent RL. Harbor is the emerging standard for RL environments and agent evaluation, and it is what we build on. We build environments from agent traces, and our platform imports Harbor task collections from Git or an archive.
How we train with GRPO on Miles
We run all RL training on Miles, an Apache-2.0 framework from RadixArk forked from and co-evolving with slime. Miles pairs SGLang rollouts with Megatron-LM training (plus FSDP2 and torchtitan backends) across decoupled, asynchronous workers with configurable on-policy and off-policy schedules. Any Miles-trained model serves on SGLang or vLLM.
In RL, roughly half the GPUs run inference for rollouts and half run training, whereas SFT puts every GPU on training. That split is why RL usually needs more compute.
Our early-access Training API follows that split directly, running Qwen3.5 9B with asynchronous GRPO, LoRA rank 128, and 64K context on 2 H100s: 1 trainer and 1 sampler. Each collection gathers 256 trajectories (8 rollouts per task group) and updates in mini-batches of 32.
Miles also supports end-to-end MXFP8 and NVFP4 RL on Blackwell GPUs (B200 and B300), which beat Hopper on compute and low-precision efficiency. To try Miles, see the Miles quick start, which needs an 8-GPU node.
Troubleshooting a GRPO run
Stalled GRPO runs usually trace back to 5 issues across reward spread, reward hacking, length caps, entropy, or rollout speed. Match the symptom to the cause and fix:
| What you see | Likely cause | What to change |
|---|---|---|
| Reward stays flat early | Uniform group rewards yield 0 advantage and 0 gradient | Check mixed-outcome rate first, enable dynamic sampling, or run SFT warm-up |
| Reward rises, held-out accuracy stalls | Policy games the reward model or overfits prompts | Inspect top completions, patch verifier loopholes, and track held-out eval |
| More completions hit length cap | Cap is too short, or per-completion averaging favors longer wrong answers | Use token-level loss, add overlong reward shaping, or raise the cap |
| Group completions look identical | Policy entropy collapsed, or the upper clip bound is too tight | Check sampling temperature and entropy, and raise the upper clip bound (Clip-Higher) |
| Each step runs slowly | Rollouts dominate step time, or workers block each other | Decouple rollout and training GPUs asynchronously (such as Miles on SGLang), or tune group size and cap |
When GRPO is the wrong choice
Skip GRPO without a trustworthy reward model, rollout variance, or the needed task knowledge. In these 3 cases, choose another approach:
- You have no reliable, affordable reward model. Every completion gets scored, so a noisy or expensive judge degrades updates and cost. Test rewards on good answers, bad answers, and shortcuts first; with only preference pairs, start with DPO or train a reward model.
- Answers in each group get identical scores. With a binary verifier, a group gives 0 advantage when every completion passes or every completion fails, which happens most on prompts the model almost always passes or fails. Sample first to count mixed outcomes; if nearly all fail, run SFT warm-up, use a stronger base model, or add dense partial credit.
- Failures come from missing or outdated facts. Start with retrieval before training weights: RAG vs fine-tuning covers that tradeoff.
How we used GRPO
We used GRPO in our August 2026 claims research study, where an agent searches a claim's evidence store, decides whether it has enough context, and returns 1 of 4 verdicts. We trained Qwen3.5-4B with GRPO and a LoRA adapter for exact-match verdict accuracy on complete search-and-reasoning trajectories.
Training on complete trajectories preserved the model's sampled sequence and kept longer episodes from getting extra weight for extra turns. On 489 held-out claims, the trained model scored 71.1% at $1.75 per 1,000 claims, raising accuracy from 57% to 71% on this benchmark.
On 500 held-out AVeriTeC development claims, it beat Claude Haiku 4.5 by 10.9% relative verdict accuracy (paired confidence interval +4.5% to +17.3%) in a controlled benchmark experiment. It used 44% fewer searches and ran 9.4 times faster at 90% lower cost.
Fine-tuning on Experiential
Experiential fine-tunes open small language models as a managed engagement, starting with 1 workload. Turn on prompt and response logging, and we simulate your production environment from agent traces, train an open model with RL, and deploy it under a new model name on the same API.
You always start each run yourself, and the weights are yours to download and self-host at any time. Book a call on the fine-tuning page to start.
Questions answered
What is GRPO?
GRPO (Group Relative Policy Optimization) is a reinforcement learning algorithm for language models that DeepSeek introduced in 2024 in its DeepSeekMath paper. For each prompt, the model samples a group of completions, a reward model scores each one, and policy gradient updates increase the probability of trajectories with higher group-relative advantage. GRPO estimates advantage from group statistics with no learned critic, avoiding the memory overhead of PPO's separate critic network.
What is the GRPO formula?
Under outcome supervision, each completion's advantage is its reward minus the group mean, divided by the group standard deviation: A_i = (r_i - mean(r)) / std(r), and implementations add a small constant to the denominator to prevent division by 0. In simplified notation, DeepSeekMath's objective is J = (1/G) Σ_i (1/|o_i|) Σ_t [min(ρ_i,t · A_i, clip(ρ_i,t, 1 - ε, 1 + ε) · A_i) - β · KL_i,t], where ε is the clip range, ρ_i,t is the ratio of a token's new probability to its rollout probability and KL_i,t penalizes drift from a reference policy. Base GRPO averages token losses inside each completion; DAPO averages over all tokens together, which removes that per-completion length bias.
What is the difference between PPO and GRPO?
PPO learns a separate critic model to estimate expected future reward from each token onward, whereas GRPO estimates advantage directly from the rewards of a group of completions sampled for the same prompt. In typical LLM setups, PPO's critic is another network comparable in size to the policy. Dropping that learned critic cuts memory and training overhead, shifting compute toward generating multiple rollouts per prompt.
What is the difference between DPO and GRPO?
DPO trains offline on a fixed dataset of preferred and rejected answer pairs with a classification loss and generates nothing during fine-tuning (online and iterative DPO variants refresh the pairs with the model's own answers). GRPO generates new completions online during training and scores every trajectory with a reward model. DPO fits teams that already have clean preference pairs, and GRPO fits tasks with a reliable reward model or verifier.
Does GRPO need a reward model?
Yes, GRPO always requires a reward model to score each sampled completion in the group. That reward model can be a neural network giving dense process-level scores, or a rule-based verifier returning a binary outcome reward such as a passing unit test or exact math check. GRPO works with either. In practice most teams use sparse outcome verifiers, and DeepSeek showed that models can learn strong process-level reasoning from outcome supervision alone.
What is DAPO?
DAPO (Decoupled Clip and Dynamic Sampling Policy Optimization) is the GRPO variant from ByteDance Seed, Tsinghua AIR and the University of Hong Kong that matters most in practice. It drops the KL penalty and adds 4 techniques to base GRPO: Clip-Higher, Dynamic Sampling, Token-Level Policy Gradient Loss, and Overlong Reward Shaping. Its authors reached 50 points on AIME 2024 starting from the Qwen2.5-32B base model.
Which framework should I use for GRPO?
We use and recommend Miles, an Apache-2.0 post-training framework from RadixArk that pairs SGLang rollouts with Megatron-LM, FSDP2, or torchtitan training backends. Other open options teams use in production include verl and NeMo-RL. Models trained in Miles export standard weights that you can serve afterward on either SGLang or vLLM.
