Since DeepSeek-R1, nearly every frontier technical report has shipped its own RL objective with its own name: GRPO, DAPO, Dr. GRPO, GSPO, CISPO, IcePop, TIS, double-sided masks, entropy-controlled clips. Read one at a time, they look like a zoo. Written in the right coordinates they are one family. Every one of them is REINFORCE with a different weight on each token. This lesson builds that coordinate system, places each lab inside it, and sets up the three lessons that follow, each of which takes one coordinate apart: aggregation and the ratio level, clipping and importance sampling, and regularisation.
The lesson assumes GRPO and its variants and the training–inference mismatch are familiar; it does not re-derive them.
The template: everything is a per-token weight
Take any loss built from the log-probabilities of the sampled tokens, , for responses to a prompt . Everything else in it — rewards, old log-probs, reference log-probs, the rollout engine’s log-probs — is a constant with respect to . By the chain rule
So for a given batch, an objective is fully described by one number per token, . Two losses that look nothing alike are the same algorithm if they produce the same , and two losses that look almost identical are different algorithms if they do not. This is also how you should read a new paper: compute .
For the clipped surrogate, follows from differentiating with , so :
When the clipped branch is active the term is a constant and the token gets no gradient at all. The stop-gradient form used by CISPO, MiMo and GLM-5’s agentic stage gives directly. Collecting every variant in the literature, the weight always factors into the same six parts:
| Slot | Choices you will meet | What it decides |
|---|---|---|
| Advantage | (GRPO), (Dr. GRPO, Olmo 3, V3.2, Kimi), leave-one-out, reward-to-go minus baseline (MiniMax-M2) | how much signal each response carries, and per-prompt weighting |
| Aggregation | (sequence-mean), (token-mean), (constant), per sequence | how much a token weighs as a function of its response’s length |
| Ratio | token , sequence geometric mean (GSPO), sequence log-ratio (k1.5), against the rollout engine (MiMo-V2.6, GLM-5 agentic) | which unit is compared with the trust region |
| Clip / mask | PPO clip, clip-higher, dual-clip, CISPO weight cap, log-ratio mask (K2.5), band mask, entropy-controlled bounds (MAI) | which tokens lose their gradient, and which are only capped |
| IS correction | none, TIS , IcePop , V3.2 sequence mask | how the gap between trainer and sampler is treated |
| Regulariser | none, k3 to , k3 (V3.2), to (K2.5), squared sequence log-ratio (k1.5) | what the policy is anchored to |
What the template does not contain is just as important. It says nothing about which samples enter the batch (difficulty filtering, dynamic sampling, curricula), about the reward, or about the systems fixes that change the numbers , and themselves (routing replay, FP32 LM head, batch-invariant kernels). Those live in the long-horizon, mismatch-engineering and rewards lessons. Two objectives with the same can still behave very differently if one of them is fed a different batch.
In a picture: the same batch under every lab’s objective
The figure draws one prompt’s group of eight responses (lengths 60 to 420 tokens, three correct). Each token has a sampled probability under , a ratio after some updates, and an engine ratio with a heavy tail. The ratio is generated as a logit shift of the sampled token, so low-probability tokens move most in ratio space — this is what really happens and it matters for every clip rule.
DeepSeek-R1 이후 거의 모든 프론티어 기술 보고서가 저마다 이름 붙인 RL 목적함수를 내놓았다. GRPO, DAPO, Dr. GRPO, GSPO, CISPO, IcePop, TIS, 양방향 mask, 엔트로피로 조절되는 clip. 하나씩 읽으면 동물원 같다. 알맞은 좌표로 쓰면 한 가족이다. 모두 토큰마다 다른 가중치를 곱한 REINFORCE다. 이 레슨은 그 좌표계를 만들고 각 랩을 그 안에 배치한 뒤, 좌표 하나씩을 해부하는 다음 세 레슨 — 집계와 ratio 단위, clipping과 importance sampling, 정규화 — 을 준비한다.
GRPO와 그 변형, 학습–추론 불일치는 안다고 가정하고 다시 유도하지 않는다.
틀: 모든 것은 토큰당 가중치다
프롬프트 에 대한 응답 개 의 샘플 토큰 log-확률 로 만든 손실을 아무거나 잡자. 그 안의 나머지 — 보상, old log-prob, reference log-prob, rollout 엔진의 log-prob — 는 에 대해 상수다. 연쇄법칙으로
그러니 주어진 배치에서 목적함수는 토큰마다 숫자 하나 로 완전히 기술된다. 전혀 달라 보이는 두 손실도 같은 를 만들면 같은 알고리즘이고, 거의 같아 보여도 가 다르면 다른 알고리즘이다. 새 논문도 이렇게 읽으면 된다. 를 계산하라.
Clip된 surrogate의 는 , 즉 를 써서 를 미분하면 나온다.
Clip된 가지가 선택되면 그 항은 상수이고 토큰은 gradient를 전혀 받지 않는다. CISPO, MiMo, GLM-5의 agentic 단계가 쓰는 stop-gradient 형태 은 곧바로 를 준다. 문헌의 변형을 모두 모으면 가중치는 늘 같은 여섯 부품으로 인수분해된다.
| 칸 | 만나게 될 선택지 | 무엇을 결정하나 |
|---|---|---|
| Advantage | (GRPO), (Dr. GRPO, Olmo 3, V3.2, Kimi), leave-one-out, reward-to-go − baseline (MiniMax-M2) | 응답 하나가 싣는 신호의 크기, 프롬프트별 가중 |
| 집계 | (sequence-mean), (token-mean), (상수), 시퀀스당 | 응답 길이에 따라 토큰 하나가 얼마나 무거운가 |
| Ratio | 토큰 , 시퀀스 기하평균 (GSPO), 시퀀스 log-ratio (k1.5), rollout 엔진 기준 (MiMo-V2.6, GLM-5 agentic) | trust region과 비교하는 단위 |
| Clip / mask | PPO clip, clip-higher, dual-clip, CISPO 가중치 상한, log-ratio mask (K2.5), band mask, 엔트로피 조절 경계 (MAI) | 어떤 토큰이 gradient를 잃고, 어떤 토큰은 크기만 눌리나 |
| IS 보정 | 없음, TIS , IcePop , V3.2 시퀀스 mask | 학습기와 샘플러의 차이 를 어떻게 다루나 |
| 정규화 항 | 없음, 로의 k3, k3 (V3.2), 로의 (K2.5), 시퀀스 log-ratio 제곱 (k1.5) | 정책을 무엇에 묶어 두나 |
틀이 담지 않는 것도 그만큼 중요하다. 어떤 샘플이 배치에 들어오는가(난이도 필터, dynamic sampling, 커리큘럼), 보상, 그리고 숫자 , , 자체를 바꾸는 시스템 쪽 수정(routing replay, FP32 LM head, batch-invariant 커널)은 여기 없다. 그것들은 long-horizon, 불일치 엔지니어링, 보상 레슨에서 다룬다. 가 같은 두 목적함수도 다른 배치를 먹으면 전혀 다르게 움직인다.
그림으로: 같은 배치, 랩마다 다른 목적함수
그림은 한 프롬프트에 대한 응답 8개(길이 60–420 토큰, 정답 3개)의 그룹이다. 토큰마다 에서의 샘플 확률, 몇 번 업데이트한 뒤의 ratio , 꼬리가 두꺼운 엔진 ratio 가 있다. Ratio는 샘플 토큰 logit의 이동으로 만들었기 때문에 확률이 낮은 토큰일수록 ratio 공간에서 크게 움직인다. 실제로도 그렇고, 모든 clip 규칙에 중요하다.
Things to try:
- GRPO vs DAPO at drift 0.4. GRPO’s long wrong answers (lengths 420 and 380) are pale; switch to DAPO and they turn as red as the short wrong one. The readout “per-token |w| long/short wrong” goes from about to 1. That is aggregation, the subject of the next lesson.
- Qwen GSPO. Whole rows go grey at once: the clip acts on the sequence ratio , so a response is either in or out. With almost every response is out at drift 0.4 — set drift to 0.05 to see them come back. Within a row the colour is uniform: every token of a response gets the same .
- MiniMax CISPO never shows grey. Tokens with large are capped at but still learn. Compare the “zero-grad” readout with DAPO’s as you raise drift.
- GLM-5 (IcePop) and Olmo 3 (TIS) react to the engine mismatch slider, not to drift: IcePop deletes tokens whose leaves ; TIS only shrinks those above 2.
- DeepSeek-V3.2 kills whole wrong responses when they drifted away from the sampler (the sequence mask fires only when ). Raise both sliders.
- Kimi k1.5 has no clip at all; the pull-back term grows with the response’s length and can flip the sign of a long correct answer’s total weight.
- GMPO and Qwen SAPO sit between the token and sequence views: GMPO gives every unclipped token of a response the same geometric-mean weight; SAPO replaces the hard cut-off with a smooth gate, so tokens fade out instead of turning grey. Both are taken apart in the next lesson.
Every lab in one table
Here is what each lab reports, translated into the slots above. Equations and numbers come from the Track VI reviews (linked), which were written from the primary reports; ”—” means the report does not use the component, “n/d” that it uses it without disclosing the value. Placeholders in the figure stand in for every n/d.
| Lab · objective | Advantage | Aggregation | Ratio · clip/mask · IS | Regulariser | Other stabilisers |
|---|---|---|---|---|---|
| DeepSeek-R1 — GRPO | , | written per sequence; DeepSeekMath form | PPO clip; in stage-1 RL (§3.2.1) | k3 in loss, ; replaced every 400 steps | one rollout batch → 16 minibatch updates |
| DeepSeek-V3.2, V4 | (no std) | token clip (n/d) × off-policy sequence mask: drop sequences with , from the inference engine | unbiased KL k3; weakened or dropped for maths | Keep Routing, Keep Sampling Mask, length penalty in reward | |
| Qwen3 → GSPO | per sequence (gradient carries ) | sequence ratio , clip / | — | stable MoE RL without routing replay (GSPO §5.3) | |
| Kimi k1.5, K2 | mean over samples, no length normalisation | no clip; squared loss pulls back | mirror descent to ( n/d) | length reward (k1.5), budget control, PTX loss, temperature decay (K2), partial rollouts | |
| Kimi K2.5 / K3 | , = tokens in batch | token ratio with a log-ratio mask (gradient zeroed outside the interval, either sign of ; bounds n/d) | per token | effort budgets (reward above ), QAT so rollout and training share precision | |
| MiniMax-M1/M2 — CISPO | group-relative (M1); reward-to-go − baseline (M2) | : weight capped, gradient kept ( n/d) | — | FP32 LM head (correlation 0.9x → 0.99x), AdamW , , dynamic sampling, length penalty | |
| MiMo-7B | clip-higher (n/d) | — | dynamic sampling, 10% easy-pool resampling, 16 updates per iteration | ||
| MiMo-V2.6 | (+ GAR rescaling) | written ; text says per-prompt mean | , separate bounds for and , initialised at , moved by entropy | — | staleness 4, frozen router, top-p candidate replay |
| GLM-4.5 | ; for agentic | token-weighted (faster for code RL) or sequence-mean | symmetric clip (n/d) | dropped | hard stage with pass@8 = 0, pass@512 > 0; temperature raised at plateaus |
| GLM-5 | clip × IcePop ; agentic: double-sided band on | dropped | deterministic top-k in the DSA indexer, optimiser reset after each weight push, staleness filter | ||
| MAI-Thinking-1 | global-batch token mean | clip , , set by an entropy controller; outer | — () | routing replay, top-p mask replay, length term in reward (), rollouts ≤ 40 gradient steps stale | |
| Olmo 3 | clip × TIS | — | active sampling fills the batch with non-zero groups; inflight weight updates | ||
| Nemotron 3 Ultra | token-level (review’s reading) | PPO clip (n/d) × mask on train/infer log-prob ratio (n/d) | — | asynchronous, ≤ 1 step lag; MOPD stage with behaviour→proximal IS weight | |
| DAPO | clip | — | dynamic sampling, overlong shaping | ||
| Dr. GRPO | PPO clip | — | — | ||
| GMPO | per sequence | geometric mean of token-clipped terms, clip | — | — | |
| Qwen SAPO | per sequence, then group | soft sigmoid gate instead of a hard clip, , | — | — |
The MAI column bounds use for the controller state that the report calls , to avoid a clash with the engine ratio .
Reading the table
Four trends stand out once everything is in the same slots.
1. The std division is leaving. DeepSeek dropped it between R1 and V3.2; Olmo 3, Kimi, MiMo-V2.6 and GLM’s agentic stage never had it. Dividing by for binary rewards up-weights prompts near or (derivation); labs that keep it (MAI, GLM-5, Nemotron) pair it with filters that remove those prompts anyway.
2. Token-mean aggregation won, with two notable exceptions. DAPO, MiMo, MiniMax, MAI, Olmo, K2.5 and Nemotron normalise by the total token count; DeepSeek V3.2 and GLM-5’s reasoning stage still use , and GSPO’s sequence ratio brings the back implicitly. MiMo-V2.6’s text argues for per-prompt averaging precisely because it slows length growth. Length bias is not a bug to remove at all costs but a lever.
3. The reference KL is almost gone; anchoring to replaced it. Only DeepSeek keeps a reference KL (and fixes its estimator). Kimi regularises towards the previous policy with an L2 penalty on the log-ratio. The rest rely on the clip or mask as their only anchor. The regularisation lesson explains why this works for verifiable rewards and what replaces the KL’s role against entropy collapse.
4. The real action moved to the ratio. One ratio now hides three different gaps — the policy update , staleness, and the engine mismatch — and each lab chooses which to clip, which to correct, which to mask, and at which unit (token, sequence, sign of ). Compare: Olmo multiplies a TIS weight for the engine gap with a PPO clip for the update; GLM-5’s agentic stage and MiMo-V2.6 skip and band-mask the full ; V3.2 masks only negative sequences. The clipping and IS lesson maps all of these on one gradient-weight plot.
The advantage slot: one family of baselines
The template takes as given, but this is the slot with the longest history, and the labs’ choices above are only a corner of it. Every critic-free estimator is a reward minus a baseline, possibly rescaled:
The baseline keeps the gradient unbiased as long as it does not depend on itself, since ; it may depend on the prompt, on the other samples, or on a separate rollout. The scale is different: it changes how much each prompt (or batch) weighs and therefore which objective is optimised.
| Estimator | Baseline | Scale | What it buys |
|---|---|---|---|
| GRPO (Shao et al. 2024) | group mean, including | group std | amplifies prompts where success is rare; biases toward or |
| Dr. GRPO (Liu et al. 2025) | group mean | 1 | the GRPO direction without the per-prompt reweighting |
| RLOO (Ahmadian et al. 2024) | mean of the other | 1 | exactly unbiased; equals Dr. GRPO |
| REINFORCE++ (Hu et al. 2025) | global batch mean of | global batch std | one sample per prompt; k1 KL folded into the return |
| REINFORCE++-baseline | group mean, then batch mean | global batch std | group baseline, batch-level scale; KL moved to a separate k2 loss |
| ReMax (Li et al. 2024) | reward of the greedy decode | 1 | one extra greedy rollout instead of a critic |
| OPO (Hao et al. 2025) | 1 | the variance-minimising baseline when gradient size grows with length | |
| GPG (Chu et al. 2025) | group mean | ( = samples in zero-advantage groups) | plain , no surrogate, clip, KL or reference; the rescale undoes the dilution by dead groups |
| pass@k advantage (Tang et al. 2025) | second-best reward in the group | 1 | optimises the max over samples: only the best response gets signal |
| Optimal Token Baseline (Li et al. 2026) | per token: reward-to-go averaged with weights | 1 | per-token variance reduction for long horizons |
The figure puts eight of them side by side on the same two prompts.
해 볼 것:
- 이동 0.4에서 GRPO와 DAPO. GRPO에서 긴 오답(길이 420, 380)은 옅다. DAPO로 바꾸면 짧은 오답만큼 빨갛다. “긴/짧은 오답 토큰당 |w|” 값이 대략 에서 1로 바뀐다. 이것이 집계이고, 다음 레슨의 주제다.
- Qwen GSPO. 행 전체가 한꺼번에 회색이 된다. clip이 시퀀스 ratio 에 걸리므로 응답 단위로 들어오거나 나간다. 이면 이동 0.4에서 거의 모든 응답이 밖이다. 이동을 0.05로 내리면 돌아온다. 한 행 안의 색은 균일하다. 응답의 모든 토큰이 같은 를 받는다.
- MiniMax CISPO에는 회색이 없다. 가 큰 토큰은 에서 눌리지만 여전히 배운다. 이동을 올리며 “기울기 0 토큰” 값을 DAPO와 비교하라.
- **GLM-5 (IcePop)**과 **Olmo 3 (TIS)**는 이동이 아니라 엔진 불일치 슬라이더에 반응한다. IcePop은 가 를 벗어난 토큰을 지우고, TIS는 2를 넘는 토큰을 줄이기만 한다.
- DeepSeek-V3.2는 샘플러에서 멀어진 오답 응답을 통째로 끈다(시퀀스 mask는 일 때만 작동). 두 슬라이더를 모두 올려 보라.
- Kimi k1.5에는 clip이 아예 없다. 끌어당기는 항 가 응답 길이에 따라 커져서, 긴 정답의 총 가중치 부호를 뒤집기도 한다.
- GMPO와 Qwen SAPO는 토큰 관점과 시퀀스 관점 사이에 있다. GMPO는 응답에서 clip되지 않은 모든 토큰에 같은 기하평균 가중치를 준다. SAPO는 딱 끊는 대신 부드러운 gate를 써서 토큰이 회색이 되는 대신 서서히 흐려진다. 둘 다 다음 레슨에서 해부한다.
모든 랩을 한 표에
각 랩이 보고한 내용을 위 칸들로 옮긴 표다. 식과 숫자는 원 보고서로 쓴 Track VI 리뷰(링크)에서 가져왔다. ”—“는 그 부품을 쓰지 않음, “비공개”는 쓰지만 값을 밝히지 않음이다. 그림의 자리표시값이 모든 비공개 값을 대신한다.
| 랩 · 목적함수 | Advantage | 집계 | Ratio · clip/mask · IS | 정규화 항 | 그 밖의 안정화 |
|---|---|---|---|---|---|
| DeepSeek-R1 — GRPO | , | 시퀀스 단위로 표기; DeepSeekMath 형태는 | PPO clip; stage-1 RL에서 (§3.2.1) | 손실 안의 k3, ; 400 step마다 교체 | rollout 배치 하나 → minibatch 업데이트 16번 |
| DeepSeek-V3.2, V4 | (std 없음) | 토큰 clip(비공개) × off-policy 시퀀스 mask: 인 시퀀스를 버림, 는 추론 엔진 확률 | 편향 없는 KL k3; 수학에서는 약하게 하거나 뺌 | Keep Routing, Keep Sampling Mask, 보상의 길이 패널티 | |
| Qwen3 → GSPO | 시퀀스당 (gradient가 를 실어 옴) | 시퀀스 ratio , clip / | — | routing replay 없이 MoE RL 안정 (GSPO §5.3) | |
| Kimi k1.5, K2 | 샘플 개 평균, 길이 정규화 없음 | clip 없음; 제곱 손실이 를 끌어당김 | 로의 mirror descent ( 비공개) | 길이 보상(k1.5), budget control, PTX loss, temperature decay(K2), partial rollout | |
| Kimi K2.5 / K3 | , = 배치 토큰 수 | 토큰 ratio에 log-ratio mask(구간 밖이면 부호와 무관하게 gradient 0; 경계 비공개) | 토큰마다 | effort budget(보상 above ), rollout과 학습이 같은 정밀도를 쓰는 QAT | |
| MiniMax-M1/M2 — CISPO | 그룹 상대(M1); reward-to-go − baseline(M2) | : 가중치만 상한, gradient 유지( 비공개) | — | FP32 LM head(상관 0.9x → 0.99x), AdamW , , dynamic sampling, 길이 패널티 | |
| MiMo-7B | clip-higher(비공개) | — | dynamic sampling, easy pool 10% 재샘플, iteration당 업데이트 16번 | ||
| MiMo-V2.6 | (+ GAR 재조정) | 식은 , 본문은 프롬프트별 평균 | , 과 에 별도 경계, 초기값 , 엔트로피로 조정 | — | staleness 4, router 고정, top-p 후보 replay |
| GLM-4.5 | ; agentic은 | token-weighted(code RL에서 더 빠름) 또는 sequence-mean | 대칭 clip(비공개) | 뺌 | pass@8 = 0, pass@512 > 0 문제로 된 어려운 단계; 정체 시 temperature 상향 |
| GLM-5 | clip × IcePop ; agentic: 에 양방향 band | 뺌 | DSA indexer의 결정적 top-k, weight push마다 optimizer 초기화, staleness 필터 | ||
| MAI-Thinking-1 | 전역 배치 토큰 평균 | clip , , 는 엔트로피 controller가 정함; 바깥 | — () | routing replay, top-p mask replay, 보상의 길이 항(), rollout은 gradient step 40 이하로 stale | |
| Olmo 3 | clip × TIS | — | active sampling으로 0이 아닌 그룹만 채움; inflight weight update | ||
| Nemotron 3 Ultra | 토큰 단위(리뷰의 해석) | PPO clip(비공개) × 학습/추론 log-prob ratio mask(비공개) | — | 비동기, 지연 ≤ 1 step; behaviour→proximal IS 가중치를 쓰는 MOPD 단계 | |
| DAPO | clip | — | dynamic sampling, overlong shaping | ||
| Dr. GRPO | PPO clip | — | — | ||
| GMPO | 시퀀스당 | 토큰별로 clip한 항의 기하평균, clip | — | — | |
| Qwen SAPO | 시퀀스, 이어서 그룹 | hard clip 대신 부드러운 sigmoid gate, , | — | — |
MAI 행의 경계는 엔진 ratio 와 겹치지 않도록 보고서의 controller 상태 를 로 썼다.
표 읽기
모두 같은 칸에 넣으면 네 가지 흐름이 보인다.
1. std 나눗셈이 사라지고 있다. DeepSeek은 R1과 V3.2 사이에 뺐고, Olmo 3, Kimi, MiMo-V2.6, GLM의 agentic 단계는 처음부터 없었다. 이진 보상에서 로 나누면 가 0이나 1 근처인 프롬프트가 무거워진다(유도). 이를 유지하는 랩(MAI, GLM-5, Nemotron)은 그런 프롬프트를 어차피 걸러 내는 필터와 함께 쓴다.
2. Token-mean 집계가 이겼다. 눈에 띄는 예외가 둘 있다. DAPO, MiMo, MiniMax, MAI, Olmo, K2.5, Nemotron은 전체 토큰 수로 나눈다. DeepSeek V3.2와 GLM-5의 추론 단계는 여전히 를 쓰고, GSPO의 시퀀스 ratio는 를 은근히 되살린다. MiMo-V2.6 본문은 바로 길이 증가를 늦춘다는 이유로 프롬프트별 평균을 택한다. 길이 편향은 무조건 없앨 버그가 아니라 손잡이다.
3. Reference KL은 거의 사라졌고, 에 묶는 것이 그 자리를 대신했다. Reference KL을 유지하는 곳은 DeepSeek뿐이다(그리고 추정량을 고쳤다). Kimi는 log-ratio에 대한 L2 패널티로 직전 정책에 묶는다. 나머지는 clip이나 mask가 유일한 닻이다. 검증 가능한 보상에서 이것이 왜 통하는지, 엔트로피 붕괴를 막던 KL의 역할을 무엇이 대신하는지는 정규화 레슨에서 다룬다.
4. 진짜 싸움은 ratio로 옮겨 갔다. 이제 ratio 하나에 세 가지 차이 — 정책 업데이트 , staleness, 엔진 불일치 — 가 숨어 있고, 각 랩은 무엇을 clip하고 무엇을 보정하고 무엇을 mask할지, 어떤 단위(토큰, 시퀀스, 의 부호)로 할지 고른다. Olmo는 엔진 차이용 TIS 가중치와 업데이트용 PPO clip을 곱한다. GLM-5 agentic과 MiMo-V2.6은 를 건너뛰고 전체에 band mask를 건다. V3.2는 음의 시퀀스만 mask한다. Clipping과 IS 레슨이 이 모두를 gradient 가중치 그림 하나에 올린다.
Advantage 칸: baseline의 한 가족
틀은 를 주어진 것으로 받지만, 이 칸이야말로 역사가 가장 길고 위 랩들의 선택은 그 한 구석일 뿐이다. critic 없는 추정량은 모두 보상에서 baseline을 빼고, 필요하면 크기를 다시 맞춘 것이다.
이므로 baseline은 자신에만 의존하지 않으면 gradient를 편향시키지 않는다. 프롬프트, 다른 샘플, 별도의 rollout에는 의존해도 된다. 크기 는 다르다. 프롬프트(또는 배치)마다의 무게를 바꾸고, 따라서 최적화하는 목적함수 자체를 바꾼다.
| 추정량 | Baseline | 크기 | 얻는 것 |
|---|---|---|---|
| GRPO (Shao et al. 2024) | 를 포함한 그룹 평균 | 그룹 std | 성공이 드문 프롬프트를 증폭; 이나 쪽으로 치우침 |
| Dr. GRPO (Liu et al. 2025) | 그룹 평균 | 1 | 프롬프트별 재가중 없는 GRPO 방향 |
| RLOO (Ahmadian et al. 2024) | 나머지 개의 평균 | 1 | 정확히 편향 없음; Dr. GRPO의 배 |
| REINFORCE++ (Hu et al. 2025) | 의 전역 배치 평균 | 전역 배치 std | 프롬프트당 샘플 하나; k1 KL을 return에 넣음 |
| REINFORCE++-baseline | 그룹 평균, 이어서 배치 평균 | 전역 배치 std | 그룹 baseline + 배치 단위 크기; KL은 별도 k2 손실 |
| ReMax (Li et al. 2024) | greedy 디코딩의 보상 | 1 | critic 대신 greedy rollout 하나 추가 |
| OPO (Hao et al. 2025) | 1 | gradient 크기가 길이에 비례할 때 분산을 최소화하는 baseline | |
| GPG (Chu et al. 2025) | 그룹 평균 | ( = advantage 0 그룹의 샘플 수) | surrogate·clip·KL·reference 없는 ; 죽은 그룹에 의한 희석을 되돌림 |
| pass@k advantage (Tang et al. 2025) | 그룹의 두 번째로 좋은 보상 | 1 | 개 샘플의 최댓값을 최적화: 가장 좋은 응답만 신호를 받음 |
| Optimal Token Baseline (Li et al. 2026) | 토큰마다: 가중치 로 평균한 reward-to-go | 1 | 긴 horizon에서 토큰 단위 분산 감소 |
그림은 이 가운데 여덟 개를 같은 두 프롬프트 위에 나란히 놓는다.
Three things to take from the figure. First, the baseline changes the direction only by a per-prompt constant (Dr. GRPO, RLOO and GPG are parallel within a group), while the scale changes how prompts are weighted against each other: GRPO’s std and REINFORCE++‘s batch std are choices about the objective, not about variance alone. Press “prompt B all correct”: GRPO, Dr. GRPO and RLOO give B nothing, GPG scales prompt A up by to keep the step size, and REINFORCE++-baseline’s batch std shrinks, so A’s advantages change even though nothing about A did. Second, ReMax can produce all-negative or all-zero advantages within a group (when the greedy answer is correct, every correct sample gets 0) — its baseline is a different rollout, not the group. Third, the pass@k advantage is the most selective: with binary rewards it is non-zero only when exactly one response is correct. It optimises the probability that at least one of samples succeeds, which is the right target when the model will be used with best-of- or a verifier, and the wrong one for pass@1.
Why OPO weights by length
When the reward is a single scalar per response, the gradient of response is , whose squared norm grows roughly in proportion to its length . Minimising over gives
which is OPO’s baseline (Hao et al. 2025, derived under the assumption that per-token score vectors are roughly independent with similar norm). When long responses are more often wrong, is lower than the mean reward. The block below checks this numerically.
import numpy as np
rng = np.random.default_rng(1)
# A "response" of length l has score ∇log π(y) = Σ_t s_t with s_t ~ N(0, I_d) independent,
# so E‖∇log π(y)‖² = l·d: long responses carry bigger gradients. Reward correlates with length.
d, n = 8, 4000
l = rng.choice([200, 400, 800, 1600, 3200], size=n, p=[.25, .25, .2, .2, .1])
p_correct = np.interp(np.log(l), np.log([200, 3200]), [0.7, 0.2]) # long = more often wrong
r = (rng.random(n) < p_correct).astype(float)
score = rng.normal(size=(n, d)) * np.sqrt(l)[:, None] # Σ_t s_t has variance l per dim
def grad_var(b):
g = (r - b)[:, None] * score # one-sample gradient estimates
return ((g - g.mean(0)) ** 2).sum(1).mean() # trace of the covariance
b_mean = r.mean()
b_opo = (l * r).sum() / l.sum() # OPO: length-weighted baseline
bs = np.linspace(0, 1, 201)
b_best = bs[np.argmin([grad_var(b) for b in bs])]
print(f"mean reward baseline b = {b_mean:.3f} var = {grad_var(b_mean):9.1f}")
print(f"OPO baseline Σ l r / Σ l b = {b_opo:.3f} var = {grad_var(b_opo):9.1f}")
print(f"grid-search minimum b = {b_best:.3f} var = {grad_var(b_best):9.1f}")
print(f"no baseline b = 0.000 var = {grad_var(0.0):9.1f}")
# The critic-free estimators on one group (G = 6), as functions of rewards (and lengths).
def estimators(r, lens, r_greedy):
G = len(r); m = r.mean()
out = {
"GRPO": (r - m) / (r.std() + 1e-6),
"Dr.GRPO": r - m,
"RLOO": r - (r.sum() - r) / (G - 1),
"ReMax": r - r_greedy,
"OPO": r - (lens * r).sum() / lens.sum(),
}
top = np.argsort(-r, kind="stable")
pk = np.zeros(G); pk[top[0]] = r[top[0]] - r[top[1]] # pass@k: only the best sample
out["pass@k"] = pk
return out
r6 = np.array([1., 0., 1., 0., 0., 1.]); l6 = np.array([220, 900, 400, 1500, 300, 650])
print()
for k, v in estimators(r6, l6, r_greedy=1.0).items():
print(f"{k:8s}", np.round(v, 2))
r1 = np.array([0., 0., 1., 0., 0., 0.])
print("one correct → pass@k:", estimators(r1, l6, 0.0)["pass@k"], " GRPO:", np.round(estimators(r1, l6, 0.0)["GRPO"], 2))The grid-search minimum lands on the OPO baseline (about 0.33 against a mean reward of 0.49), cutting the gradient variance by about 9% relative to the mean baseline here. The gain is larger when lengths are more spread out and more strongly correlated with the reward, which is exactly the long-reasoning regime.
The critic-based branch
Before group baselines, the advantage came from a learned value function through GAE (Schulman et al. 2015), with (see actor-critic). With a reward only at the end of a long chain of thought, two things go wrong. VC-PPO (Yuan et al. 2025) traced PPO’s collapse on long CoT to the value model’s initialisation bias: with the early tokens’ advantages are dominated by a critic that has not learned yet. Its fixes are to pretrain the value model on a fixed policy and to decouple : (an unbiased Monte Carlo target for the value) and . VAPO (Yue et al. 2025) makes the policy’s length-adaptive, with , so that a 2,000-token response bootstraps less (λ ≈ 0.99) than a 100-token one (λ = 0.8). The frontier labs in the table all chose the critic-free branch, but per-token advantages are coming back through other doors: reward-to-go minus a baseline (MiniMax-M2), the Optimal Token Baseline, and dense teacher log-ratios in on-policy distillation.
Two older tools complete the picture. PF-PPO (Zhang et al. 2025) does not change the estimator at all; it filters which samples enter the batch, keeping the reward-model ranks where the RM is reliable (e.g. best and worst of ). And the adaptive KL controller of Ziegler et al. (2019) moves multiplicatively toward a target KL; it belongs to the regulariser slot and is treated in the regularisation lesson.
Bias and variance across objectives
Every clip or mask trades bias for variance: it removes or caps exactly the tokens with extreme ratios, which are the tokens that would dominate the update. The next figure sweeps the policy drift and plots two batch statistics for every objective: the share of tokens whose gradient was removed (what the objective refuses to learn from) and the effective sample size of the weights (how many tokens effectively contribute).
그림에서 가져갈 것 셋. 첫째, baseline은 프롬프트마다 상수만큼만 방향을 바꾸지만(그룹 안에서 Dr. GRPO, RLOO, GPG는 평행하다), 크기는 프롬프트끼리의 무게를 바꾼다. GRPO의 std와 REINFORCE++의 배치 std는 분산만이 아니라 목적함수에 관한 선택이다. “프롬프트 B 모두 정답”을 눌러 보라. GRPO, Dr. GRPO, RLOO는 B에 아무것도 주지 않고, GPG는 step 크기를 지키려고 프롬프트 A를 배로 키우며, REINFORCE++-baseline은 배치 std가 줄어서 A에 대해 아무것도 바뀌지 않았는데도 A의 advantage가 바뀐다. 둘째, ReMax는 그룹 안에서 모두 음수이거나 모두 0인 advantage를 만들 수 있다(greedy 답이 맞으면 맞은 샘플은 모두 0). baseline이 그룹이 아니라 다른 rollout이기 때문이다. 셋째, pass@k advantage가 가장 까다롭다. 이진 보상에서는 정확히 하나만 맞았을 때만 0이 아니다. 개 중 적어도 하나가 성공할 확률을 최적화하므로, 모델을 best-of-나 verifier와 함께 쓸 때는 맞는 목표이고 pass@1에는 틀린 목표다.
OPO가 길이로 가중하는 이유
보상이 응답마다 스칼라 하나이면 응답 의 gradient는 이고, 그 제곱 노름은 대략 길이 에 비례해 커진다. 을 에 대해 최소화하면
이것이 OPO의 baseline이다(Hao et al. 2025, 토큰별 score 벡터가 대략 독립이고 노름이 비슷하다는 가정 아래 유도). 긴 응답이 더 자주 틀리면 는 평균 보상보다 낮다. 아래 블록이 수치로 확인한다.
import numpy as np
rng = np.random.default_rng(1)
# 길이 l인 "응답"의 score ∇log π(y) = Σ_t s_t, s_t ~ N(0, I_d) 독립
# → E‖∇log π(y)‖² = l·d: 긴 응답일수록 gradient가 크다. 보상은 길이와 상관된다.
d, n = 8, 4000
l = rng.choice([200, 400, 800, 1600, 3200], size=n, p=[.25, .25, .2, .2, .1])
p_correct = np.interp(np.log(l), np.log([200, 3200]), [0.7, 0.2]) # 길수록 자주 틀림
r = (rng.random(n) < p_correct).astype(float)
score = rng.normal(size=(n, d)) * np.sqrt(l)[:, None] # Σ_t s_t의 차원별 분산 = l
def grad_var(b):
g = (r - b)[:, None] * score # 샘플 하나짜리 gradient 추정
return ((g - g.mean(0)) ** 2).sum(1).mean() # 공분산의 trace
b_mean = r.mean()
b_opo = (l * r).sum() / l.sum() # OPO: 길이 가중 baseline
bs = np.linspace(0, 1, 201)
b_best = bs[np.argmin([grad_var(b) for b in bs])]
print(f"mean reward baseline b = {b_mean:.3f} var = {grad_var(b_mean):9.1f}")
print(f"OPO baseline Σ l r / Σ l b = {b_opo:.3f} var = {grad_var(b_opo):9.1f}")
print(f"grid-search minimum b = {b_best:.3f} var = {grad_var(b_best):9.1f}")
print(f"no baseline b = 0.000 var = {grad_var(0.0):9.1f}")
# 그룹 하나(G = 6)에서 critic 없는 추정량들 — 보상(과 길이)의 함수
def estimators(r, lens, r_greedy):
G = len(r); m = r.mean()
out = {
"GRPO": (r - m) / (r.std() + 1e-6),
"Dr.GRPO": r - m,
"RLOO": r - (r.sum() - r) / (G - 1),
"ReMax": r - r_greedy,
"OPO": r - (lens * r).sum() / lens.sum(),
}
top = np.argsort(-r, kind="stable")
pk = np.zeros(G); pk[top[0]] = r[top[0]] - r[top[1]] # pass@k: 가장 좋은 샘플만
out["pass@k"] = pk
return out
r6 = np.array([1., 0., 1., 0., 0., 1.]); l6 = np.array([220, 900, 400, 1500, 300, 650])
print()
for k, v in estimators(r6, l6, r_greedy=1.0).items():
print(f"{k:8s}", np.round(v, 2))
r1 = np.array([0., 0., 1., 0., 0., 0.])
print("one correct → pass@k:", estimators(r1, l6, 0.0)["pass@k"], " GRPO:", np.round(estimators(r1, l6, 0.0)["GRPO"], 2))격자 탐색의 최솟값이 OPO baseline(평균 보상 0.49에 대해 약 0.33)에 떨어지고, 여기서는 평균 baseline보다 gradient 분산이 9%쯤 줄어든다. 길이가 더 넓게 퍼져 있고 보상과 더 강하게 상관될수록 이득이 크다. 바로 긴 추론의 영역이다.
Critic을 쓰는 갈래
그룹 baseline 이전에는 학습한 가치함수에서 GAE(Schulman et al. 2015)로 advantage를 얻었다. , (actor-critic 참고). 보상이 긴 chain of thought의 끝에만 있으면 두 가지가 어긋난다. VC-PPO(Yuan et al. 2025)는 긴 CoT에서 PPO가 무너지는 원인을 가치 모델의 초기화 편향에서 찾았다. 이면 앞쪽 토큰의 advantage가 아직 배우지 못한 critic에 지배된다. 해법은 고정된 정책으로 가치 모델을 먼저 학습시키고 를 분리하는 것이다. (가치에 대한 편향 없는 Monte Carlo 목표), . VAPO(Yue et al. 2025)는 정책의 를 길이에 맞춘다. , 이므로 2,000토큰 응답은 100토큰 응답(λ = 0.8)보다 덜 bootstrap한다(λ ≈ 0.99). 표의 프론티어 랩은 모두 critic 없는 갈래를 골랐지만, 토큰 단위 advantage는 다른 문으로 돌아오고 있다. reward-to-go − baseline(MiniMax-M2), Optimal Token Baseline, on-policy distillation의 dense한 teacher log-ratio다.
오래된 도구 둘이 그림을 채운다. PF-PPO(Zhang et al. 2025)는 추정량을 전혀 바꾸지 않는다. 보상모델이 믿을 만한 순위(예: 개 중 최고와 최저)만 남기도록 배치에 들어갈 샘플을 거른다. Ziegler et al.(2019)의 적응형 KL controller는 목표 KL 쪽으로 를 곱셈으로 움직인다. 정규화 칸에 속하며 정규화 레슨에서 다룬다.
목적함수별 bias와 variance
모든 clip과 mask는 bias를 내주고 variance를 산다. ratio가 극단적인 토큰, 즉 업데이트를 좌우했을 토큰을 정확히 지우거나 누른다. 다음 그림은 정책 이동을 키우며 모든 목적함수에 대해 배치 통계 둘을 그린다. gradient가 지워진 토큰의 비율(목적함수가 배우기를 거부하는 몫)과 가중치의 effective sample size(실제로 기여하는 토큰이 몇 개인가)다.
At zero drift every curve on the left sits at 0 — on the first minibatch and no PPO clip can fire — except for the rules that look at the rollout engine (IcePop, V3.2’s sequence mask, the bands of MiMo-V2.6 and GLM-5 agentic), which react to the engine mismatch even then. As drift grows, the curves separate by unit and bound: GSPO’s tiny sequence-level removes whole responses early; DAPO-style token clips remove a growing slice of tokens; CISPO and Kimi k1.5 remove nothing. On the right, the objectives that remove nothing pay with a lower effective sample size: a few tokens with large carry the step. There is no free lunch in this figure, only a choice of where to stand. Which point is right depends on how off-policy the data is, which is why the labs with the most asynchronous pipelines (MAI with rollouts up to 40 gradient steps stale, MiMo-V2.6 with staleness 4) use far wider bounds than the 0.2 of the textbook clip.
Implementing it
The block below writes eleven objectives the way their reports write them, as functions of the sampled tokens’ log-probs , and differentiates them numerically. It then computes from the template with the slots filled in, and checks that the two agree. It is the strongest form of the claim “they are all one family”: not an analogy, the same numbers.
import numpy as np
rng = np.random.default_rng(0)
# ---- one synthetic group: G responses, per-token log-probs under four distributions ----
G, L_MAX = 6, 64
lens = np.array([12, 40, 20, 60, 8, 30])
r = np.array([1., 0., 1., 0., 0., 1.])
seg = np.repeat(np.arange(G), lens).astype(np.intp) # response id of every token
N = int(lens.sum())
l_old = np.log(rng.uniform(0.05, 0.95, N)) # log π_old (trainer, θ_old)
l_mu = l_old + rng.normal(0, 0.15, N) # log μ (rollout engine)
l_th = l_old + rng.normal(0, 0.25, N) # log π_θ (after a few updates)
l_ref = l_old + rng.normal(-0.05, 0.2, N) # log π_ref
def adv(kind):
m = r.mean()
return {"std": (r - m) / (r.std() + 1e-6), "mean": r - m}[kind]
def seg_mean(x): # per-response mean of a per-token array
return np.bincount(seg, weights=x, minlength=G) / lens
def ppo(rho, A, lo, hi): # PPO clipped surrogate
return np.minimum(rho * A, np.clip(rho, lo, hi) * A)
# ---- literal objectives J(ℓ) as the reports write them; ℓ = log π_θ of the sampled tokens.
# Quantities inside sg[·] and masks are evaluated at the sampled θ (l_th) and held fixed.
def J(l, name):
rho = np.exp(l - l_old); k = np.exp(l_old - l_mu); A = adv("std")[seg]; A0 = adv("mean")[seg]
if name == "GRPO":
k3 = np.exp(l_ref - l) - (l_ref - l) - 1
return seg_mean(ppo(rho, A, 0.8, 1.2) - 1e-3 * k3).mean()
if name == "DAPO": return ppo(rho, A, 0.8, 1.28).sum() / N
if name == "Dr.GRPO": return ppo(rho, A0, 0.8, 1.2).sum() / (G * L_MAX)
if name == "V3.2":
M = ~((A0 < 0) & (seg_mean(l_mu - l_th)[seg] > 0.05))
kl = rho * (np.exp(l_ref - l) - (l_ref - l) - 1)
return seg_mean(ppo(rho, A0, 0.8, 1.2) * M - 1e-3 * kl).mean()
if name == "GSPO":
s = np.exp(seg_mean(l - l_old))
return ppo(s, adv("std"), 1 - 3e-4, 1 + 4e-4).mean()
if name == "k1.5": # −(1/2τ)·mean_i (r − r̄ − τ log π/π_old)²
tau = 0.1; X = np.bincount(seg, weights=l - l_old, minlength=G)
return -((adv("mean") - tau * X) ** 2).mean() / (2 * tau)
if name == "K2.5":
tau = 0.05; lr0 = l_th - l_old; M = (lr0 > -0.3) & (lr0 < 0.3)
return (M * rho * A0 - tau * (l - l_old) ** 2).sum() / N
if name == "CISPO":
w = np.clip(np.exp(l_th - l_old), 0, 2.0)
return (w * A * l).sum() / N
if name == "GLM-5":
pop = np.where((k >= 0.5) & (k <= 2), k, 0.0)
return seg_mean(pop * ppo(rho, A, 0.8, 1.28)).mean()
if name == "Olmo 3": return (np.minimum(k, 2.0) * ppo(rho, A0, 0.8, 1.272)).sum() / N
if name == "MAI":
keep = np.exp(l_th - l_old) <= 50
return (keep * ppo(rho, A, 0.4, 1 / 0.4 + 1.0)).sum() / N
raise ValueError(name)
# ---- the ONE template: w_{i,t} = c_i · [ g(ratio, A, clip/mask) · IS − regulariser ] ----
def template(name):
rho = np.exp(l_th - l_old); k = np.exp(l_old - l_mu); A = adv("std")[seg]; A0 = adv("mean")[seg]
inside = lambda R, A, lo, hi: np.where(A >= 0, R <= hi, R >= lo) # PPO: is the gradient alive?
c_seq, c_tok = 1 / (G * lens[seg]), 1 / N
if name == "GRPO": return c_seq * (inside(rho, A, .8, 1.2) * rho * A - 1e-3 * (1 - np.exp(l_ref - l_th)))
if name == "DAPO": return c_tok * inside(rho, A, .8, 1.28) * rho * A
if name == "Dr.GRPO": return inside(rho, A0, .8, 1.2) * rho * A0 / (G * L_MAX)
if name == "V3.2":
M = ~((A0 < 0) & (seg_mean(l_mu - l_th)[seg] > 0.05))
return c_seq * (M * inside(rho, A0, .8, 1.2) * rho * A0 - 1e-3 * rho * (l_th - l_ref))
if name == "GSPO":
s = np.exp(seg_mean(l_th - l_old)); a = adv("std")
return (inside(s, a, 1 - 3e-4, 1 + 4e-4) * s * a / G)[seg] / lens[seg]
if name == "k1.5":
X = np.bincount(seg, weights=l_th - l_old, minlength=G)
return ((adv("mean") - 0.1 * X) / G)[seg]
if name == "K2.5":
lr0 = l_th - l_old; M = (lr0 > -0.3) & (lr0 < 0.3)
return c_tok * (M * rho * A0 - 2 * 0.05 * lr0)
if name == "CISPO": return c_tok * np.clip(rho, 0, 2.0) * A
if name == "GLM-5": return c_seq * np.where((k >= .5) & (k <= 2), k, 0) * inside(rho, A, .8, 1.28) * rho * A
if name == "Olmo 3": return c_tok * np.minimum(k, 2) * inside(rho, A0, .8, 1.272) * rho * A0
if name == "MAI": return c_tok * (rho <= 50) * inside(rho, A, .4, 1 / .4 + 1) * rho * A
def num_grad(name, h=1e-6): # ∂J/∂ℓ_t by central differences
g = np.zeros(N)
for t in range(N):
e = np.zeros(N); e[t] = h
g[t] = (J(l_th + e, name) - J(l_th - e, name)) / (2 * h)
return g
print(f"{'objective':9s} {'rel. error':>11s} {'zeroed':>7s} {'Σw(A>0)':>9s} {'Σw(A<0)':>9s}")
for name in ["GRPO", "DAPO", "Dr.GRPO", "V3.2", "GSPO", "k1.5", "K2.5", "CISPO", "GLM-5", "Olmo 3", "MAI"]:
w, g = template(name), num_grad(name)
pos = r[seg] > r.mean()
print(f"{name:9s} {np.abs(w - g).max() / np.abs(g).max():11.1e} {np.mean(np.abs(w) < 1e-12):7.2f}"
f" {w[pos].sum():9.4f} {w[~pos].sum():9.4f}")Every relative error is around , i.e. finite-difference noise. Three things in the last columns are worth a second look. GRPO, V3.2 and K2.5 never show zeroed tokens even where their clip or mask fires, because the regulariser keeps a small gradient alive on every token; when you log a “clip fraction” for these objectives, log the policy-gradient part separately. GSPO zeroes 40% of tokens here because three responses are out of its -wide band as whole units. And k1.5’s totals are an order of magnitude larger than the others: with no length normalisation, the sequence log-ratio and its gradient both scale with , so its learning rate lives on a different scale.
In a real trainer the same template becomes one loss function with switches. The version below takes the three log-prob tensors a modern RL stack has — current, recomputed old, and rollout-engine — and expresses every row of the table by its arguments.
import torch
def frontier_pg_loss(logp, old_logp, rollout_logp, adv, mask, *,
ratio="token", # "token" | "seq_geo" (GSPO) | "rollout" (π_θ/μ directly)
clip="ppo", # "ppo" | "dual" | "cispo" | "band" | "none"
eps_low=0.2, eps_high=0.28, dual_c=3.0, band=(0.5, 2.0),
is_corr="none", # "none" | "tis" | "icepop"
tis_cap=2.0, icepop_band=(0.5, 2.0),
agg="token_mean", # "token_mean" | "seq_mean" | "const"
L_max=None, ref_logp=None, kl="none", beta=0.0):
"""logp: (B,T) current policy with grad; old_logp: (B,T) trainer recompute at θ_old;
rollout_logp: (B,T) sampler log-probs μ; adv: (B,) sequence advantage; mask: (B,T) 1 on model tokens."""
m = mask.float()
A = adv[:, None].expand_as(logp)
if ratio == "seq_geo": # GSPO: s_i = exp(mean_t log ρ_t)
log_s = ((logp - old_logp) * m).sum(1, keepdim=True) / m.sum(1, keepdim=True).clamp(min=1)
R = torch.exp(log_s).expand_as(logp)
elif ratio == "rollout": # MiMo-V2.6 / GLM-5 agentic
R = torch.exp(logp - rollout_logp)
else:
R = torch.exp(logp - old_logp)
if clip in ("ppo", "dual"):
surr = torch.minimum(R * A, R.clamp(1 - eps_low, 1 + eps_high) * A)
if clip == "dual": # A<0: bound the loss at c·A
surr = torch.where(A < 0, torch.maximum(surr, dual_c * A), surr)
elif clip == "cispo": # weight capped, gradient kept
surr = R.clamp(max=1 + eps_high).detach() * A * logp
elif clip == "band": # zero outside the band, either sign
keep = ((R >= band[0]) & (R <= band[1])).float().detach()
surr = keep * R.detach() * A * logp
else:
surr = R * A
k = torch.exp(old_logp - rollout_logp).detach() # engine ratio π_old/μ
if is_corr == "tis":
surr = k.clamp(max=tis_cap) * surr
elif is_corr == "icepop":
surr = torch.where((k >= icepop_band[0]) & (k <= icepop_band[1]), k, torch.zeros_like(k)) * surr
per_tok = -surr
if kl != "none":
log_r = ref_logp - logp # log π_ref/π_θ
k3 = torch.exp(log_r) - log_r - 1
if kl == "k3_is": # DeepSeek-V3.2: ρ·k3, unbiased
k3 = torch.exp(logp - old_logp) * k3
per_tok = per_tok + beta * k3
if agg == "seq_mean":
return ((per_tok * m).sum(1) / m.sum(1).clamp(min=1)).mean()
if agg == "const":
return (per_tok * m).sum() / (m.shape[0] * L_max)
return (per_tok * m).sum() / m.sum().clamp(min=1) # token mean; all-reduce m.sum() under DPTwo details matter in practice. Under data parallelism, m.sum() in the token-mean must be the global token count (MAI defines its normaliser over the global batch); dividing by each rank’s local count silently reweights ranks with short responses. And the "rollout" ratio uses the sampler’s log-probs directly, which saves the recompute pass but means one ratio carries the update, staleness and engine noise at once — the reason GLM-5 says its band must be tight.
A new paper proposes the loss −(1/Σ|y|) Σ sg[min(ρ, 2)]·A·log π. Which row of the table is it?
Its per-token weight is : token-mean aggregation, the policy ratio capped at , gradient never zeroed. That is CISPO. Olmo’s TIS cap of 2 applies to the engine ratio and is multiplied with a PPO clip that does zero gradients; DAPO zeroes tokens with when .
In the figure, why does GSPO zero whole responses while DAPO zeroes scattered tokens?
GSPO computes and clips it, so the in/out decision is made once per response and every token of the response shares the weight . Its is much smaller () because the geometric mean has a far smaller spread than single-token ratios.
Summary
- For a fixed batch, any LLM policy-gradient objective is fully described by its per-token weight , and every frontier objective factors into aggregation × (ratio + clip/mask) × IS correction × advantage − regulariser.
- PPO-style clips zero the gradient of a token; stop-gradient weights (CISPO, MiMo-V2.6, GLM-5 agentic) cap it instead. Masks (IcePop, V3.2, K2.5) zero it based on a different ratio or a different unit.
- Across labs: std normalisation is fading, token-mean aggregation dominates, the reference KL has mostly been replaced by anchoring to , and the design effort now goes into how the three gaps hidden in the ratio (update, staleness, engine mismatch) are clipped, corrected or masked.
- Every clip or mask trades bias (tokens it refuses to learn from) for variance (tokens that would dominate the step); the right trade depends on how off-policy the data is.
- The advantage slot is a baseline plus a scale: the baseline (group mean, leave-one-out, greedy, length-weighted, second-best, per-token) affects variance, the scale (group std, batch std, GPG’s rescale) changes which objective is optimised.
- The template leaves out batch selection, rewards and systems fixes; those are the other half of stability.
이동이 0이면 왼쪽의 모든 곡선은 0이다. 첫 minibatch에서는 이라 PPO clip이 작동할 수 없다. rollout 엔진을 보는 규칙(IcePop, V3.2의 시퀀스 mask, MiMo-V2.6과 GLM-5 agentic의 band)만 예외인데, 그때도 엔진 불일치에 반응한다. 이동이 커지면 곡선이 단위와 경계로 갈린다. GSPO의 아주 작은 시퀀스 단위 은 일찍부터 응답 전체를 지운다. DAPO 계열 토큰 clip은 점점 늘어나는 토큰 조각을 지운다. CISPO와 Kimi k1.5는 아무것도 지우지 않는다. 오른쪽을 보면, 아무것도 지우지 않는 목적함수는 낮은 effective sample size로 값을 치른다. 가 큰 소수 토큰이 한 step을 끌고 간다. 이 그림에 공짜 점심은 없고 어디 설지 선택만 있다. 어느 점이 맞는지는 데이터가 얼마나 off-policy인지에 달렸다. 그래서 파이프라인이 가장 비동기적인 랩(rollout이 gradient step 40까지 stale한 MAI, staleness 4인 MiMo-V2.6)은 교과서 clip의 0.2보다 훨씬 넓은 경계를 쓴다.
구현
아래 블록은 열한 목적함수를 보고서가 쓴 그대로 샘플 토큰 log-prob 의 함수로 적고 수치 미분한다. 그리고 칸을 채운 틀로 를 계산해 둘이 같은지 확인한다. “모두 한 가족”이라는 주장의 가장 강한 형태다. 비유가 아니라 같은 숫자다.
import numpy as np
rng = np.random.default_rng(0)
# ---- 합성 그룹 하나: 응답 G개, 네 분포 아래의 토큰별 log-prob ----
G, L_MAX = 6, 64
lens = np.array([12, 40, 20, 60, 8, 30])
r = np.array([1., 0., 1., 0., 0., 1.])
seg = np.repeat(np.arange(G), lens).astype(np.intp) # 토큰마다 응답 번호
N = int(lens.sum())
l_old = np.log(rng.uniform(0.05, 0.95, N)) # log π_old (학습기, θ_old)
l_mu = l_old + rng.normal(0, 0.15, N) # log μ (rollout 엔진)
l_th = l_old + rng.normal(0, 0.25, N) # log π_θ (몇 번 업데이트한 뒤)
l_ref = l_old + rng.normal(-0.05, 0.2, N) # log π_ref
def adv(kind):
m = r.mean()
return {"std": (r - m) / (r.std() + 1e-6), "mean": r - m}[kind]
def seg_mean(x): # 토큰 배열의 응답별 평균
return np.bincount(seg, weights=x, minlength=G) / lens
def ppo(rho, A, lo, hi): # PPO clipped surrogate
return np.minimum(rho * A, np.clip(rho, lo, hi) * A)
# ---- 보고서가 쓴 그대로의 목적함수 J(ℓ); ℓ = 샘플 토큰의 log π_θ.
# sg[·] 안의 값과 mask는 샘플 시점 θ(l_th)에서 계산해 고정한다.
def J(l, name):
rho = np.exp(l - l_old); k = np.exp(l_old - l_mu); A = adv("std")[seg]; A0 = adv("mean")[seg]
if name == "GRPO":
k3 = np.exp(l_ref - l) - (l_ref - l) - 1
return seg_mean(ppo(rho, A, 0.8, 1.2) - 1e-3 * k3).mean()
if name == "DAPO": return ppo(rho, A, 0.8, 1.28).sum() / N
if name == "Dr.GRPO": return ppo(rho, A0, 0.8, 1.2).sum() / (G * L_MAX)
if name == "V3.2":
M = ~((A0 < 0) & (seg_mean(l_mu - l_th)[seg] > 0.05))
kl = rho * (np.exp(l_ref - l) - (l_ref - l) - 1)
return seg_mean(ppo(rho, A0, 0.8, 1.2) * M - 1e-3 * kl).mean()
if name == "GSPO":
s = np.exp(seg_mean(l - l_old))
return ppo(s, adv("std"), 1 - 3e-4, 1 + 4e-4).mean()
if name == "k1.5": # −(1/2τ)·mean_i (r − r̄ − τ log π/π_old)²
tau = 0.1; X = np.bincount(seg, weights=l - l_old, minlength=G)
return -((adv("mean") - tau * X) ** 2).mean() / (2 * tau)
if name == "K2.5":
tau = 0.05; lr0 = l_th - l_old; M = (lr0 > -0.3) & (lr0 < 0.3)
return (M * rho * A0 - tau * (l - l_old) ** 2).sum() / N
if name == "CISPO":
w = np.clip(np.exp(l_th - l_old), 0, 2.0)
return (w * A * l).sum() / N
if name == "GLM-5":
pop = np.where((k >= 0.5) & (k <= 2), k, 0.0)
return seg_mean(pop * ppo(rho, A, 0.8, 1.28)).mean()
if name == "Olmo 3": return (np.minimum(k, 2.0) * ppo(rho, A0, 0.8, 1.272)).sum() / N
if name == "MAI":
keep = np.exp(l_th - l_old) <= 50
return (keep * ppo(rho, A, 0.4, 1 / 0.4 + 1.0)).sum() / N
raise ValueError(name)
# ---- 하나의 틀: w_{i,t} = c_i · [ g(ratio, A, clip/mask) · IS − 정규화 항 ] ----
def template(name):
rho = np.exp(l_th - l_old); k = np.exp(l_old - l_mu); A = adv("std")[seg]; A0 = adv("mean")[seg]
inside = lambda R, A, lo, hi: np.where(A >= 0, R <= hi, R >= lo) # PPO: gradient가 살아 있나?
c_seq, c_tok = 1 / (G * lens[seg]), 1 / N
if name == "GRPO": return c_seq * (inside(rho, A, .8, 1.2) * rho * A - 1e-3 * (1 - np.exp(l_ref - l_th)))
if name == "DAPO": return c_tok * inside(rho, A, .8, 1.28) * rho * A
if name == "Dr.GRPO": return inside(rho, A0, .8, 1.2) * rho * A0 / (G * L_MAX)
if name == "V3.2":
M = ~((A0 < 0) & (seg_mean(l_mu - l_th)[seg] > 0.05))
return c_seq * (M * inside(rho, A0, .8, 1.2) * rho * A0 - 1e-3 * rho * (l_th - l_ref))
if name == "GSPO":
s = np.exp(seg_mean(l_th - l_old)); a = adv("std")
return (inside(s, a, 1 - 3e-4, 1 + 4e-4) * s * a / G)[seg] / lens[seg]
if name == "k1.5":
X = np.bincount(seg, weights=l_th - l_old, minlength=G)
return ((adv("mean") - 0.1 * X) / G)[seg]
if name == "K2.5":
lr0 = l_th - l_old; M = (lr0 > -0.3) & (lr0 < 0.3)
return c_tok * (M * rho * A0 - 2 * 0.05 * lr0)
if name == "CISPO": return c_tok * np.clip(rho, 0, 2.0) * A
if name == "GLM-5": return c_seq * np.where((k >= .5) & (k <= 2), k, 0) * inside(rho, A, .8, 1.28) * rho * A
if name == "Olmo 3": return c_tok * np.minimum(k, 2) * inside(rho, A0, .8, 1.272) * rho * A0
if name == "MAI": return c_tok * (rho <= 50) * inside(rho, A, .4, 1 / .4 + 1) * rho * A
def num_grad(name, h=1e-6): # 중앙 차분으로 ∂J/∂ℓ_t
g = np.zeros(N)
for t in range(N):
e = np.zeros(N); e[t] = h
g[t] = (J(l_th + e, name) - J(l_th - e, name)) / (2 * h)
return g
print(f"{'objective':9s} {'rel. error':>11s} {'zeroed':>7s} {'Σw(A>0)':>9s} {'Σw(A<0)':>9s}")
for name in ["GRPO", "DAPO", "Dr.GRPO", "V3.2", "GSPO", "k1.5", "K2.5", "CISPO", "GLM-5", "Olmo 3", "MAI"]:
w, g = template(name), num_grad(name)
pos = r[seg] > r.mean()
print(f"{name:9s} {np.abs(w - g).max() / np.abs(g).max():11.1e} {np.mean(np.abs(w) < 1e-12):7.2f}"
f" {w[pos].sum():9.4f} {w[~pos].sum():9.4f}")모든 상대 오차가 근처, 즉 유한 차분의 잡음이다. 마지막 열에서 세 가지를 다시 볼 만하다. GRPO, V3.2, K2.5는 clip이나 mask가 작동하는 곳에서도 0이 된 토큰이 없다. 정규화 항이 모든 토큰에 작은 gradient를 남기기 때문이다. 이런 목적함수의 “clip 비율”을 기록할 때는 policy-gradient 부분을 따로 기록하라. GSPO는 여기서 토큰의 40%를 0으로 만든다. 응답 셋이 폭 인 band 밖에 통째로 있기 때문이다. 그리고 k1.5의 합계는 다른 것보다 한 자릿수 크다. 길이 정규화가 없으니 시퀀스 log-ratio와 그 gradient가 모두 에 비례해 커지고, 학습률이 다른 눈금 위에 있게 된다.
실제 학습기에서는 같은 틀이 스위치 달린 손실 함수 하나가 된다. 아래 버전은 요즘 RL 스택이 가진 세 log-prob 텐서 — 현재, 다시 계산한 old, rollout 엔진 — 를 받아 표의 모든 행을 인자로 표현한다.
import torch
def frontier_pg_loss(logp, old_logp, rollout_logp, adv, mask, *,
ratio="token", # "token" | "seq_geo" (GSPO) | "rollout" (π_θ/μ를 바로 사용)
clip="ppo", # "ppo" | "dual" | "cispo" | "band" | "none"
eps_low=0.2, eps_high=0.28, dual_c=3.0, band=(0.5, 2.0),
is_corr="none", # "none" | "tis" | "icepop"
tis_cap=2.0, icepop_band=(0.5, 2.0),
agg="token_mean", # "token_mean" | "seq_mean" | "const"
L_max=None, ref_logp=None, kl="none", beta=0.0):
"""logp: (B,T) gradient가 흐르는 현재 정책; old_logp: (B,T) θ_old에서 학습기가 다시 계산;
rollout_logp: (B,T) 샘플러 log-prob μ; adv: (B,) 시퀀스 advantage; mask: (B,T) 모델 토큰에 1."""
m = mask.float()
A = adv[:, None].expand_as(logp)
if ratio == "seq_geo": # GSPO: s_i = exp(mean_t log ρ_t)
log_s = ((logp - old_logp) * m).sum(1, keepdim=True) / m.sum(1, keepdim=True).clamp(min=1)
R = torch.exp(log_s).expand_as(logp)
elif ratio == "rollout": # MiMo-V2.6 / GLM-5 agentic
R = torch.exp(logp - rollout_logp)
else:
R = torch.exp(logp - old_logp)
if clip in ("ppo", "dual"):
surr = torch.minimum(R * A, R.clamp(1 - eps_low, 1 + eps_high) * A)
if clip == "dual": # A<0: 손실을 c·A에서 막음
surr = torch.where(A < 0, torch.maximum(surr, dual_c * A), surr)
elif clip == "cispo": # 가중치만 상한, gradient 유지
surr = R.clamp(max=1 + eps_high).detach() * A * logp
elif clip == "band": # band 밖이면 부호와 무관하게 0
keep = ((R >= band[0]) & (R <= band[1])).float().detach()
surr = keep * R.detach() * A * logp
else:
surr = R * A
k = torch.exp(old_logp - rollout_logp).detach() # 엔진 ratio π_old/μ
if is_corr == "tis":
surr = k.clamp(max=tis_cap) * surr
elif is_corr == "icepop":
surr = torch.where((k >= icepop_band[0]) & (k <= icepop_band[1]), k, torch.zeros_like(k)) * surr
per_tok = -surr
if kl != "none":
log_r = ref_logp - logp # log π_ref/π_θ
k3 = torch.exp(log_r) - log_r - 1
if kl == "k3_is": # DeepSeek-V3.2: ρ·k3, 편향 없음
k3 = torch.exp(logp - old_logp) * k3
per_tok = per_tok + beta * k3
if agg == "seq_mean":
return ((per_tok * m).sum(1) / m.sum(1).clamp(min=1)).mean()
if agg == "const":
return (per_tok * m).sum() / (m.shape[0] * L_max)
return (per_tok * m).sum() / m.sum().clamp(min=1) # token mean; DP에서는 m.sum()을 all-reduce실전에서 중요한 세부 둘. Data parallel에서는 token-mean의 m.sum()이 전역 토큰 수여야 한다(MAI는 정규화 분모를 전역 배치로 정의한다). 랭크마다 자기 토큰 수로 나누면 짧은 응답을 가진 랭크의 가중치가 조용히 바뀐다. 그리고 "rollout" ratio는 샘플러의 log-prob을 바로 써서 재계산 패스를 아끼지만, ratio 하나가 업데이트, staleness, 엔진 잡음을 한꺼번에 싣는다. GLM-5가 band를 좁게 잡아야 한다고 말하는 이유다.
새 논문이 −(1/Σ|y|) Σ sg[min(ρ, 2)]·A·log π 손실을 제안했다. 표의 어느 행인가?
토큰당 가중치는 다. token-mean 집계, 정책 ratio 를 에서 상한, gradient는 결코 0이 되지 않는다. CISPO다. Olmo의 TIS 상한 2는 엔진 ratio 에 걸리고, gradient를 0으로 만드는 PPO clip과 곱해진다. DAPO는 일 때 인 토큰을 0으로 만든다.
그림에서 GSPO는 응답 전체를 0으로 만들고 DAPO는 흩어진 토큰을 0으로 만드는 이유는?
GSPO는 를 계산해 clip하므로, 안/밖 판정이 응답마다 한 번 내려지고 응답의 모든 토큰이 가중치 를 공유한다. 기하평균은 토큰 하나의 ratio보다 퍼짐이 훨씬 작기 때문에 은 훨씬 작다().
정리
- 배치가 고정되면 LLM policy-gradient 목적함수는 토큰당 가중치 로 완전히 기술되고, 모든 프론티어 목적함수는 를 집계 × (ratio + clip/mask) × IS 보정 × advantage − 정규화 항으로 인수분해한다.
- PPO식 clip은 토큰의 gradient를 0으로 만들고, stop-gradient 가중치(CISPO, MiMo-V2.6, GLM-5 agentic)는 크기만 누른다. Mask(IcePop, V3.2, K2.5)는 다른 ratio나 다른 단위를 기준으로 0으로 만든다.
- 랩 전체로 보면 std 정규화는 사라지는 중이고, token-mean 집계가 우세하며, reference KL은 대부분 에 묶는 것으로 바뀌었고, 설계의 노력은 ratio에 숨은 세 차이(업데이트, staleness, 엔진 불일치)를 어떻게 clip·보정·mask하느냐로 옮겨 갔다.
- 모든 clip과 mask는 bias(배우기를 거부하는 토큰)를 내주고 variance(step을 좌우했을 토큰)를 산다. 맞는 교환은 데이터가 얼마나 off-policy인지에 달렸다.
- Advantage 칸은 baseline과 크기다. baseline(그룹 평균, leave-one-out, greedy, 길이 가중, 두 번째 최고, 토큰별)은 분산에 영향을 주고, 크기(그룹 std, 배치 std, GPG의 재조정)는 최적화하는 목적함수를 바꾼다.
- 틀은 배치 선택, 보상, 시스템 수정을 빼놓는다. 그것이 안정성의 나머지 절반이다.
더 읽을거리Further reading
- Shao et al., DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models (2024) — GRPO 원전. 그룹 평균 baseline, std 정규화, 손실 안의 k3 KL.The origin of GRPO: group-mean baseline, std normalisation, k3 KL inside the loss.
- Yu et al., DAPO: An Open-Source LLM Reinforcement Learning System at Scale (2025) — clip-higher, token-level 집계, dynamic sampling, overlong shaping. 이후 거의 모든 랩의 기본값이 됐다.Clip-higher, token-level aggregation, dynamic sampling, overlong shaping; became the default for almost every lab.
- Zheng et al., Group Sequence Policy Optimization (2025) — 시퀀스 단위 ratio. Qwen3 이후 모델의 RL 목적함수.Sequence-level ratio; the RL objective of the post-Qwen3 models.
- MiniMax, MiniMax-M1: Scaling Test-Time Compute Efficiently with Lightning Attention (2025) — CISPO(IS 가중치를 clip하고 gradient는 살림)와 일반화된 mask 형태(Eq. 6–7).CISPO (clip the IS weight, keep the gradient) and its general masked form (Eqs. 6–7).
- DeepSeek-AI, DeepSeek-V3.2: Pushing the Frontier of Open Large Language Models (2025), §3.1 — 편향 없는 KL 추정량, 음의 advantage 시퀀스 off-policy mask, Keep Routing, Keep Sampling Mask.Unbiased KL estimator, off-policy mask on negative-advantage sequences, Keep Routing, Keep Sampling Mask.
- Team Olmo, Olmo 3 (2025), §4.4.1 — 목적함수를 식으로 모두 공개한 드문 사례. TIS × clip, std 없는 advantage, 하이퍼파라미터 표(Table 49).A rare fully written-out objective: TIS × clip, advantage without std, hyperparameter table (Table 49).
- The Microsoft AI Team, MAI-Thinking-1: Building a Hill-Climbing Machine (2026) — 엔트로피 controller가 clip 상한을 움직이는 목적함수(T1 Eq. 5, 7–9).An objective whose clip upper bound is moved by an entropy controller (T1 Eqs. 5, 7–9).
- Lambert, RLHF Book — Policy Gradients chapter — 같은 변형들을 교과서 표기로 정리하고 ratio 처리 방식을 표로 비교한다.The same variants in textbook notation, with a table comparing how each handles the ratio.