Search

Search papers and lessons

DAPO (Decoupled Clip and Dynamic Sampling Policy Optimization)

Level 4 · 14 min read

DAPO is a GRPO variant for long reasoning RL: asymmetric clipping, dynamic sampling, token-level loss and soft length penalties, with no KL term.

On this page

  • Colour = topic mix
  • Probability
  • Reinforcement learning
  • Calculus
  • Linear algebra
  • Discrete math
  • Post-training
  • Sign in to see your progress

TL;DR

DAPO is a variant of GRPO for reinforcement learning on long reasoning chains. It loosens the upper clip so that unlikely tokens can grow in probability, drops prompts whose sampled answers are all right or all wrong, and averages the loss over tokens instead of over answers. It also penalises answers that run past a length limit, but gently, and it removes the KL penalty. The paper reports 50 points on AIME 2024 for a Qwen2.5-32B base model, against 30 for plain GRPO on the same model.

Where you'll see it: training open reasoning models on math and code tasks whose answers can be checked automatically, where the open-source DAPO system built on verl is a common starting point.

Intuition

Why a plain GRPO run stalls

GRPO works, but the authors found that a naive run on Qwen2.5-32B reached only 30 points on AIME 2024, well below the 47 reported for DeepSeek's R1-Zero recipe on the same base model. They traced the gap to three symptoms: entropy collapse, reward noise and training instability. DAPO gives each symptom a targeted fix, and each fix is small enough to explain on its own.

Entropy collapse and the clip

Entropy measures how spread out a model's next-token probabilities are. When entropy falls too far, the model becomes nearly deterministic, and the answers it samples for one question start to look identical. A group of identical answers gives no comparison to learn from, so exploration stops.

PPO's clip is one cause. For a token with a positive advantage, the update is capped once the probability ratio passes 1+ε1 + \varepsilon. A token that starts at probability 0.9 has plenty of room, because it can only go up to 1. A token that starts at 0.01 is held to a tiny absolute gain. Rare tokens are often the ones that open a new line of reasoning, so a tight upper cap blocks exactly the moves that would add diversity.

00.20.40.60.811.21.40.60.811.21.4probability ratio rclipped ratio for A > 0
  • upper cap, ε = 0.2
  • upper cap, ε_high = 0.28
For a token with positive advantage, the clipped ratio stops rising at 1 + ε. DAPO raises that ceiling only on the upper side.

Prompts that teach nothing

If every sampled answer to a prompt is correct, every reward in the group is equal. The group-relative advantage is then zero, and the prompt contributes no gradient. The same happens when every answer is wrong. As training goes on, more prompts sit at the all-correct end, so the number of useful prompts in each batch shrinks. DAPO handles this by sampling more prompts and discarding the useless ones until the batch is full of prompts with mixed outcomes.

Long answers and short answers

GRPO first averages the loss over the tokens of each answer and then averages over answers. A 100-token answer and a 1000-token answer therefore carry the same total weight, and each token of the long answer counts ten times less. The paper observes that long, degenerate answers (gibberish, repeated words) then go unpunished per token, which pushes entropy and length up in an unhealthy way. DAPO averages over all tokens in the group instead, so every token counts equally.

The math

Notation: qq is a question, aa its reference answer, and πθ\pi_\theta the policy (the language model) with parameters θ\theta. For each question, the old policy πθold\pi_{\theta_{old}} samples a group of GG answers o1,…,oGo_1, \dots, o_G. Answer oio_i has ∣oi∣|o_i| tokens, and oi,to_{i,t} is its tt-th token. The probability ratio for that token is

ri,t(θ)=πθ(oi,t∣q,oi,<t)πθold(oi,t∣q,oi,<t).r_{i,t}(\theta) = \frac{\pi_\theta(o_{i,t} \mid q, o_{i,\lt t})}{\pi_{\theta_{old}}(o_{i,t} \mid q, o_{i,\lt t})}.
Definition: DAPO objective

DAPO maximises

