DEV Community

Tisha Chawla
Tisha Chawla

Posted on Edited on

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 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 =

One forward pass: text, token ids, embeddings, 28 layers, logits, probabilities

Here is the forward pass, step by step:

  1. The text is split into tokens, and each token becomes a number (its id).
  2. Each id picks out its row of embed_tokens: 1,536 numbers.
  3. Those numbers go through 28 layers of matrix multiplications.
  4. The last layer produces 151,936 logits: one score for every token the model could say next.
  5. 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:

  • exp turns 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. 11 and 12 differ by 2.00 − 1.12 = 0.88, and exp(0.88) = 2.41. That is exactly 0.602 / 0.250: 11 is 2.41 times as likely as 12. 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?

Pre-training, supervised fine-tuning, RL; post-training is everything after pre-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. For 10 + 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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

The loop: policy, sample, reward, baseline, advantage, loss, update

Every online method runs this loop:

  1. The model writes some answers.
  2. Each answer gets a score.
  3. Each score is compared with a baseline.
  4. The weights move.

The methods differ almost entirely in one box: where the baseline comes from.

The loop: policy, sample, reward, baseline, advantage, loss, update

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode
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)] )
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

The paper gives the gradient:

∇L_DPO = −β · σ(r̂_l − r̂_w) · [ ∇ log π(y_w) − ∇ log π(y_l) ]
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode
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.

One update raises P(11): GRPO to 0.687, DPO to 0.693

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) ]
Enter fullscreen mode Exit fullscreen mode

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 } ]
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

(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]
Enter fullscreen mode Exit fullscreen mode

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, clip freezes the value. A frozen value has a gradient of 0, so this batch stops pushing that answer.
  • The min makes sure the frozen version only applies when it would otherwise be over-rewarding a change.

Clipping: inside the shaded range the objective rises; past its edge it goes flat

On our example:

  • 11 at 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

DeepSeekMath weighted it with β = 0.04.

4.3 Entropy

Entropy measures how spread out the model's probabilities are:

H = − Σ p · ln p
Enter fullscreen mode Exit fullscreen mode

Entropy: equal 1.099, before 0.935, after 0.827, collapsed 0.063

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")
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

A rare right answer starting at 0.05 reaches 0.5 in 10 batches with x1.28, 13 with x1.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

Groups where every answer scores the same are filtered out

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

DAPO takes one average over all 8 tokens. Every token counts the same:

every token:   1/8
Enter fullscreen mode Exit fullscreen mode

GRPO gives each token of the long wrong answer 1/12, DAPO gives 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Soft overlong punishment: 0 up to 16,384 tokens, a ramp to −1 at 20,480

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)
Enter fullscreen mode Exit fullscreen mode

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 β · KL term (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)
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode
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

DAPO ablation: plain GRPO 30, then 36, 38, 41, 42, and 50 with dynamic sampling

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
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)