How GRPO Actually Updates a Model
Most explanations of GRPO open with a wall of expectations, importance ratios and clipping brackets. This one opens with 10 + 1 = and a model that can only answer 11, 12 or 10, and computes every gradient, clip and weigh
Most explanations of GRPO open with a wall of expectations, importance ratios and clipping brackets. This one opens with 10 + 1 = and a model that can only answer 11, 12 or 10, and computes every gradient, clip and weight update by hand.
We will start with the numbers inside a real model, work out what "training" means for those numbers, and then run the same prompt through REINFORCE, PPO, GRPO, DPO and finally DAPO. Every number is computed in the open, so you can check each step with a calculator.
You might be wondering: why DPO, in an article about GRPO?
GRPO and DPO are the two most common ways to teach a model what "better" means after pre-training. GRPO learns online: the model writes answers during training, and each one gets a score. DPO learns offline: from a fixed list of "this answer was preferred over that one", with no scoring and no new answers during training. Running both on the same prompt makes the difference concrete.
Settings and results taken from papers are cited where they appear. Every other number is worked out here.
Part 1: What is a model, really?
1.1 The weights
Let's start from the bottom. An open model is two things: a file of numbers, called weights, and the code that does arithmetic with them.
Qwen2.5-1.5B-Instruct, for example, has 1,543,714,304 weights in a single 3.09 GB file. They are grouped into 338 named matrices:
| Matrix | Shape |
|---|---|
model.embed_tokens.weight |
151,936 Γ 1,536 (one row per vocabulary token) |
model.layers.0.self_attn.q_proj.weight |
1,536 Γ 1,536 |
model.layers.0.self_attn.k_proj.weight |
256 Γ 1,536 |
model.layers.0.mlp.gate_proj.weight |
8,960 Γ 1,536 |
28 layers like this; the output layer reuses embed_tokens
|
What does one of these weights mean?
On its own, nothing you could name. A weight is one coefficient in one matrix multiplication. What matters is all of them together: they decide which next-token probabilities come out for any input.
That gives us the key fact for the rest of the article: training a model means changing these numbers. Nothing else changes.
1.2 What happens when we type 10 + 1 =
Here is the forward pass, step by step:
- The text is split into tokens, and each token becomes a number (its id).
- Each id picks out its row of
embed_tokens: 1,536 numbers. - Those numbers go through 28 layers of matrix multiplications.
- The last layer produces 151,936 logits: one score for every token the model could say next.
- Softmax turns those scores into probabilities.
1.3 A small version we can compute by hand
151,936 probabilities are too many to follow. So from here on, we pretend the model can only answer 11, 12 or 10, each as one token. Here are its logits and what softmax does with them:
| Answer | Logit z | exp(z) | Probability = exp(z) / 12.276 |
|---|---|---|---|
| 11 | 2.00 | 7.389 | 0.602 |
| 12 | 1.12 | 3.065 | 0.250 |
| 10 | 0.60 | 1.822 | 0.148 |
| 12.276 | 1.000 |
So the model gets 10 + 1 right 60% of the time. Everything in this article is about raising that 0.602.
You might be wondering: why exp(z)? Why not use the logits directly?
Let's break this down. We need probabilities, which must be positive and add up to 1. Logits are neither: they can be negative, and their sum means nothing. Softmax fixes both:
expturns any number into a positive one and keeps the order, so a bigger logit still gives a bigger probability.- Dividing by the total makes them add up to 1.
- Only the gaps between logits matter.
11and12differ by 2.00 β 1.12 = 0.88, and exp(0.88) = 2.41. That is exactly 0.602 / 0.250:11is 2.41 times as likely as12. Add the same number to every logit and nothing changes.- It has a very clean derivative (section 2.3), which keeps every update below to a few lines of arithmetic.
Part 2: The ideas we need
2.1 Where does RL fit in training?
A model is trained in phases:
- Pre-training teaches it to predict the next token on huge amounts of text.
- Post-training is everything after that. It usually starts with supervised fine-tuning: show the model good answers and train it to reproduce them.
- Reinforcement learning (RL) comes next.
You might be wondering: if we can show the model good answers, why do we need RL at all?
Because showing a good answer requires having one written down. RL needs something weaker: a way to score an answer the model wrote itself. For many tasks, checking an answer is much easier than writing the best one. For10 + 1 =, the check is trivial: is the answer 11?
2.2 The words RL uses
Let's define each term on our example.
Policy (Ο). The rule the model uses to choose an answer. For a language model, the policy is simply its probabilities: Ο(11) = 0.602. Change the weights and the policy changes.
Reward (r). A number that scores one complete answer. Ours: r = 1 for 11, 0 for anything else.
Objective function (J). The single number training is trying to make as large as possible. In RL, it's the reward we expect on average:
J = Ξ£ Ο(answer) Γ r(answer)
= 0.602 Γ 1 + 0.250 Γ 0 + 0.148 Γ 0
= 0.602
For our prompt, J is exactly the probability of the right answer. Raising J means raising 0.602.
Loss (L). Optimisers are built to make a number smaller, so in practice we minimise a loss built so that lowering it raises J.
Advantage (A). How much better an answer was than we expected. If A > 0 we want that answer to become more likely; if A < 0, less likely.
Policy gradient. The direction to move the weights so that J goes up. Estimated from sampled answers, it is:
βJ β A Γ β log Ο(answer)
What does that formula actually say?
Let's break this down. β log Ο(answer) is the direction in weight space that makes this particular answer more likely. Multiply it by A:
- good answer (A > 0): move that way;
- bad answer (A < 0): move the opposite way;
- average answer (A = 0): don't move.
That's the whole idea of policy gradient methods. They differ mainly in how they compute A.
2.3 Backpropagation
The formula above needs β log Ο for every one of 1.5 billion weights. Backpropagation is how we get it.
How do you compute a derivative through 28 layers?
Let's break this down with two weights instead of 1.5 billion. The rule is the chain rule: the effect of a weight on the loss is the product of the effects along the path from that weight to the loss.
forward x = 3, w1 = 0.5, w2 = 2
h = w1 Β· x = 1.5
y = w2 Β· h = 3.0
loss L = (y β 5)Β² = 4.0 (we want y to be 5)
backward βL/βy = 2(y β 5) = β4
βL/βw2 = βL/βy Β· h = β4 Γ 1.5 = β6
βL/βw1 = βL/βy Β· w2 Β· x = β4 Γ 2 Γ 3 = β24
update move each weight against its derivative, step 0.01:
w2 = 2.06, w1 = 0.74 β y = 4.573, L = 0.182 (was 4.0)
We go backwards from the loss, reusing each derivative for the next one. A language model does exactly this, just with more weights.
For our softmax, the chain rule gives one formula that every section below relies on:
β log p_a / β z_j = (1 if j is the answer a, else 0) β p_j
In words: to make answer a more likely, raise its own logit by (1 β p_a) and lower every other logit j by p_j.
Part 3: Five methods, one prompt
3.1 The loop they all share
Every online method runs this loop:
- The model writes some answers.
- Each answer gets a score.
- Each score is compared with a baseline.
- The weights move.
The methods differ almost entirely in one box: where the baseline comes from.
3.2 REINFORCE (Williams, 1992): the simplest version
Use the reward itself as the advantage: A = r.
- Sample
11(r = 1): pushed up. Good. - Sample
12(r = 0): A = 0, nothing happens. A wrong answer is never pushed down.
What's wrong with that?
Two things. Wrong answers are never actively discouraged. And if all rewards were positive (say between 0.3 and 0.6), every answer would be pushed up, just by different amounts, which makes learning slow and noisy.
The fix is to compare against what we expected: A = r β baseline. Above expectation goes up, below goes down. The question every later method answers is: where does the baseline come from?
3.3 PPO (Schulman et al., 2017): learn the baseline
PPO trains a second network, the critic (or value model), whose only job is to predict the expected reward. Say it predicts 0.6 for 10 + 1 =:
sample "11": A = 1 β 0.6 = +0.4
sample "12": A = 0 β 0.6 = β0.6
Now wrong answers are pushed down, too. PPO also limits how far each update can go (clipping, section 4.1).
You might be wondering: so what's the catch?
The critic is a second network, typically about the size of the policy itself, that has to be trained alongside it. That roughly doubles the memory and adds another thing that can go wrong.
3.4 GRPO (Shao et al., DeepSeekMath, 2024): let the answers be the baseline
GRPO's idea is simple: if we write several answers to the same prompt anyway, their average reward already tells us what to expect. No critic needed. In the paper's words, GRPO "foregoes the critic model, instead estimating the baseline from group scores."
Let's run one GRPO step on 10 + 1 =.
Step 1: write a group of answers. We sample G = 4 answers from the probabilities (DeepSeekMath used 64):
11 12 11 10
You might be wondering: why sample at random instead of taking the most likely answer?
Because the model can only learn about answers it actually tries. If it always gave its top answer, it would never discover that a less likely answer scores better. The temperature T controls how random sampling is: logits are divided by T before softmax.
Step 2: score them.
rewards: 1 0 1 0
Step 3: compare each answer with the group.
A_i = (r_i β mean(r)) / std(r)
mean = 0.5, std = 0.5
A = +1 β1 +1 β1
Answers above the group average get pushed up, those below get pushed down. Dividing by the standard deviation puts every prompt on the same scale. The paper's reason for comparing within the group: it "aligns well with the comparative nature of rewards models", which are trained on comparisons between answers to the same question.
Step 4: work out the gradient. Let's break this down. For each sample, the formula from 2.3 says how to make it more likely; we multiply that by its A and average:
| Sample | A | on z_11 | on z_12 | on z_10 |
|---|---|---|---|---|
| 11 | +1 | +0.398 | β0.250 | β0.148 |
| 12 | β1 | +0.602 | β0.750 | +0.148 |
| 11 | +1 | +0.398 | β0.250 | β0.148 |
| 10 | β1 | +0.602 | +0.250 | β0.852 |
| average | +0.500 | β0.250 | β0.250 |
Every row agrees on the direction: raise the logit of 11, lower the other two.
Step 5: update. Backpropagation carries this from the logits to every weight. To see the effect, we apply it to the logits directly, with step size 0.5:
z = (2.00, 1.12, 0.60) + 0.5 Γ (0.50, β0.25, β0.25) = (2.250, 0.995, 0.475)
| before | after one GRPO step | |
|---|---|---|
| P(11) | 0.602 | 0.687 |
| P(12) | 0.250 | 0.196 |
| P(10) | 0.148 | 0.117 |
That's one full GRPO step. Repeat it over many prompts and you have GRPO training.
Does one step really move things that much?
No. A step size of 0.5 is used here so the change is visible. Real training uses a learning rate of 1e-6 on the weights (both DeepSeekMath and DAPO do), so each step moves the probabilities very little. The direction is the same.
With GRPO, DeepSeekMath-RL 7B went from 82.9% to 88.2% on GSM8K and from 46.8% to 51.7% on MATH.
3.5 DPO (Rafailov et al., 2023): skip the reward entirely
DPO takes a different route. There's no reward, no sampling during training and no critic. Instead, it uses a dataset of pairs: for a prompt x, an answer people preferred (y_w) and one they didn't (y_l). The paper's claim is that it trains a model to follow preferences "without explicit reward modeling or reinforcement learning."
Here is its loss:
L_DPO = β log Ο( Ξ² Β· log[Ο(y_w|x) / Ο_ref(y_w|x)] β Ξ² Β· log[Ο(y_l|x) / Ο_ref(y_l|x)] )
That looks heavy. Let's break this down:
- Ο_ref is a frozen copy of the model from before training.
-
Ξ² Β· log(Ο / Ο_ref)asks: how much more likely is this answer now than at the start? DPO treats this as the answer's implicit reward. Ξ² (we use 0.1) sets how strongly it counts. - The loss compares the implicit reward of the preferred answer with that of the dispreferred one. Ο is the logistic function, which turns that difference into a number between 0 and 1.
- Minimising the loss pushes the preferred answer's implicit reward above the dispreferred one's.
Our pair: x = 10 + 1 =, y_w = 11, y_l = 12. At the start the model equals Ο_ref, so both implicit rewards are 0:
loss = βlog Ο(0) = βlog 0.5 = 0.693
The paper gives the gradient:
βL_DPO = βΞ² Β· Ο(rΜ_l β rΜ_w) Β· [ β log Ο(y_w) β β log Ο(y_l) ]
What is Ο(rΜ_l β rΜ_w) doing there?
It sets how much this pair counts. If the model currently prefers the wrong answer, it's close to 1 and the pair counts fully. If the model already prefers the right one, it shrinks towards 0. In the paper's words, the examples "are weighed by how much higher the implicit reward model" rates the dispreferred answer.
On our logits:
β log Ο(11) β β log Ο(12) = (0.398, β0.250, β0.148) β (β0.602, 0.750, β0.148) = (1, β1, 0)
To minimise the loss we step against its gradient, which cancels the leading minus sign:
step direction = +Ξ² Γ 0.5 Γ (1, β1, 0) = (0.05, β0.05, 0)
step size 5 β logits (2.25, 0.87, 0.60)
| before | after one DPO step | |
|---|---|---|
| P(11) | 0.602 | 0.693 |
| P(12) | 0.250 | 0.174 |
| loss | 0.693 | 0.669 |
| pair weight Ο(rΜ_l β rΜ_w) | 0.500 | 0.488 |
The pair weight dropped, because the model now prefers 11 a little more.
Both raised P(11). So what's the difference in practice?
| GRPO | DPO | |
|---|---|---|
| What you need | a way to score any answer | a fixed set of preferred / dispreferred pairs |
| Writes new answers during training | yes, G per prompt | no |
| Learns from | its own current answers | answers collected beforehand |
| Can find a good answer that isn't in the data | yes | no |
| Extra model in memory | frozen reference copy (for KL) | frozen reference copy |
3.6 One formula behind all of them
Are these really different algorithms, or variations of one?
DeepSeekMath (Section 5.2.1) shows they share one shape. Each method pushes up the log-probability of some answers, multiplied by a gradient coefficient GC:
βJ = E[ (1/|o|) Ξ£_t GC(q, o, t) Β· β log Ο(o_t | q, o_<t) ]
What changes is where the answers come from and what GC is:
| Method | Answers come from | GC, as in the examples above |
|---|---|---|
| Supervised fine-tuning | a written dataset | 1 (every answer pushed up equally) |
| PPO | the current model | advantage from the critic |
| GRPO | the current model, G per prompt | advantage from the group (plus a KL term) |
| DPO | fixed pairs | +Ξ²Β·Ο(rΜ_l β rΜ_w) for the preferred, βΞ²Β·Ο(rΜ_l β rΜ_w) for the other |
Part 4: The full GRPO objective, piece by piece
Here is GRPO's objective as written in DeepSeekMath (Eq. 3):
J_GRPO = E[ (1/G) Ξ£_i (1/|o_i|) Ξ£_t { min( ratio_i,t Β· Γ_i,t , clip(ratio_i,t, 1βΞ΅, 1+Ξ΅) Β· Γ_i,t ) β Ξ² Β· KL_i,t } ]
That's a lot at once. Let's break this down into its three new pieces: the ratio and clipping, the KL term, and the averaging over tokens. Each gets one section, on our example. Entropy, which DAPO cares about, gets a section too.
4.1 The ratio and clipping
Why would we ever use the same batch twice?
Because writing and scoring answers is the expensive part. Once a batch is scored, it's tempting to run several updates on it. The catch: after the first update, the model has changed, and the batch was written by the old model.
The ratio measures how much the model has changed for each answer since it was sampled:
ratio = Ο(answer now) / Ο(answer when sampled)
"11" after our GRPO step: 0.687 / 0.602 = 1.14
(That 14% jump comes from our large illustrative step size. With a real learning rate the ratio drifts slowly across many updates.)
Clipping sets a limit on that ratio:
min( ratio Γ A , clip(ratio, 1βΞ΅, 1+Ξ΅) Γ A ) Ξ΅ = 0.2 β allowed range [0.8, 1.2]
Let's break this down:
- Inside the range (0.8 to 1.2), the objective is just ratio Γ A, and the update works normally.
-
Past the edge,
clipfreezes the value. A frozen value has a gradient of 0, so this batch stops pushing that answer. - The
minmakes sure the frozen version only applies when it would otherwise be over-rewarding a change.
On our example:
-
11at ratio 1.14 is inside the range, so it keeps being pushed up. - If another update took it to ratio 1.30, it would be past 1.2 and this batch would stop pushing it.
Note: DeepSeekMath itself did "a single update following each exploration stage". With one update per batch, the ratio is always 1 and clipping never kicks in. It matters when a batch is reused, as DAPO does with 16 updates per batch (Part 5).
4.2 The KL penalty
What stops the model from drifting into strange behaviour to chase reward?
In GRPO, the KL penalty. It measures how far the model has moved from a reference model (a frozen copy of where it started) and subtracts that from the objective. It's added directly to the loss, not to the reward.
KL divergence is 0 when two probability distributions are identical, and grows as they differ:
KL = Ξ£ Ο(x) Β· ln( Ο(x) / Ο_ref(x) )
= 0.687Β·ln(0.687/0.602) + 0.196Β·ln(0.196/0.250) + 0.117Β·ln(0.117/0.148)
= 0.0158
Summing over all 151,936 tokens at every position would be expensive. So GRPO estimates the KL from the sampled token alone (Eq. 4), an estimate the paper notes "is guaranteed to be positive":
KL β Ο_ref/Ο β ln(Ο_ref/Ο) β 1
"11": 0.602 / 0.687 = 0.876 β 0.876 β ln 0.876 β 1 = 0.0085
DeepSeekMath weighted it with Ξ² = 0.04.
4.3 Entropy
Entropy measures how spread out the model's probabilities are:
H = β Ξ£ p Β· ln p
Our GRPO step lowered it from 0.935 to 0.827. That's expected: training on rewards concentrates probability on what scores well.
So is low entropy bad?
Only if it falls too far, too early. Near zero, the model writes nearly the same answer every time. It stops trying alternatives, so it stops finding better ones. DAPO calls this entropy collapse, and one of its four changes targets it.
4.4 Answers are made of tokens
So far each answer was one token. Real answers are many tokens. Qwen's tokenizer even splits numbers into digits, so 11 is two tokens:
log Ο("11") = log Ο("1" | "10 + 1 =") + log Ο("1" | "10 + 1 = 1")
Every token of an answer gets that answer's advantage. The ratio, clipping and KL are all computed per token, and the per-token values are then averaged. How they are averaged matters more than it looks. Section 5.4 shows why.
Part 5: From GRPO to DAPO
5.1 The problem DAPO started from
DAPO (Yu et al., 2025; ByteDance Seed, Tsinghua AIR, The University of Hong Kong) used GRPO to train Qwen2.5-32B on maths with long chains of reasoning. Plain GRPO reached 30 points on AIME 2024. DeepSeek-R1-Zero-Qwen-32B had reached 47.
Where did those 17 points go?
The paper traces the gap to four problems, plus one choice. Each one shows up on 10 + 1 =.
| What goes wrong in GRPO | DAPO's change |
|---|---|
| A rare good answer can barely grow in one batch | Clip-Higher |
| A group where every answer scores the same teaches nothing | Dynamic Sampling |
| Tokens in long answers count less | Token-Level Loss |
| Cut-off answers get a reward unrelated to their content | Overlong Reward Shaping |
| The KL penalty keeps the model near its start | KL removed |
5.2 Clip-Higher
Let's start from what the clip does to a good answer. The upper limit 1 + Ξ΅ means that in one batch, its probability can rise to at most 1.2 times where it started. Because that's a multiplication, it hits rare answers much harder:
| Answer's probability when sampled | Most it can reach in one batch (Γ 1.2) | Gain |
|---|---|---|
| common answer, 0.60 | 0.72 | +0.12 |
| rare answer, 0.05 | 0.06 | +0.01 |
| the paper's example, 0.01 | 0.012 | +0.002 |
Why is that a problem, if the rare answer still grows?
Because everything else keeps growing faster. Suppose the model rarely says 11: P(11) = 0.05. When it does, the reward is high, but each batch can only lift it from 0.05 to 0.06. Meanwhile the answers it already favours keep getting sampled and reinforced. The model narrows onto what it already does, and entropy drops.
That's what the paper observed: "the entropy of the policy decreases quickly as training progresses", and the tokens hitting the upper limit were the unlikely ones (mean probability below 0.2).
The fix: raise only the upper limit.
Ξ΅_low = 0.2 unchanged: bad answers shrink at the same pace
Ξ΅_high = 0.28 good answers may grow to 1.28 times per batch, instead of 1.2
Starting from 0.05, at the fastest rate the clip allows, 11 reaches 0.5 after 13 batches with Γ 1.2 and after 10 batches with Γ 1.28.
Why not change the lower limit too?
The upper limit controls how fast good answers grow; the lower limit controls how fast bad answers shrink. The problem was rare good answers growing too slowly, so only the upper limit moves. It's the green dashed line in the clipping figure in section 4.1.
5.3 Dynamic Sampling
You might be wondering: what happens when the model gets all four answers right?
Let's work it out. Rewards are 1, 1, 1, 1. The mean is 1, so every answer's advantage is 1 β 1 = 0. (The standard deviation is 0 too; implementations add a tiny number to the denominator so this gives 0 instead of 0/0.) Every advantage is 0, so the group produces no gradient at all. The same happens when all four are wrong.
As the model improves, more prompts become all-correct, so a growing share of each batch teaches nothing. DAPO samples extra prompts and keeps only groups that have both right and wrong answers:
keep the prompt only if 0 < number of correct answers < G
The paper reports this "does not necessarily impede training efficiency". Training even converges in fewer steps, because each step carries more signal.
5.4 Token-Level Policy Gradient Loss
This is the least obvious change, so let's go slowly.
The question: an answer is several tokens, and each token gets a loss. When we average them, how much does each token count?
Take a group of two answers to 10 + 1 =:
| Answer | Tokens | Right? | A |
|---|---|---|---|
11 |
2 | yes | +1 |
| a 6-token answer that rambles and ends at 12 | 6 | no | β1 |
GRPO averages inside each answer first, then across answers. Each answer gets an equal share (1/2), and that share is split among its own tokens:
each token of "11": 1/2 Γ 1/2 = 1/4
each token of the long answer: 1/2 Γ 1/6 = 1/12
DAPO takes one average over all 8 tokens. Every token counts the same:
every token: 1/8
Why does that matter?
Look at what GRPO does to the long wrong answer. The longer it is, the weaker the push on each of its tokens: 1/12 here, 1/400 for a 200-token answer in the same group. So the model barely learns to stop rambling, repeating or producing gibberish inside long answers.
The paper saw exactly that: "excessively long samples often exhibit low-quality patterns such as gibberish", and per-answer averaging led to an "unhealthy increase in entropy and response length". With DAPO's averaging, a bad token is pushed down just as hard wherever it appears.
The two averages, written out:
GRPO: (1/G) Ξ£_i (1/|o_i|) Ξ£_t loss_i,t
DAPO: (1 / Ξ£_i |o_i|) Ξ£_i Ξ£_t loss_i,t
Note: the paper reports this change adds little to the score on its own (41 β 42), but makes training more stable and keeps answer length from growing unhealthily.
5.5 Overlong Reward Shaping
What happens to an answer that hits the length limit?
It gets cut off, and it's scored as wrong, because there's no final answer. But a correct line of reasoning that ran out of room isn't the same as a wrong one. The reward is telling the model something misleading.
DAPO first tried Overlong Filtering: leave cut-off answers out of the loss. Then it added a graded length penalty on top of the correctness reward, the Soft Overlong Punishment:
R_length(y) = 0 if |y| β€ L_max β L_cache
((L_max β L_cache) β |y|) / L_cache if L_max β L_cache < |y| β€ L_max
β1 if |y| > L_max
Let's put numbers in. DAPO uses L_max = 20,480 (its maximum generation length) and L_cache = 4,096:
- up to L_max β L_cache = 16,384 tokens: no penalty;
- from 16,384 to 20,480 (a 4,096-token ramp): the penalty grows steadily from 0 to β1;
- beyond L_max = 20,480: β1.
5.6 No KL
You might be wondering: didn't we just say KL keeps the model safe? Why remove it?
The paper's reasoning: when training long chains of thought, "the model distribution can diverge significantly from the initial model, thus this restriction is not necessary." The model is supposed to move far from where it started, and the KL penalty would hold it back.
DAPO's reward is a checked answer: +1 if it matches the ground truth, β1 if not.
You might be wondering: does +1 / β1 change anything compared with our 1 / 0?
No. After group normalisation, rewards (1, β1, 1, β1) give A = (+1, β1, +1, β1), exactly what (1, 0, 1, 0) gave. Normalising within the group makes the two scales equivalent.
5.7 The DAPO objective
Now we can read the full objective:
J_DAPO = E[ (1 / Ξ£_i |o_i|) Ξ£_i Ξ£_t min( ratio_i,t Β· Γ_i,t , clip(ratio_i,t, 1βΞ΅_low, 1+Ξ΅_high) Β· Γ_i,t ) ]
subject to 0 < |{ o_i : o_i is correct }| < G
Γ_i,t = (R_i β mean(R)) / std(R)
Let's break this down against GRPO's:
-
1 / Ξ£_i |o_i|: one average over all tokens (5.4); -
Ξ΅_low, Ξ΅_high: two different limits (5.2); -
subject to ...: only groups with both right and wrong answers (5.3); - no
Ξ² Β· KLterm (5.6); - R includes the length penalty (5.5).
5.8 Two DAPO updates, by hand
Let's run DAPO on a batch of two groups:
group 1: 11 12 11 10 rewards +1 β1 +1 β1 kept
group 2: 11 11 11 11 rewards +1 +1 +1 +1 filtered out (all equal)
Update 1. The model hasn't changed yet, so every ratio is 1 and nothing is clipped. With no KL, this is the same step as in 3.4: P(11) goes from 0.602 to 0.687.
Update 2, same batch. Now the model has moved, so the ratios have moved:
To keep the arithmetic checkable, here are the probabilities to four decimals:
| Sample | A | ratio = Ο now / Ο when sampled | Clipped? |
|---|---|---|---|
| 11 | +1 | 0.6875 / 0.6019 = 1.142 | no (below 1.28) |
| 12 | β1 | 0.1960 / 0.2497 = 0.785 | yes (below 0.8, and A < 0) |
| 11 | +1 | 1.142 | no |
| 10 | β1 | 0.1165 / 0.1484 = 0.785 | yes |
12 and 10 have already been pushed down as far as this batch allows, so they contribute nothing. Only the two 11 samples push, each scaled by its ratio:
gradient = 2 Γ 1.142 Γ (1 β 0.6875, β0.1960, β0.1165) / 4 = (+0.178, β0.112, β0.067)
logits = (2.250, 0.995, 0.475) + 0.5 Γ gradient = (2.339, 0.939, 0.442)
| start | after update 1 | after update 2 | |
|---|---|---|---|
| P(11) | 0.602 | 0.687 | 0.716 |
ratio of 11
|
1.00 | 1.14 | 1.19 |
Update 2 is smaller than update 1, and each further update on this batch will hit more limits. That's how clipping makes reusing a batch safe.
5.9 What each change was worth
From the paper's Table 1 (AIME 2024, avg@32, Qwen2.5-32B base). The full DAPO reaches 50, above DeepSeek-R1-Zero-Qwen-32B's 47, "using 50% training steps".
Part 6: The whole update on one page
for each training step:
prompts ββΊ write G answers each (temperature T) ββΊ score each ββΊ r
β
DAPO: keep only groups where 0 < #correct < G βββββββββββββββββββ
β
Γ = (r β group mean) / (group std + tiny number) same Γ for every token of an answer
β
per token: ratio = Ο now / Ο when sampled β
term = min( ratioΒ·Γ , clip(ratio, 1βΞ΅_low, 1+Ξ΅_high)Β·Γ )
GRPO also subtracts Ξ² Β· KL; DAPO does not β
β
average: GRPO inside each answer, then across the group β
DAPO over all tokens in the batch β
βΌ
loss = β average ββΊ backpropagate ββΊ update every weight
repeat on the same batch a few times (clipping keeps it bounded), then write new answers
On 10 + 1 =, one GRPO step took P(11) from 0.602 to 0.687: entropy fell from 0.935 to 0.827, and the model moved 0.0158 in KL from where it started. A second, clipped DAPO update on the same batch took it to 0.716.
Which one should you use?
It comes down to what you have:
| What you have | Reach for |
|---|---|
| Only a fixed set of "A was preferred over B" pairs, and no way to score new answers | DPO |
| A way to score any answer: a checker, a test or a reward model | GRPO |
| A scorer, and long chains of reasoning where entropy collapse and length effects break plain GRPO | DAPO |
DPO learns from preferences someone collected in advance. GRPO and DAPO learn from the model's own answers, scored as it goes, so they can find answers no one wrote down.
References
- Williams (1992). Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning 8.
- Schulman et al. (2017). Proximal Policy Optimization Algorithms. arXiv:1707.06347
- Rafailov et al. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. arXiv:2305.18290
- Shao et al. (2024). DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv:2402.03300
- Yu et al. (2025). DAPO: An Open-Source LLM Reinforcement Learning System at Scale. arXiv:2503.14476
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.