JDAPO(θ)=E(q,a), {oi}i=1G∼πθold[1∑i=1G∣oi∣∑i=1G∑t=1∣oi∣min⁡(ri,t(θ) A^i,t, clip⁡(ri,t(θ), 1−εlow, 1+εhigh) A^i,t)]\mathcal{J}_{\text{DAPO}}(\theta) = \mathbb{E}_{(q,a),\ \{o_i\}_{i=1}^{G} \sim \pi_{\theta_{old}}}\left[ \frac{1}{\sum_{i=1}^{G} |o_i|} \sum_{i=1}^{G} \sum_{t=1}^{|o_i|} \min\Big( r_{i,t}(\theta)\, \hat{A}_{i,t},\ \operatorname{clip}\big(r_{i,t}(\theta),\, 1 - \varepsilon_{low},\, 1 + \varepsilon_{high}\big)\, \hat{A}_{i,t} \Big) \right]

subject to

0<∣{oi:correct(oi)}∣<G,0 \lt \left| \{ o_i : \text{correct}(o_i) \} \right| \lt G,

where the advantage is A^i,t=Ri−mean⁡(R1,…,RG)std⁡(R1,…,RG)\hat{A}_{i,t} = \dfrac{R_i - \operatorname{mean}(R_1, \dots, R_G)}{\operatorname{std}(R_1, \dots, R_G)} and RiR_i is the reward of answer oio_i. The symbols εlow\varepsilon_{low} and εhigh\varepsilon_{high} are the lower and upper clip widths.

The objective has four changes from GRPO, one per technique.

Asymmetric clipping (Clip-Higher)

The clip range is split into a lower width εlow\varepsilon_{low} and an upper width εhigh\varepsilon_{high}. The paper uses εlow=0.2\varepsilon_{low} = 0.2 and εhigh=0.28\varepsilon_{high} = 0.28. Only the upper bound moves, because raising the lower bound would push low-probability tokens toward zero and collapse the sampling space.

Dynamic sampling (the constraint)

The constraint in the objective is the dynamic sampling rule. A prompt is kept only if its group is neither all correct nor all wrong. Sampling continues until the batch holds the target number of prompts that satisfy it.

Token-level normalisation

The denominator ∑i∣oi∣\sum_i |o_i| is the total number of tokens in the group. Each token contributes with the same weight, so a longer answer has more influence on the update in proportion to its length.

No KL penalty

GRPO adds a KL penalty against a frozen reference model. DAPO drops it. The paper's argument is that in long reasoning training the model is supposed to move far from its starting point, so keeping it close is not the right constraint. See Kullback–Leibler Divergence for what the removed term measured.

Reward and length penalty

The correctness reward is R=1R = 1 when the predicted answer is equivalent to the reference and R=−1R = -1 otherwise. Because the advantage is normalised by the group mean and standard deviation, shifting and scaling the reward (for example, from 0 and 1 to −1-1 and 11) leaves the advantages unchanged. The paper also adds a soft length penalty for truncated answers, with Lmax=16384L_{max} = 16384 and a cache Lcache=4096L_{cache} = 4096:

Rlength(y)={0,∣y∣≤Lmax−Lcache(Lmax−Lcache)−∣y∣Lcache,Lmax−Lcache<∣y∣≤Lmax−1,Lmax<∣y∣R_{\text{length}}(y) = \begin{cases} 0, & |y| \le L_{max} - L_{cache} \\ \dfrac{(L_{max} - L_{cache}) - |y|}{L_{cache}}, & L_{max} - L_{cache} \lt |y| \le L_{max} \\ -1, & L_{max} \lt |y| \end{cases}

Here ∣y∣|y| is the length of answer yy in tokens. The penalty is added to the correctness reward. Hard truncation at 20,480 tokens still applies, as the paper sets the generation limit there.

Worked examples

Example
How much room the upper clip gives

Take εlow=0.2\varepsilon_{low} = 0.2, so the lower bound is 0.80.8, and compare two upper widths for a token with positive advantage. The cap on the new probability is the old probability times 1+εhigh1 + \varepsilon_{high}.

  1. Rare token, old probability 0.010.01. With εhigh=0.2\varepsilon_{high} = 0.2, the cap is 0.01×1.2=0.0120.01 \times 1.2 = 0.012. With εhigh=0.28\varepsilon_{high} = 0.28, the cap is 0.01×1.28=0.01280.01 \times 1.28 = 0.0128.
  2. Gain from the change: 0.0128−0.012=0.00080.0128 - 0.012 = 0.0008.
  3. Common token, old probability 0.90.9. With 0.20.2 the cap is 1.081.08, and with 0.280.28 it is 1.1521.152. Both exceed 1, so neither clip binds, since a probability cannot exceed 1.

Interpretation: the relaxed bound moves the cap for rare tokens from 1.2 times to 1.28 times their old probability. The absolute gain in one update is small, so this is a steady nudge that accumulates over many steps, not a jump. It does nothing for common tokens, which is the intended asymmetry.

Example
Dynamic sampling on one prompt

Take a group with G=16G = 16 answers and suppose 12 are correct. Rewards are +1+1 for correct and −1-1 for wrong.

  1. Mean reward: (12×1+4×(−1))/16=0.5(12 \times 1 + 4 \times (-1)) / 16 = 0.5.
  2. Deviations: +0.5+0.5 for correct answers, −1.5-1.5 for wrong ones.
  3. Population variance: (12×0.25+4×2.25)/16=12/16=0.75(12 \times 0.25 + 4 \times 2.25) / 16 = 12 / 16 = 0.75, so the standard deviation is 0.75≈0.866\sqrt{0.75} \approx 0.866.
  4. Advantages: 0.5/0.866≈0.5770.5 / 0.866 \approx 0.577 for correct answers and −1.5/0.866≈−1.732-1.5 / 0.866 \approx -1.732 for wrong ones.
  5. Check: 12×0.577−4×1.732≈6.93−6.93=012 \times 0.577 - 4 \times 1.732 \approx 6.93 - 6.93 = 0, as normalised advantages must sum to zero.

If the same prompt had 16 correct answers, every reward would be +1+1, the standard deviation would be 0, and the group would be dropped by the constraint.

Interpretation: this prompt still has a signal, so it is kept. The illustrative arithmetic below shows the batch-filling effect. Suppose a batch needs 512 prompts and 150 of the first 512 sampled prompts are all-correct or all-wrong. Only 362 remain, so the sampler draws more prompts until 512 useful ones are collected. The cost of generation rises, but every gradient step uses a full batch of informative prompts. The paper reports that the total training time was not significantly affected.

Example
Token weights for a short and a long answer

A group has two answers. Answer A has 100 tokens and answer B has 1000 tokens, with G=2G = 2.

  1. Sample-level GRPO weights each token by 1G∣oi∣\frac{1}{G \lvert o_i \rvert}. A token in A gets 12×100=0.005\frac{1}{2 \times 100} = 0.005, and a token in B gets 12×1000=0.0005\frac{1}{2 \times 1000} = 0.0005.
  2. Total weight per answer under sample-level GRPO: 100×0.005=0.5100 \times 0.005 = 0.5 for A and 1000×0.0005=0.51000 \times 0.0005 = 0.5 for B. The two answers count equally.
  3. Token-level DAPO weights each token by 1∑i∣oi∣=11100≈0.00091\frac{1}{\sum_i \lvert o_i \rvert} = \frac{1}{1100} \approx 0.00091, the same for every token.
  4. Total weight per answer under DAPO: 100/1100≈0.091100 / 1100 \approx 0.091 for A and 1000/1100≈0.9091000 / 1100 \approx 0.909 for B.

Interpretation: under GRPO each token of the long answer is diluted tenfold, so a bad pattern repeated across a long answer is penalised weakly per token. Under DAPO a pattern costs the same wherever it appears, so repeated gibberish in a long answer is penalised as much as the same pattern in a short one.

Tradeoffs and failure modes

SituationWhat goes wrongBetter choice
Short answers, most prompts already solvedDynamic sampling discards many prompts and spends extra generation for little gainPlain GRPO or a curriculum that keeps hard prompts
Very hard dataset, most prompts at 0%Sampling cost grows sharply; the filter may never fill a batchEasier prompts first, or relax the group size
Learned reward model instead of a checkerWithout KL, the policy can drift into reward hackingKeep a KL term or a clipped reward; the paper's setup uses a rule-based correctness reward, where this risk is smaller
Truncated answers simply masked outThe model never learns to shorten, and it can drift back to long answersSoft length penalty, as in the paper's final recipe
Entropy drifting up with lengthRepetitive, low-quality text in long answersWatch entropy and length together, as the paper does

The paper's ablation (Table 1) shows each step adding accuracy on AIME 2024, in the order applied: naive GRPO 30, plus overlong filtering 36, plus Clip-Higher 38, plus soft overlong punishment 41, plus token-level loss 42, plus dynamic sampling 50. These gains come from one run order, so they are not independent contributions, and the token-level loss gives the smallest gain. The authors say it mainly improves stability.

History

DAPO was posted to arXiv in March 2025 by a team from ByteDance Seed and the Institute for AI Industry Research at Tsinghua University. It followed DeepSeek-R1, released in January 2025, which showed that RL on a base model could produce long chains of reasoning. R1 did not publish every training detail, and the DAPO authors reported that several groups had struggled to reproduce the result. Their contribution was a list of the failure modes they hit, a fix for each, and an open release of the training code (built on verl), the algorithm, and a curated dataset of about 17,000 math prompts with integer answers.

Check yourself

QuestionWhat is the only difference between the clip in DAPO and the clip in PPO when the advantage is positive?Show answer

PPO uses the same width ε\varepsilon on both sides, so the ratio is capped at 1+ε1 + \varepsilon and floored at 1−ε1 - \varepsilon. DAPO uses εlow=0.2\varepsilon_{low} = 0.2 on the lower side and εhigh=0.28\varepsilon_{high} = 0.28 on the upper side. For a positive advantage only the upper cap matters, so it rises from 1.21.2 to 1.281.28. The lower bound is kept because lowering the probability of a token too far can remove it from the sampling space.

QuestionIn a group of G=5G = 5 answers with 0 or 1 rewards, two answers are correct. What are the advantages of the correct and wrong answers, to three decimal places?Show answer

The mean reward is 0.40.4. The population variance is 0.4×0.6=0.240.4 \times 0.6 = 0.24, so the standard deviation is 0.24≈0.4899\sqrt{0.24} \approx 0.4899. The correct answers have advantage (1−0.4)/0.4899≈1.225(1 - 0.4)/0.4899 \approx 1.225, and the wrong answers have (0−0.4)/0.4899≈−0.816(0 - 0.4)/0.4899 \approx -0.816. Check: 2×1.225+3×(−0.816)≈02 \times 1.225 + 3 \times (-0.816) \approx 0.

QuestionWhy does a prompt on which all sampled answers are correct give no learning signal under GRPO, and why does DAPO discard it?Show answer

When every reward in the group is equal, each answer's reward equals the group mean, so every advantage is zero. The gradient from that prompt is zero, and the prompt only adds sampling cost. Since the group standard deviation is also zero, the normalisation is undefined. DAPO removes such prompts and keeps sampling until the batch contains only prompts with mixed outcomes, so each step's gradient comes from informative data.

QuestionYou train a code model with unit-test rewards. About 40% of prompts are solved by all 16 samples in every step. What would DAPO do, and what would you monitor?Show answer

DAPO would filter those prompts out and draw more prompts to fill the batch, so the effective gradient stays dense. The cost is that generation per step rises, roughly in proportion to the share of filtered prompts. You would monitor the filtered fraction, the cost per useful prompt, the response length and the entropy. If entropy falls sharply, Clip-Higher and the entropy watch from the paper are the first things to check. If the filtered fraction keeps growing, the training set is too easy and should be made harder.

Sources

  • Qiying Yu et al., "DAPO: An Open-Source LLM Reinforcement Learning System at Scale," 2025. arXiv:2503.14476
  • Zhihong Shao et al., "DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models," 2024. arXiv:2402.03300
  • John Schulman et al., "Proximal Policy Optimization Algorithms," 2017. arXiv:1707.06347
  • volcengine, verl reinforcement learning framework. GitHub