Maps to: UC Berkeley EE 290/194 Scalable AI, Fall 2026 Lecture 14, Reasoning Models (slides
lecture14.pdf), §1 “Reasoning models”, §2 “The policy gradient and its fixes” and §4 “What RL does to a language model”; its §3, “RL at scale is an inference problem”, is Lecture 19 here. Also drawn on: Spring 2026 Lecture 15, RL Algorithms for Post-Training (slideslecture_15.pdf). Recommended reading:
- Foundations: Williams, REINFORCE (1992); Schulman et al., TRPO (arXiv:1502.05477), GAE (arXiv:1506.02438), PPO (arXiv:1707.06347).
- GRPO and its successors: Shao et al., DeepSeekMath (GRPO, arXiv:2402.03300); DeepSeek-AI, DeepSeek-R1 (arXiv:2501.12948); Ahmadian et al., RLOO (arXiv:2402.14740); Hu, REINFORCE++ (arXiv:2501.03262); Yu et al., DAPO (arXiv:2503.14476); Liu et al., Understanding R1-Zero-Like Training (Dr. GRPO, arXiv:2503.20783); Zheng et al., GSPO (arXiv:2507.18071); MiniMax, MiniMax-M1 (CISPO, arXiv:2506.13585).
- What RL does: Yue et al., Does RL Really Incentivize Reasoning Capacity? (arXiv:2504.13837); Gandhi et al., Cognitive Behaviors (arXiv:2503.01307); Liu et al., ProRL (arXiv:2505.24864); Cui et al., The Entropy Mechanism of RL for Reasoning LMs (arXiv:2505.22617); Shenfeld et al., RL’s Razor (arXiv:2509.04259); Shao et al., Spurious Rewards (arXiv:2506.10947). Code:
code/lecture18/contains:pg_toy.py: a “reasoning” toy small enough to enumerate every response, so every gradient and every metric is exact;- five demos (estimators, GRPO fixes, clipping and ratios, what RL does, RL vs SFT forgetting).
Reading time: ~2.5 hours for the prose; ~20 seconds to run all demos.
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Tell the story of reasoning RL from RLHF to R1-Zero to 2026’s specialist-then-distil recipes, and say why RL became the “capability engine”.
- Derive the policy gradient and explain its noise: REINFORCE, baselines (critic, group mean, leave-one-out), why noise grows with response length, which groups carry any signal.
- Explain importance ratios and clipping: the three (at scale, four) policies in one update; the per-token approximation; what PPO’s clip does case by case.
- Map each 2025 fix to the part of the objective it repairs: dynamic sampling, token-level loss / Dr. GRPO, clip-higher, GSPO, CISPO, the return of the critic.
- Reason about what RL does to a model: sharpening vs discovery under pass@k, how the base model shapes the result, entropy and diversity, and why RL forgets less than SFT.
0.2 Prerequisites and scope
- Prerequisites: Lecture 16 §5 (RLVR, GRPO in one paragraph); Lecture 17 (environments and verifiers); probability (expectations, variance, KL).
- Scope: the RL update for language models and its 2025–26 variants; what RL does to the model’s distribution.
- Not in scope: making RL fast at scale (rollout engines, asynchrony, engine mismatch), which is Lecture 19.
0.3 Section → code map
| Section | Idea | Code in code/lecture18/ |
|---|---|---|
| §2.1–2.4 | REINFORCE, baselines, signal, importance weights | pg_toy.py, 01_policy_gradient.py |
| §3.3–3.5 | aggregation over tokens, dynamic sampling, overlong responses | 02_grpo_fixes.py |
| §2.5, §3.6–3.8 | the clip, clip-higher, CISPO, GSPO | 03_clipping_and_ratios.py |
| §5.2–5.6 | sharpening, discovery, entropy, diversity, random rewards | 04_what_rl_does.py |
| §5.7 | RL vs SFT forgetting | 05_rl_vs_sft_forgetting.py |
0.4 Notation
- = prompt; = response; = reward (here 0/1 from a checker).
- = the policy being trained; = the policy that generated the batch; = a fixed anchor (usually the SFT model).
- = per-token importance ratio.
- = advantage; = samples (rollouts) per prompt; = clip range.
0.5 The toy
Every experiment uses one toy (pg_toy.py). A problem has one correct answer among M. A response is some “think” tokens followed by an answer, at most L tokens; L think tokens and no answer is a truncated response, which gets reward 0. With L = 8 and M = 5 there are only 41 possible responses per problem, so every expectation can be summed exactly. The policy is a table of logits per (problem, position).
Two ways of initialising it stand for two kinds of base model:
- a model that rambles when it does not know: answers after more think tokens are less accurate;
- a model whose thinking helps: later answers are more accurate.
For effects that need parameters shared across problems (sharpening, forgetting), demos 04 and 05 add the smallest such models (§5). The toy cannot tell you the size of an effect in a 30B model. It can tell you whether a mechanism exists, and what causes it, with no sampling noise in the measurement.
1. Reasoning models: how the recipe changed
1.1 From preference models to checkers to environments
| period | reward | responses |
|---|---|---|
| 2017–2022 (PPO, RLHF, InstructGPT) | a reward model learned from human comparisons | short answers |
| 2023 (DPO) | the same comparisons, no explicit RL | short answers |
| 2024–2025 (o1, GRPO, DeepSeek-R1) | a checker on the final answer | long chains of thought |
| 2025–2026 (agent RL) | environments with tools | many steps of tool use |
1.2 The 2025 recipe and the 2026 recipe
- DeepSeek-R1 (2025) ran its stages one after another: cold-start SFT → reasoning RL → rejection sampling and SFT → general RL. Each later RL stage could erode skills from an earlier one. DeepSeek-V3.2 merged its RL into one mixed stage to avoid this forgetting (Nemotron 3 Nano did the same; Lecture 20).
- The 2026 recipes (DeepSeek-V4, Kimi K3, GLM-5.2) run a separate RL job per domain and effort level, often by different teams at once. They then distil all the specialists into one released model, usually by on-policy distillation (Lecture 17 §9).
The Spring 2026 slides frame the shift: before 2025 RL was alignment polish; from 2025 on, it is the capability engine. Three things matured together:
- verifiable domains: exact answers in math, unit tests in code, scores from environments;
- long chains of thought as learned search: plan → check → revise → commit, rewarded on the outcome;
- systems: rollout fleets, asynchronous schedulers, separate training and inference (Lecture 19).
1.3 R1-Zero’s “aha moment”, and AlphaGo’s Move 37
DeepSeek-R1-Zero was trained with RL only, from the base model, with a rule-based reward. Nobody showed it examples of checking its work. After roughly 8,000 steps its responses started to contain “wait”, rechecking and self-correction, while its answers grew longer and more accurate. DeepSeek called this an “aha moment”.
The Fall slides open with a comparison. AlphaGo’s policy network, trained on human games, gave Move 37 against Lee Sedol about a 1-in-10,000 chance; search with a value network chose it anyway. Can RL on a language model come up with genuinely new ideas, or only make existing behaviours more common? We first look at the update that produced R1-Zero’s behaviour (§2–§3), then return to this question with evidence (§5).
2. The policy gradient
2.1 REINFORCE, and why its noise grows with length
The objective is the expected reward, . The log-derivative trick gives its gradient:
Sampling a response and weighting its log-probability by its reward gives an unbiased estimate: REINFORCE (Williams 1992). Two problems follow:
- Every token gets the same credit. In a correct response, the filler and the false start are pushed up exactly as much as the key step. A wrong response with contributes no gradient at all.
- Each token adds a random term, so the noise grows with the response length.
Demo 01 Part B measures the second problem exactly: a policy that thinks with probability 0.8 per position, with answers 40% correct at every position, so length carries no information.
| max length L | mean length | REINFORCE relative variance | RLOO relative variance |
|---|---|---|---|
| 1 | 1.00 | 0.2 | 0.2 |
| 4 | 2.95 | 2.0 | 1.5 |
| 8 | 4.16 | 6.4 | 4.7 |
| 32 | 5.00 | 10.4 | 7.3 |
The relative variance is for a group of 8. Going from 1 to 5 tokens multiplies it by 50, and a baseline lowers it without stopping the growth. With chains of thought of 10,000 tokens and one 0/1 at the end, raw REINFORCE is too noisy to train on.
2.2 Baselines
Any baseline that does not depend on the sampled response leaves the expected gradient unchanged, because . So we replace by an advantage .
| method | baseline | cost |
|---|---|---|
| PPO | a learned critic for every prefix | a second model the size of the policy |
| GRPO | the mean reward of the G samples for the same prompt | G rollouts per prompt |
| RLOO | the mean reward of the other G − 1 samples | G rollouts per prompt |
| REINFORCE++ | the mean reward over the whole batch | one rollout per prompt |
Demo 01 Part A compares them on one problem with , against the exact gradient :
| estimator | cosine to | relative variance | |
|---|---|---|---|
| REINFORCE (no baseline) | 0.998 | 1.0000 | 1.79 |
| exact value baseline | 1.002 | 1.0000 | 1.17 |
| GRPO mean (the sample included) | 0.879 | 1.0000 | 1.06 |
| RLOO (leave one out) | 1.001 | 1.0000 | 1.38 |
| GRPO mean / std | 1.797 | 1.0000 | 4.38 |
- Every baseline keeps the direction and lowers the variance.
- GRPO’s group mean includes the sample itself, so it shrinks the gradient by : here 0.879, predicted 0.875. It is a harmless rescaling, which RLOO removes.
- Dividing by the std rescales each group. With many problems it changes the relative weight of problems, so it optimises a reweighted objective (§2.3).
The group mean estimates how often the model solves the prompt, the same quantity PPO’s critic learns. GRPO does the critic’s job by sampling more. Advantages are signed: correct samples are pushed up, wrong ones down, and a prompt the model always solves gives . For example, with 3 of 8 correct the baseline is 0.375: correct samples get +0.63, wrong ones −0.38.
GAE, generalised advantage estimation (Schulman et al.), is PPO’s knob between the critic and the actual return:
- λ = 0 trusts the critic one step ahead: low variance, but biased when the critic is wrong, which is common on long chains.
- λ = 1 (with γ = 1, the usual language-model setting) telescopes to “actual return minus the critic’s guess”: unbiased, higher variance.
With a sparse terminal reward, every token’s advantage is “outcome minus how promising this prefix looked”.
2.3 Only problems the model sometimes solves produce a gradient
If all samples get the same reward, every advantage is zero. The group cost a full set of rollouts and gave nothing. The probability that a group of carries signal is . Demo 01 Part C tabulates it:
| P(correct) | groups of 8 with signal | rollouts per useful group |
|---|---|---|
| 0.001 | 0.8% | 1,004 |
| 0.05 | 33.7% | 24 |
| 0.5 | 99.2% | 8 |
| 0.99 | 7.7% | 104 |
Signal vanishes at both ends. Too hard and already solved both waste rollouts, which is why recipes drop such prompts before training (difficulty filters) and again while forming each batch (dynamic sampling, §3.4).
The std division also reweights problems by difficulty. Per group that has signal, the total is 7.0 at P(correct) = 0.5 and 5.0 at 0.01 with the std. Without it (Dr. GRPO) the totals are 3.5 and 1.8. So dividing by the std gives nearly solved and nearly impossible problems about 1.4× more relative weight. Dr. GRPO removes the division; GRPO keeps it.
2.4 Reusing a batch requires importance weights
A rollout batch takes minutes to hours to generate, so it is reused for several updates. After the first update the samples come from an older policy, and the importance ratio corrects for it:
Over a whole response the ratio is a product of thousands of token ratios, which can explode or vanish. PPO and GRPO use only each token’s own ratio . That is TRPO’s surrogate approximation: it ignores how earlier tokens changed the context, so it is accurate only while stays close to .
Demo 01 Part D reuses a batch after updates of growing size, against the exact gradient at the new policy:
| KL(new ‖ old) | no correction: cosine | per-token ratios: cosine | sequence ratio: cosine / variance | largest sequence ratio |
|---|---|---|---|---|
| 0.11 | 0.867 | 0.992 | 1.000 / 2.58 | 2.4 |
| 0.77 | 0.567 | 0.959 | 1.000 / 2.43 | 8.3 |
| 1.42 | 0.395 | 0.943 | 1.000 / 1.56 | 13.9 |
- Uncorrected, the gradient turns away from the truth.
- Per-token ratios stay close but are not exact.
- The sequence ratio is exact in expectation and has the largest variance. Its weights reach 13.9 even on 6-token responses; over thousands of tokens they explode (§3.8).
Three policies appear in one update:
- the policy being optimised, (the numerator);
- the one that generated the batch, (the denominator);
- a fixed anchor, , for an optional KL penalty.
At scale there is a fourth: the inference engine’s copy of , which computes slightly different probabilities from the trainer’s (Lecture 19). Many reasoning recipes drop the KL penalty. DAPO’s argument is that a model learning long chains of thought has to move far from the SFT model.
2.5 The clip: one batch cannot move a token too far
Case by case, with :
- If a token was good (), its gain stops once its probability has risen to its old value. Past that point it gives no gradient for the rest of the batch.
- If it was bad (), its penalty stops once its probability has fallen to .
- The clip only stops movement in the direction the advantage pushes. A token that moved the other way still gets a gradient.
The clip is a cheap stand-in for TRPO’s trust region. Because it bounds a ratio, its limit in probability is proportional to where a token starts. Demo 03 Part A computes it:
| start probability | max after one batch, ε = 0.2 | with clip-higher, ε_high = 0.28 |
|---|---|---|
| 0.5 | 0.6 (+0.1) | 0.64 (+0.14) |
| 0.01 | 0.012 (+0.002) | 0.0128 (+0.0028) |
A likely token can gain 0.1 per batch, a rare one only 0.002. §3.6 shows why that matters.
3. The 2025 fixes, one part of the objective each
3.1 The map
The Fall slides organise the 2025 literature by which part of the objective each fix targets:
| part | problem | fixes |
|---|---|---|
| which groups | groups with identical rewards cost rollouts and give no gradient | difficulty filters, dynamic sampling |
| averaging | dividing by length lets long wrong answers off lightly | token-level loss, Dr. GRPO |
| clip | a symmetric clip keeps rare tokens from gaining probability | clip-higher |
| ratio | a few outlier token ratios dominate a long response | GSPO, CISPO |
| baseline | PPO’s critic is costly and hard to fit to long chains | GRPO’s group mean; GLM-5.2 brings a critic back for agent RL |
3.2 DAPO
DAPO (ByteDance Seed and Tsinghua’s AIR, 2025) is a diagnosis-and-repair package for long-chain GRPO, not a new family. On Qwen2.5-32B base it took AIME 2024 from 30 to 50 (avg@32), adding one change at a time:
| change (cumulative) | AIME 2024 |
|---|---|
| GRPO | 30 |
| + overlong filtering | 36 |
| + clip-higher | 38 |
| + soft overlong penalty | 41 |
| + token-level loss | 42 |
| + dynamic sampling | 50 |
Each gain depends on the order the changes were added. The open recipes of 2025 converged on the same few choices:
- DeepSeek-R1 used plain GRPO with a KL penalty;
- nearly every later report filtered problems by difficulty. Those reports are Kimi k1.5, DAPO, Open Reasoner Zero, INTELLECT-2, Llama-Nemotron, MiMo, Skywork OR-1, Magistral and GLM-4.5;
- most dropped the KL penalty and averaged the loss over tokens.
3.3 How the loss is averaged over tokens
GRPO divides each response’s loss by its own length, . Two wrong answers to the same prompt, both with :
- the 100-token one pushes each of its tokens down by ;
- the 1,000-token one only by .
A long wrong answer spreads its penalty over more tokens. Dr. GRPO observed that under GRPO wrong answers grew to ~2,000 tokens, and without the division they fell back to ~950 at the same reward. Two repairs exist:
- DAPO’s token-level loss divides by the total number of tokens in the batch;
- Dr. GRPO divides by a constant.
Either way every token gets the same weight within a batch.
Demo 02 isolates the length dynamics. It trains only the “think” logits, so the accuracy of an answer given after think tokens is fixed by the base model, and the policy can only learn when to answer:
| base model | loss | step 1: length | step 300: length | accuracy |
|---|---|---|---|---|
| thinking helps | GRPO (1/|o|, std) | 2.00 | 5.94 | 61.6% |
| thinking helps | Dr. GRPO | 2.00 | 6.42 | 64.8% |
| thinking helps | token-level | 2.00 | 6.02 | 61.4% |
| rambles | GRPO | 1.98 | 1.11 (wrong answers 1.16) | 58.9% |
| rambles | Dr. GRPO | 1.98 | 1.08 (wrong 1.11) | 59.2% |
| rambles | token-level | 1.98 | 1.06 (wrong 1.09) | 59.4% |
- When thinking helps, RL lengthens responses on its own, the R1-Zero pattern in miniature.
- GRPO’s averaging slows every length change. It gives each response the same total weight however long it is, so long correct responses are reinforced less per token, and long wrong ones penalised less.
In this toy the bias shows as slower length change, not the runaway growth Dr. GRPO saw in a real model; we report what we measured.
3.4 Dynamic sampling
DAPO drops groups whose rewards are all equal and samples more prompts until the batch is full. Demo 02 Part C trains on 20 hard (2%), 20 medium (30%) and 20 easy (95%) problems:
| step 100 | rollouts by then | at ~19,500 rollouts | |
|---|---|---|---|
| static batches | 69.6% | 12,800 | 89.7% (step 150) |
| dynamic sampling | 87.7% | 26,544 | 72.2% (step 75) |
Dynamic sampling makes every step count, and pays for it in rollouts. Per rollout, static batches did better in this toy. Whether it pays depends on whether gradient steps or rollouts are the bottleneck. At scale rollouts usually are (Lecture 19), which is one reason recipes also filter prompts before training: Nemotron removes prompts its SFT model already solves 100% of the time (Lecture 20).
3.5 Responses that run out of room
A response cut off at the length limit gets reward 0 and is treated as a negative example, punished for running out of room rather than for being wrong. DAPO has two fixes:
- overlong filtering masks the loss of truncated responses;
- soft overlong punishment lowers the reward gradually as a response nears the limit.
Demo 02 Part D (L = 6, thinking helps up to the last position):
| truncated responses | accuracy | mean length | truncated |
|---|---|---|---|
| reward 0 (a negative) | 73.0% | 5.59 | 1.1% |
| left out of the loss | 73.3% | 5.73 | 3.4% |
| soft length penalty (last 2 positions) | 46.5% | 3.77 | 0.2% |
- Filtering and the plain negative end at the same accuracy here. Filtering lets more responses run out, since running out is no longer punished.
- The soft penalty cost 27 points, because in this task the best answers come at the end of the budget. A length penalty is a prior that long is bad; it helps when that is true of the task (DAPO’s AIME setting) and hurts when it is not.
3.6 Clip-higher and rare tokens
MiniMax and DAPO both noticed that the tokens the clip removes are often rare words like “However”, “Recheck”, “Wait”: tokens that start with low probability and open new behaviour. By §2.5’s arithmetic a symmetric clip lets them gain almost nothing per batch. With a symmetric clip, DAPO saw entropy fall to almost zero and AIME accuracy stall near 25%. Clip-higher raises only the upper bound (0.2 → 0.28), letting rare good tokens grow faster while bad tokens are still suppressed at 0.8.
Demo 03 tests the mechanism. Reusing each batch for 4 updates, and with a “trap” (each problem has a common half-credit answer at 40% and a rare full-credit answer at 2%):
| update | problems that settle on the full-credit answer (5 seeds) |
|---|---|
| on-policy, 1 update per batch | 62.0% |
| 4 updates, no clip | 56.0% |
| 4 updates, clip 0.2 | 34.7% |
| 4 updates, clip-higher 0.2 / 0.28 | 35.7% |
| 4 updates, CISPO (weight capped at 1.28) | 35.7% |
- Bounding the ratio during reuse holds back the rare answer. The likely mechanism is Part A’s: the rare answer’s ratio reaches the bound after one update, while the common answer keeps rising within it.
- We could not reproduce clip-higher’s gain: its +0.08 changed nothing measurable here. DAPO measured it on a 32B model whose entropy falls across all prompts at once, a shared-parameter effect a per-problem table cannot show (§5.6 shows one).
3.7 CISPO: cap the weight, keep the gradient
Past the clip, PPO and GRPO drop the token’s gradient entirely. MiniMax-M1’s CISPO keeps every token and caps its weight:
where sg is stop-gradient: the capped weight is a constant, and every token keeps contributing.
On Qwen2.5-32B, CISPO matched DAPO’s AIME accuracy in half the training steps. MiniMax-M1 was trained with it on 512 H800s for three weeks (about $535K), with 1M-token native context. In demo 03 Part B, reusing each batch 4 times:
- the clip removes the gradient of 50% of the tokens after the first update;
- CISPO learns as fast as an unclipped update (91.9% vs 91.0% at step 50);
- the clipped update is slower (87.2%), clip-higher in between (88.3%).
3.8 GSPO: one ratio per response
The reward belongs to the whole response, but GRPO clips each token separately, so a few outlier ratios can dominate. GSPO (Qwen) uses one ratio per response, the geometric mean of its token ratios, and clips that:
Demo 03 Part D simulates per-token log-ratio noise of σ = 0.02 (essentially no token falls outside [0.8, 1.2]):
| tokens | product of ratios (5%–95%) | geometric mean (5%–95%) |
|---|---|---|
| 100 | 0.71 – 1.4 | 0.9966 – 1.0032 |
| 4,000 | 0.13 – 7.7 | 0.9995 – 1.0005 |
| 1,000 with 0.5% outlier tokens | 0.022 – 44 | 0.996 – 1.004 |
The geometric mean stays near 1 and can be clipped tightly, and outliers move it far less than they move the product. Outliers are what a mixture-of-experts model produces when a token is routed to different experts at rollout and at training. GRPO needed routing replay, recording the rollout’s expert choices and reusing them during training, to stay stable on Qwen3-30B-A3B. GSPO did not, and reached the same reward with less compute; it was used for Qwen3 Instruct, Coder and Thinking.
3.9 The critic, gone and back
With the usual GAE setting (λ = 0.95), DeepSeek found PPO clearly worse than GRPO on MATH. With λ = 1 it came close. GRPO matched it without training a second, policy-sized model, and Open Reasoner Zero and VAPO showed a critic can still train well.
For long agent tasks, a GRPO group waits for its slowest rollout (Lecture 19). GLM-5.2 went back to one rollout per prompt with a value model (single-rollout asynchronous optimisation, SAO). In its comparison, vanilla GRPO collapsed after ~160 steps, and GRPO with an off-policy correction ended a few points below.
3.10 The consensus, and what matters more than the name
The Spring slides’ choosing guide:
| setting | method |
|---|---|
| a critic and dense rewards | PPO |
| a verifier and multiple samples per prompt | GRPO or DAPO |
| long MoE responses | GSPO |
| heavy off-policy reuse | CISPO |
But what matters more than the algorithm’s name is entropy control, reward normalisation per task and difficulty, and credit assignment at the right granularity.
ScaleRL (Meta, Oct 2025, >400,000 GPU-hours) fit compute–performance curves to RL runs and separated two kinds of change:
- changes that move the asymptote: the prompt and task distribution, verifier precision, architecture, environment richness;
- changes that only move compute efficiency: loss aggregation, normalisation, off-policy reuse, clipping and baseline variants.
Do not confuse “learns faster” with “will ultimately learn more”. Much of 2025’s algorithm work improved efficiency. The lever on the end point is usually reward and environment quality (Lecture 17).
4. Off-policy reuse and agent RL, briefly
- Reuse versus staleness. Off-policy reuse trades cost for correctness. Three quantities govern it:
- the reuse factor (updates per generated batch);
- the staleness (how far the policy has drifted from the one that sampled);
- the quality of the correction.
- Kimi k1.5 made context length an RL scaling axis (up to 128K). It uses partial rollouts: long responses are continued in later steps instead of regenerated. It then distils long reasoning into short (“long2short”).
- Agent RL interleaves actions and observations: .
- Latency varies by 100× between trajectories, and an early bad retrieval poisons 50 later steps.
- The reward is composite: task success + process − latency − tool cost − unsafe actions, as MiniMax M2.5 reports.
- Its failure modes are tool farming, context bloat, environment over-fit, credit leakage (process rewards for busy activity) and non-stationary tools.
- Systems. All of this turns RL into a systems problem, the subject of Lecture 19.
5. What RL does to a language model
5.1 No tree search, no process rewards
Many expected o1-style models to use tree search, as AlphaGo did, plus graders that score each reasoning step (process reward models). DeepSeek tried both and dropped them:
- a reasoning step is hard to define and grade, and a step grader gets gamed;
- the space of token sequences is too large for tree search, and the value model it needs is hard to train.
This removes the part of AlphaGo that found Move 37. In the open recipes, exploration is limited to what the model itself samples.
5.2 Sharpening and discovery look different under pass@k
Pass@k counts a problem as solved if any of k samples is right (Lecture 16 §6.3). Pass@1 measures what the model does by default; pass@k at large k measures what it can reach with enough tries. Two outcomes are possible:
- Sharpening. The correct answer was sampled, say 8% of the time. RL raises pass@1, while large-k pass@k was already near 1.
- Discovery. The correct answer was sampled 1 in 10,000 times. RL raises pass@k even at large k.
These labels describe outcomes, not mechanisms, and “almost never sampled” depends on how large k is. Move 37 was a discovery.
Yue et al. compared base and RL models on math and code benchmarks up to 32B. For Qwen-2.5-32B on AIME 2024, RL raised pass@1 from 9% to 27%, but at k = 1,024 the base model solved 90% and the RL model 83%. The crossover appeared on every benchmark they tested, and the RL model lost some problems the base could solve. (At very large k an answer-only benchmark can also credit lucky guesses, which flatters the base model.)
Demo 04 reproduces the crossover and shows its cause. Its policy, SharpPolicy, has one shared sharpness (an inverse temperature for all problems) and per-problem corrections : logits . The 100 problems are of three types:
- type A: the correct answer is the base model’s favourite;
- type B: it is the 4th choice, at ~10%;
- type C: it has probability .
| model (200 RL steps) | pass@1 | pass@16 | pass@256 | pass@1024 |
|---|---|---|---|---|
| base | 14.9% | 78.0% | 85.4% | 86.5% |
| shared sharpness only (rises to 31) | 44.8% | 50.4% | 51.7% | 53.0% |
| shared sharpness + per-problem | 83.0% | 85.0% | 85.0% | 85.0% |
| per-problem only (no sharing) | 82.4% | 85.0% | 85.4% | 86.6% |
- Sharpening alone raises pass@1 (every A problem’s favourite answer is right) and drops pass@1024: B and C problems lose correct answers they could reach by sampling.
- With per-problem parameters as well, the base still wins from k = 61 on.
- Without a shared parameter, nothing is lost at large k.
In this toy the crossover has one cause: a shared parameter that makes every rarely sampled answer rarer, including correct ones RL never saw. Real models share all their parameters.
5.3 The base model shapes what RL finds
- The behaviour was already there. R1-Zero’s “wait” already appeared in DeepSeek-V3-Base: prompted with math, it wrote it and corrected itself occasionally, before any RL.
- Same RL, different bases. Under the same RL on a number game (Countdown), Qwen-2.5-3B reached ~50% within 50 steps, while Llama-3.2-3B stayed near zero for 60 steps and ended near 35%. Qwen’s base already checked its work and backtracked. Training Llama briefly on examples with those behaviours before RL brought it to ~73% (Gandhi et al.).
- Distillation can beat RL on a small model. DeepSeek distilled R1 into Qwen-32B and got 72.6 on AIME 2024, against 47.0 for RL on the same base model.
5.4 Weak signals gave large gains on Qwen models
- Spurious rewards. On Qwen2.5-Math-7B, a reward assigned at random raised MATH-500 by 21.4 points; the correct reward raised it by 29.1. The same random reward did nothing for Llama or OLMo models.
- Shao et al. attribute the random-reward gain to the clip, which favours behaviour the model already prefers. For Qwen-Math that is reasoning in code, which went from 65% to ~90% of responses.
- Wu et al. found signs that Qwen2.5 saw MATH-500 in pre-training. On new synthetic tasks it could not have seen, only correct rewards helped.
- Demo 04 Part F could not reproduce the clip mechanism in a tabular toy, even with an 86% favourite answer. Random rewards only diffused the distribution (a right favourite fell from 87.5% to 56.7%), so the effect depends on something the toy lacks.
- Fixing the first words. Starting OLMo-3-7B’s response with ”.\n\nOkay” raised MATH-500 from 42% to 78%, close to the RL model’s 75%. In these short runs (at most 300 steps), the largest change RL made was raising that opening’s probability from 0.14 to 0.65. Replacing “okay” with “chicken” in mid-training data raised the “chicken” opening from 2% to 37%; openings seem to work because of what followed them in training data (Wang et al.).
- Training-free sharpening. Sampling from a sharpened version of the base model’s distribution, with no training, reached 74.8 on MATH-500, against 78.5 for GRPO and 49.6 for the base (Karan and Du), at the cost of many extra forward passes per answer.
- Weight perturbation. On GSM8K, the share of small random weight changes that did at least as well as the model rose from 0% at 0.5B to 64% at 32B, and voting over the best 50 of 5,000 beat GRPO on most tasks, at 50× the inference cost (Gan and Isola).
Both studies compared against GRPO on models of 8B or fewer.
5.5 With long training, RL can solve what the starting model never solved
With more than 2,000 RL steps on varied tasks, ProRL took a 1.5B model (itself distilled from R1) from 0% at every k to 100% at k = 256 on a planning puzzle it was never trained on. Several studies report RL combining skills the model already had into combinations it had never seen. RL helped most on problems just beyond what the model could already do, and for agents the advantage of RL grew with k. The reported cases share three ingredients:
- long training;
- tasks that compose known skills;
- a reward on problems at the edge of competence.
Demo 04 Part C runs 2,000 steps on the 15 C problems (correct answer at ):
| model | C problems solved after 200 steps | after 2,000 steps | pass@1024 after 2,000 |
|---|---|---|---|
| shared sharpness + per-problem | 0 / 15 | 0 / 15 | 85.0% |
| per-problem only | 0 / 15 | 3 / 15 | 90.0% (base 86.5%) |
Discovery needs the answer to be sampled at all. Without sharpening, ~5,000 samples per problem eventually hit some correct answers, and RL then reinforced them. With sharpening, the answers became rarer still. ProRL kept a KL penalty, which most recipes drop, and periodically reset its reference model, which is what kept it improving past 2,000 steps.
The strongest frontier results come without base-model comparisons:
- Gemini Deep Think and an OpenAI experimental model reached gold-medal level at IMO 2025 (35 of 42);
- DeepSeekMath-V2 scored 118 of 120 on Putnam 2024 with RL against a trained proof verifier.
These systems use far more RL compute and longer reasoning than the controlled studies, and none reports the base model’s pass@k on the same problems. So they cannot say how much RL found and how much it selected.
5.6 Entropy, and fewer distinct answers
In Cui et al.’s runs, accuracy during RL fit , where is the policy’s entropy. Most of the gain came early, while entropy dropped quickly, and the fit predicts that accuracy stops improving as entropy approaches zero. This is the collapse that clip-higher, entropy bonuses and fewer reuse steps are meant to slow.
Demo 04 Part D fits the same form to our run, with . The fit’s value at zero entropy, 82.6%, is close to where the run ends: 83.0% at . Once entropy is gone, so is the room to improve.
Diversity shrinks with it. After RL, ProRL-1.5B gave fewer distinct final answers to the same prompt and lost about four times as many reachable correct answers as it gained (Wu et al., “The Invisible Leash”), while also being the model that solved the new puzzle. One model can show both patterns. In demo 04 Part E:
- answers above 1% probability fall from 10.9 to 2.0 per problem;
- the expected number of problems 1,024 samples solve falls from 86.46 to 85.00, all of it on the C problems.
Attempts to keep diversity include training on pass@k instead of pass@1, and keeping a KL term to the base model.
5.7 RL forgets less than SFT
Shenfeld et al. compared fine-tuned models across math, science, tool use and robotics. At the same accuracy on a new task, RL kept more of the model’s earlier abilities than SFT did. The KL divergence from the base model, measured on the new task, predicted how much was forgotten. Their argument: because RL samples from itself, it moves to a nearby solution.
Demo 05 tests it on a shared linear policy. The old task B is known at 90.8%. On the new task A, each problem has two correct forms: one the base leans toward, and one a teacher writes. At 80% accuracy on A:
| method | points of B lost | KL on A | KL on B |
|---|---|---|---|
| SFT on the teacher’s answers | 20.0 | 1.99 | 0.715 |
| SFT on the model’s own correct samples | 11.2 | 0.64 | 0.233 |
| RL (GRPO, either form rewarded) | 6.0 | 0.76 | 0.097 |
- Across 9 runs (three methods × three targets), KL on A predicts forgetting with correlation 0.867. SFT on the teacher at 60% and RL at 90% have nearly the same KL (1.07 vs 1.04) and lose nearly the same (10.8 vs 10.7 points).
- KL is a predictor, not the whole story. Self-sampled SFT ends closer to the base on A than RL and still forgets more. A plausible reason: matching a fixed target pushes every wrong answer down, while RL moves only what its samples touch.
The flip side is the slide’s point: many recipes drop the KL penalty, yet RL still stays close. If the argument holds, the same pull that limits forgetting also limits how far RL explores.
5.8 The evidence so far points both ways
| consistent with sharpening | consistent with discovery |
|---|---|
| random rewards helped Qwen models | olympiad-level proofs (without a base comparison) |
| forcing an opening word recovered most of a short run’s gain | long RL taught a puzzle the starting model never solved at any k |
| better sampling and weight perturbation reached much of the gain | several studies report RL composing known skills in new ways |
| the base wins pass@k at large k; answer diversity shrinks | for agents, the advantage of RL grows with k |
Most controlled studies use models of 8B or fewer, short runs, and math benchmarks that may be in pre-training data. Frontier labs run RL far longer but do not publish base-model comparisons. Language-model RL differs from AlphaGo in search, value estimates and how far it may move from its start. Settings that relax these (long runs, checked proof verifiers, long agent tasks) are where discovery is most likely to show up. How much RL adds, and when, is still open.
6. Summary
-
RL became the capability engine of post-training once checkers, long chains of thought and rollout systems matured together. The 2026 recipes train RL specialists per domain and distil them into one model.
-
The policy gradient credits every token of a response equally, and its noise grows with length (×50 from 1 to 5 tokens in our toy). Baselines remove much of the noise without bias:
- GRPO’s group mean shrinks the gradient by (G−1)/G;
- RLOO is exact;
- the std reweights problems by difficulty.
Only mixed groups carry signal.
-
Reusing a batch needs importance ratios. Per-token ratios are an approximation valid near , and the clip bounds how far one batch moves a token, in proportion to its starting probability.
-
Each 2025 fix repairs one part of the objective.
- Which groups: dynamic sampling, faster per step and not per rollout in our toy.
- Averaging: token-level loss or Dr. GRPO; GRPO’s 1/|o| slows length changes.
- The clip: clip-higher; bounds on the ratio hold back rare answers during reuse.
- The ratio: GSPO’s geometric mean stays near 1 where products explode; CISPO keeps clipped tokens’ gradients.
- The baseline: GRPO’s group mean, and a critic back for long agent tasks.
Most of this improves efficiency; the asymptote is set by rewards and data.
-
RL sharpens what the model can already sample. Pass@1 rises and pass@k at large k can fall, because shared parameters make rare answers rarer. Discovery happens when correct answers are sampled at all, in long runs that keep entropy. Accuracy tracks entropy, and diversity shrinks.
-
RL forgets less than SFT, because it stays near the base model. KL on the new task predicts forgetting, roughly.
7. Common pitfalls
- Raw REINFORCE on long responses; a group mean but no check for all-equal groups.
- Training on prompts the model always or never solves.
- Reusing a batch without ratios, or with full sequence ratios on long responses.
- Reading GRPO’s std division as harmless: it reweights problems.
- Per-response length normalisation when lengths matter.
- A soft length penalty on a task whose best answers are long.
- Comparing algorithms per step when rollouts are the bottleneck (or the reverse).
- Mistaking faster learning for a higher ceiling.
- Claiming RL “taught reasoning” from pass@1 alone, without pass@k of the base model.
- Letting entropy collapse early: the run stops improving there.
- Dropping the KL term without watching diversity and forgetting.
8. Exercises
- Baseline algebra. Show that for any constant b. Then show that GRPO’s group-mean advantage, with the sample included, gives for binary rewards.
Answer
. For GRPO, . The second term is independent of sample , so it is a valid baseline and contributes zero in expectation; the first scales the REINFORCE term by . Demo 01 measured 0.879 for G = 8 (0.875 predicted).
- Signal. A batch has 512 prompts: 40% that the model solves 99% of the time, 40% at 50%, and 20% at 0.1%. With G = 16, what fraction of groups carries signal? How many rollouts per useful group?
Answer
: p = 0.99 → 14.9%; p = 0.5 → ~100%; p = 0.001 → 1.6%. Weighted: 0.4 × 0.149 + 0.4 × 1.0 + 0.2 × 0.016 = 46.3%. Rollouts per useful group = 16 / 0.463 ≈ 35. Filtering the solved and unsolvable prompts first would bring it close to 16.
- Clip arithmetic. A token has probability 0.02 under , and its advantage is positive. What is the most its probability can reach within one batch with ε = 0.2? With ε_high = 0.28? How many batches to reach 0.5 if every batch hits the bound?
Answer
0.024 and 0.0256. From 0.02 to 0.5 is a factor of 25: batches vs . In practice the token is not pushed by every batch, so the gap is larger, which is DAPO’s argument.
- Length normalisation. Two wrong responses with A = −1 are 50 and 500 tokens long. Under GRPO’s per-response averaging, what does each token of each get? Under a token-level loss in a batch of 1,000 tokens? Which is the unbiased policy gradient?
Answer
GRPO: −1/50 and −1/500 per token (each response’s total is −1). Token-level: −1/1000 per token for both, so the long one’s total is ten times the short one’s. The unbiased gradient sums over tokens with no per-response division (up to a constant), which is what Dr. GRPO and the token-level loss do.
- The crossover. A model has two problems. On problem 1, P(correct) is 0.5 at base and 0.9 after RL. On problem 2, it is 0.01 at base and 0.0001 after RL. Compute pass@1 and pass@256 for both models.
Answer
Base: pass@1 = (0.5 + 0.01)/2 = 25.5%; pass@256 = (1 + (1 − 0.99^256))/2 = (1 + 0.924)/2 = 96.2%. RL: pass@1 = (0.9 + 0.0001)/2 = 45.0%; pass@256 = (1 + (1 − 0.9999^256))/2 = (1 + 0.025)/2 = 51.3%. RL wins at k = 1 and loses badly at k = 256: sharpening.
- Forgetting. In demo 05, why might RL stay closer to the base model than SFT on a teacher’s answers, even though both reach 80% on the new task?
Answer
RL samples from the model and reinforces the correct answers it already produces. The base leaned toward form 1, so RL raised form 1, a small move. SFT on the teacher pulled every problem to form 2, which the base gave 5%: a large move in distribution (KL 1.99 vs 0.76), and with shared weights a large move on the old task too.
9. The related assignment (concepts only)
The post-training assignment (A3 in both offerings) includes an RL stage. This lecture’s lessons are its prerequisites:
- check what fraction of your groups carries signal;
- report the aggregation, clip and KL settings you used;
- watch entropy and response length;
- evaluate pass@k for both the starting and the trained model.
No solutions are given here.
10. Research directions
- When does RL discover? Controlled studies at larger scale and longer horizons; base-model pass@k for frontier results.
- Exploration without tree search. Entropy control that does not slow learning; pass@k objectives; resetting references.
- Credit assignment for long chains and agents without gameable process rewards.
- Algorithms vs asymptotes. Which changes move the ceiling (ScaleRL’s distinction), measured rather than assumed.
- Forgetting and distance. When KL to the base predicts forgetting and when it does not (demo 05’s self-sampled SFT).
11. Further reading
- Schulman et al., TRPO, GAE, PPO (arXiv:1502.05477, 1506.02438, 1707.06347); Williams (1992).
- DeepSeekMath (arXiv:2402.03300); DeepSeek-R1 (arXiv:2501.12948); Kimi k1.5 (arXiv:2501.12599); Open Reasoner Zero (arXiv:2503.24290); VAPO (arXiv:2504.05118).
- DAPO (arXiv:2503.14476); Dr. GRPO (arXiv:2503.20783); RLOO (arXiv:2402.14740); REINFORCE++ (arXiv:2501.03262); GSPO (arXiv:2507.18071); MiniMax-M1 / CISPO (arXiv:2506.13585); ScaleRL (arXiv:2510.13786).
- Yue et al. (arXiv:2504.13837); Gandhi et al. (arXiv:2503.01307); Shao et al., Spurious Rewards (arXiv:2506.10947); Wu et al., Reasoning or Memorization (arXiv:2507.10532); Karan and Du (arXiv:2510.14901); ProRL (arXiv:2505.24864); Cui et al. (arXiv:2505.22617); Wu et al., The Invisible Leash (arXiv:2507.14843); Chen et al., Pass@k Training (arXiv:2508.10751); Shenfeld et al., RL’s Razor (arXiv:2509.04259).
12. Next lecture
Lecture 19 · RL at Scale Is an Inference Problem: NeMo RL and NeMo Gym. Rollout generation can take most of an RL step. Lecture 19 follows one step through the serving system and the training system:
- the long tail of response lengths;
- shared vs separate GPUs;
- asynchronous RL and its staleness limits;
- the inference engine and the trainer disagreeing about probabilities, and the corrections;
- sandboxes as a second serving system;
- how NeMo RL and NeMo Gym organise it.
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| reasoning model / chain of thought | 推理模型 / 思维链 |
| policy gradient / REINFORCE / score function | 策略梯度 / REINFORCE / 得分函数 |
| baseline / advantage / critic / value function | 基线 / 优势 / 评论家 / 价值函数 |
| GAE (generalised advantage estimation) | 广义优势估计 |
| group-relative advantage / leave-one-out (RLOO) | 组相对优势 / 留一法 |
| zero-signal group / difficulty filter / dynamic sampling | 无信号组 / 难度过滤 / 动态采样 |
| importance ratio / behaviour policy / reference policy | 重要性比率 / 行为策略 / 参考策略 |
| trust region / clipped surrogate objective | 信赖域 / 裁剪替代目标 |
| clip-higher (asymmetric clipping) | 上界放宽的非对称裁剪 |
| length normalisation / token-level loss | 长度归一化 / 词元级损失 |
| overlong filtering / soft overlong penalty | 超长过滤 / 软超长惩罚 |
| sequence-level ratio (GSPO) / routing replay | 序列级比率 / 路由回放 |
| capped importance weight (CISPO) / stop-gradient | 截断重要性权重 / 停止梯度 |
| entropy collapse / exploration | 熵坍缩 / 探索 |
| sharpening / discovery | 锐化 / 发现 |
| pass@k crossover / answer diversity | pass@k 交叉 / 答案多样性 |
| spurious reward / training-free sampling | 虚假奖励 / 免训练采样 |
| catastrophic forgetting / RL’s Razor | 灾难性遗忘 / “RL 剃刀” |
| specialist distillation / on-policy distillation | 专家模型蒸馏 / 同策略蒸馏 |