← All posts
Machine Learning

Decoupled Clip and Dynamic Sampling Policy Optimization (DAPO)

Overview

How DAPO fixes the failures of GRPO in long chain-of-thought reasoning: Clip-Higher against entropy collapse, dynamic sampling against zero-gradient prompts, a token-level loss for long responses, and overlong reward shaping for truncated answers.

DAPO cover: an asymmetric clipping range that leaves more room for raising the probability of rare tokens

Introduction

When DeepSeek released DeepSeek-R1 [1], it showed that a language model can learn to reason step by step through reinforcement learning alone. Its first version, R1-Zero, was trained with GRPO [2] directly from a pre-trained model, using nothing but a checker that says whether the final answer is right. But the paper left out many training details, and when others tried to reproduce the result, it did not work as well. Training Qwen2.5-32B [3] with GRPO in the same way, one team reached only points on the AIME 2024 math competition, far below the points DeepSeek reported for the same base model.

That team, from ByteDance Seed and Tsinghua University, studied why. They found that plain GRPO runs into four problems when the responses are long chains of reasoning: the model stops exploring, many prompts stop producing any learning signal, long responses are weighted wrongly in the loss, and responses cut off at the length limit give misleading rewards. Their fix, DAPO (Decoupled Clip and Dynamic sAmpling Policy Optimization) [4], changes GRPO in four places, one for each problem. With it, the same base model reached points on AIME 2024, more than DeepSeek’s , using half as many training steps. They also released the full training system and dataset.

In this post, we start from GRPO and the setting DAPO works in, then go through the four problems one at a time, each with the change that fixes it. We then put the changes together into the DAPO objective and algorithm, and see how much each one contributed. If you are not yet familiar with GRPO, the GRPO post covers everything this one builds on.

The Starting Point: GRPO for Long Reasoning

DAPO keeps the core of GRPO. For each prompt , the policy writes a group of responses , each response gets a reward , and the advantage of each response is its reward compared with the rest of its group, as in Eq. (3) of the GRPO post:

Every token of response gets this advantage, and the policy is updated with PPO’s clipped objective, using the probability ratio between the current policy and the policy that generated the group:

where is the prompt and the tokens of before . Like GRPO, DAPO uses no value model. In DAPO’s training runs, every group had responses.

Two choices define the setting. First, the reward comes from a rule instead of a reward model, because a learned reward model can be exploited, as we saw in the RLHF post. For math problems, a checker compares the model’s final answer with the correct answer [4]:

Second, DAPO removes the KL penalty that GRPO subtracts in Eq. (7) of the GRPO post. In RLHF, the penalty keeps the model close to its starting point because the reward model is only reliable there. Here, the reward of Eq. (1) is reliable everywhere, and a model learning long chains of reasoning is expected to move far away from its starting point, so the restriction is no longer needed [4].

With this setup, plain GRPO reached points on AIME 2024. The rest of this post follows the four problems behind that gap.

Clip-Higher: Making Room for Exploration

The first problem appeared early in training. At every step of a response, the policy gives a probability to every possible next token, and its entropy measures how spread out these probabilities are. High entropy means several tokens have a real chance of being picked, so the model tries different ways of solving a problem; low entropy means it makes the same choice nearly every time. In DAPO’s first runs with plain GRPO, the entropy fell quickly, and the responses in a group became nearly identical: the model had settled on one way of solving each problem before it knew whether that way was the best one. This is called entropy collapse, and it hurts GRPO in particular, because GRPO learns by comparing the responses within a group. When they are all the same, they all get the same reward, nothing tells the model that a different approach would have worked better, and training stops improving [4].

DAPO traced this to PPO’s clipping. Recall from the PPO post that when a token has a positive advantage, the clipped objective stops rewarding the update once the ratio reaches :

Multiplying both sides by the old probability shows what this means for the new probability:

The limit in Eq. (2) is a multiple of the old probability, so it treats likely and unlikely tokens very differently. With the usual , a token that already has probability may go up to , which is no limit at all, since no probability can exceed . But a token with probability may only go up to in one update. Tokens the model already prefers, the exploitation tokens, can easily become even more likely, while rare tokens that might start a new line of reasoning, the exploration tokens, can barely move. The paper confirms this in training: the tokens that hit the upper clip had a mean probability below [4].

DAPO’s fix is to decouple the two sides of the clipping range. Instead of one , it uses a lower bound and a separate, larger upper bound :

DAPO uses and , so the ratio may move within instead of . A rare token with probability may now reach in one update instead of , and over many updates this extra room adds up. In training, this kept the entropy from collapsing and the responses diverse [4].

The lower bound stays where it was. Raising would let a single update push the probability of a token much further down, and repeated over training, this would drive the probabilities of many tokens to and shrink the set of responses the model can produce [4].

Dynamic Sampling: Keeping Every Prompt Useful

The second problem comes from the group advantage itself. When every response in a group gets the same reward, all correct or all wrong, every reward equals the group mean:

so every advantage in the group is , and the whole group contributes nothing to the gradient. As we saw in the limitations of GRPO, this happens more and more as the model improves: in DAPO’s training, the share of prompts that the model solved in all attempts kept growing [4]. A batch of prompts might then contain only a fraction of prompts that actually produce a gradient. The effective batch shrinks, and the gradient becomes noisier.

DAPO’s fix is dynamic sampling. It generates responses for more prompts than it needs and keeps only the prompts whose group is mixed, with at least one correct and at least one wrong response:

The left inequality removes groups where every response is wrong, and the right one removes groups where every response is correct. Prompts that pass are added to a buffer, and generation continues until the buffer holds a full batch. Every prompt in the batch then has a non-zero advantage for at least some of its responses.

This means generating more responses per batch, but the paper found that it does not slow training down. In synchronous RL systems, the time to generate a batch is dominated by its longest responses, not by the number of prompts, and with every prompt now useful, the model reaches the same performance in fewer steps [4].

Token-Level Loss: Weighting Every Token Equally

The third problem is in how GRPO averages the loss. Write for the clipped term of token in response . GRPO first averages over the tokens of each response, and then over the responses of the group:

This is called a sample-level loss: every response gets the same total weight, , however long it is. But the weight of each individual token then depends on the length of its response. A token in response is weighted by

so the longer the response, the less each of its tokens counts. With , a response of tokens gives each of its tokens a weight of , while a response of tokens gives each of its tokens , a hundred times less.

In long reasoning, this has two harmful effects [4]. For a long and correct response, each of its reasoning steps is reinforced only weakly, so the model learns little from its best work. And very long responses are often the worst ones, full of repetition or meaningless text, but with sample-level weighting their tokens are penalized only weakly too. In DAPO’s training, this let the entropy and the response length grow in an unhealthy way.

DAPO’s fix is a token-level loss. Instead of averaging each response first, as in Eq. (5), it sums over all the tokens of all the responses in the group, and divides once by the total number of tokens:

Now every token has the same weight, , whatever the length of its response. In the example above, every token gets . A longer response has more influence on the update simply because it has more tokens, and a pattern that raises or lowers the reward is reinforced or suppressed equally, wherever it appears. The same length bias of GRPO was also pointed out by later work on Dr. GRPO [5].

Overlong Reward Shaping: Handling Truncated Responses

The fourth problem appears at the length limit. During training, responses are cut off at a maximum length, and a cut-off response has no final answer to check, so by default it gets the lowest reward. But a response may be cut off while its reasoning is still correct and simply long. Punishing it teaches the model that its reasoning was wrong when the only problem was its length. This adds reward noise: the same kind of reasoning is sometimes rewarded and sometimes punished, depending only on where the length limit falls.

DAPO first tested how much this noise matters with overlong filtering, which removes truncated responses from the loss entirely, so they neither reward nor punish anything. This alone made training much more stable and improved performance [4].

DAPO then replaced the hard punishment with a soft overlong punishment: a penalty that starts before the hard limit and grows gradually with the length. With the hard limit and the width of a soft interval before it, the length penalty of a response is [4]:

This penalty is added to the correctness reward of Eq. (1). DAPO sets the expected maximum length to tokens and adds a soft interval of tokens after it, so the hard limit is tokens [4]. With these values, the three cases of Eq. (7) divide the possible lengths into three zones.

Example: the three zones of the length penalty

The safe zone. If the response is no longer than , the first case applies:

A response of up to tokens gets no length penalty at all, and its reward is decided only by whether its answer is correct.

The soft zone. If the response is longer than tokens but still within the hard limit of , the second case applies. The penalty is the distance past tokens, as a fraction of the -token interval, with a minus sign. At the start of the interval, the penalty is still zero:

Halfway through the interval, it is :

and at the end of the interval, it reaches :

So inside this zone, the penalty falls in a straight line from to . Every extra token costs a little more reward, which tells the model that its response is getting too long while it is still being generated in full and its answer is still checked.

The hard zone. If the response goes beyond tokens, it is cut off, and the third case gives the full penalty:

The two zones meet without a jump: the soft zone ends at exactly , the value of the hard zone. Instead of going from no penalty to the maximum penalty at a single length, the reward now declines smoothly, so a response that runs slightly long is punished only slightly, and only a response that runs far too long is punished fully.

The DAPO Objective

Putting the four changes together gives the DAPO objective [4]. Compared with GRPO, it uses the decoupled clipping range of Eq. (3), the token-level average of Eq. (6), no KL term, and the dynamic sampling condition of Eq. (4):

where the expectation is over prompts and groups of responses sampled from , and the reward behind each advantage is the correctness reward of Eq. (1) plus the length penalty of Eq. (7). The training loop that maximizes Eq. (8) follows GRPO’s, with the dynamic sampling buffer added:

Algorithm 1 DAPO

The training runs used a batch of prompts with responses each, split into mini-batches for gradient updates per batch, the AdamW optimizer with a learning rate of , and the verl framework [6] for training. The prompts come from DAPO-Math-17K, a dataset of math problems the authors released with the paper. To make the rule-based reward of Eq. (1) reliable, every problem was rewritten so that its answer is an integer, which a simple rule can check without parsing formulas [4].

How Much Each Change Helped

The paper added the techniques to plain GRPO one at a time, training Qwen2.5-32B and measuring the average accuracy on AIME 2024 over attempts per problem [4]:

Model AIME 2024
DeepSeek-R1-Zero-Qwen-32B 47
GRPO 30
+ Overlong filtering 36
+ Clip-Higher 38
+ Soft overlong punishment 41
+ Token-level loss 42
+ Dynamic sampling (DAPO) 50

Every change helped. The largest single gain came from dynamic sampling, which keeps every prompt in the batch useful, and handling truncated responses correctly was worth points in total, from overlong filtering and from soft overlong punishment. The token-level loss added only one point on its own, but the paper found that it made training more stable by keeping the response length under control.

What DAPO Does Not Change

DAPO fixes GRPO’s problems in long reasoning, but it keeps GRPO’s basic design and its costs. It still generates a group of responses for every prompt, and dynamic sampling generates even more before filtering. Every token of a response still gets the same advantage, so a correct step and an irrelevant one in the same response are reinforced equally. Removing the KL penalty relies on a reward that cannot be exploited, which holds for checkable tasks like math but not for rewards from a learned model. And the paper evaluates DAPO only on math, although its techniques are not specific to it.

DAPO did not replace GRPO. It showed that GRPO works for long reasoning once its clipping, sampling, loss averaging, and length handling are adjusted to it.

References

  1. DeepSeek-AI (2025). DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning. arXiv:2501.12948.
  2. Shao, Z., Wang, P., Zhu, Q., et al. (2024). DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv:2402.03300.
  3. Qwen Team (2024). Qwen2.5 Technical Report. arXiv:2412.15115.
  4. Yu, Q., Zhang, Z., Zhu, R., et al. (2025). DAPO: An Open-Source LLM Reinforcement Learning System at Scale. arXiv:2503.14476.
  5. Liu, Z., Chen, C., Li, W., et al. (2025). Understanding R1-Zero-Like Training: A Critical Perspective. arXiv:2503.20783.
  6. Sheng, G., Zhang, C., Ye, Z., et al. (2024). HybridFlow: A Flexible and Efficient RLHF Framework. arXiv:2409.19256.
Mir Sazzat Hossain

Mir Sazzat Hossain

Junior Research Scientist at CCDS, IUB. Working on computer vision, domain adaptation, and the occasional radio-galaxy problem.

Related posts

Comments

Join the discussion here or continue it on GitHub.