Reasoning, Part 2

Let a small model guess the next 7 tokens, and let the big model check all 7 in one pass. For T5-XXL (11B) with a 77M draft, each guess survives 75% of the time. So one check yields 3.60 tokens on average, and the text is exactly what the 11B alone would write. Measured: 3.4 times faster.

Pick a draft model and press Race. Then we build, piece by piece, what makes long chains of thought affordable. That means the draft-and-check rule, stale data in RL, on-policy distillation, longer windows, and when more thinking pays.

You need a little Python, what a probability is and what a language model does (Lectures 7 and 12). We build the rest from zero.

Lecture 13, "Reasoning 2", of Stanford CS224N, Natural Language Processing with Deep Learning (Winter 2026, Diyi Yang and Yejin Choi; this lecture’s slides are Yejin Choi’s). Its readings are Let’s Verify Step by Step (Lightman et al., 2023), speculative decoding (Leviathan et al., 2023), compute-optimal test-time scaling (Snell et al., 2024) and RoFormer (Su et al., 2021). Before: Lecture 12, Reasoning 1. Next: Lecture 14, Tokenization and Multilinguality.

Race draft-and-check against the big model alone

7

Acceptance α and draft cost c are Table 4 of Leviathan et al. (2023): T5-XXL translating English to German with argmax decoding. The measured speedups, 3.4, 2.8 and 1.7 times, are their Table 2. The race draws each guess’s fate at random with chance α, so one run varies; the read-out gives the average. The German sentence is a stand-in.

Chapter 0

Thinking Costs Tokens

Price one long chain of thought in time and in context, and see the four bills this lecture pays

A reasoning model answers a hard maths question by writing first. It tries an approach, checks it and backtracks, often for thousands of tokens. Lecture 12 showed how reinforcement learning teaches a model to write such chains. This lecture is about paying for them.

Bill one chain of thought

The warm tape is the chain the model writes. Drag its length. The pink bar is the least time it takes; the grey ruler is a 4,096-token context window.

10,000

Illustrative lower bound. A 70B model in 16-bit numbers is 140 GB. An H100 SXM reads memory at 3.35 TB/s (NVIDIA’s datasheet). We count only reading the weights once per token at batch size 1, on one GPU’s bandwidth.

Why is each token so slow? To write one token, the model runs one forward pass: every weight takes part once. At batch size 1, the GPU spends that pass waiting for weights to arrive from memory. It does little arithmetic on each one. So decoding is memory-bound: the speed of memory, not of arithmetic, sets the pace.

With numbers: 70 billion weights at 2 bytes each are 140 GB. At 3.35 TB per second, reading them takes 140 / 3,350 = 0.0418 s. That is 41.8 ms per token at the least. A 10,000-token chain then takes 418 s, about 7 minutes.

The lecture pays four bills. Time: make one big pass write several tokens. Training: RL needs fresh samples, but long chains are slow to sample. Room: the chain and its documents must fit in the context window. Payoff: spend extra thinking only where it helps.

Symptom: a reasoning model takes minutes for one answer.

Measure: tokens per second at batch size 1, against the weight-reading bound of one token per 41.8 ms.

Fix: get more than one token out of each big pass (Chapter 1).

The road

  1. Draft and check: a small model guesses; the big model keeps or rejects each guess.
  2. Exact: why the text has exactly the big model’s distribution.
  3. Speed: how many tokens one check yields; the race in the hero.
  4. Stale data: asynchronous RL trains on samples from older weights.
  5. Distill: the student writes, the teacher grades every token.
  6. RoPE: positions as rotations, so only distance counts.
  7. Stretch: PI, NTK-aware scaling and YaRN for longer windows.
  8. Best of N: sample many answers, and let a checker pick.
  9. Showcase: a bigger model, or more thinking?
  10. Field guide: the numbers and the code.
Why does a large model write tokens slowly at batch size 1?

Chapter 1

Draft, Then Check

Let a small model guess several tokens, check them all in one big pass, and keep each guess by a coin flip

Not every token is hard. After "dogs love chasing", a small model guesses "after" about as well as a big one. Two teams proposed the same trick independently: Leviathan et al. at Google Research (November 2022) and Chen et al. at DeepMind (February 2023). It is called speculative decoding.

A small draft model writes γ guesses, one by one. It is fast. The big target model then runs once over all γ positions in parallel. That pass costs about as much as a pass for one token, because the time goes into reading the weights. Now the target has a probability for every guess.

Walk the guesses left to right. For a guess x, call the draft’s probability of it q(x). Call the target’s probability of the same token, after the same prefix, p(x). Keep the guess with this chance:

Say it aloud

The chance to accept x equals the minimum of one and p of x over q of x.

P(accept x)
the chance to accept x how likely the draft’s guess x stays in the text.
min(1, ·)
the minimum of one and take the smaller of 1 and the ratio, so a chance never passes 1.
p(x)
p of x the target model’s probability of token x at this position.
q(x)
q of x the draft model’s probability of the same token. The lecture slides swap the two letters, as Chen et al. do; we follow Leviathan et al.
In plain words

If the target likes x at least as much as the draft did, p(x) ≥ q(x), keep it. If the draft was overconfident, keep x only with chance p(x)/q(x). At the first rejection, stop and draw one token from the target instead.

With numbers

The slides’ example: for "chasing" the draft gave q = 0.9 and the target p = 0.8. Keep it with chance 0.8 / 0.9 = 0.889. For "after", q = 0.8 and p = 0.3: keep it with chance 0.3 / 0.8 = 0.375.

Check five guesses

Each warm word is a guess, with the draft’s q and the target’s p under it. The blue bar is its keep chance, min(1, p/q). The thin line is a random draw u: the guess stays if u lands inside the bar. Press Check all.

The five words and both rows of probabilities are the lecture slides’ example (a 1B draft, a 100B target). The replacement word and the bonus token are our stand-ins.

The target likes the first two guesses more than the draft did, so both always stay. The third survives with chance 0.889 and the fourth with 0.375. All four survive together with 0.889 × 0.375 = 0.333, and the fifth then always stays. On average 3.56 of the 5 guesses survive. With one token from the target at the end, one big pass writes 4.56 tokens.

Symptom: the target rejects almost every draft at its first token, and decoding gets slower.

Measure: the acceptance rate α, the average chance a guess survives.

Fix: a draft trained on similar data with the same tokenizer. The lecture notes newer methods that align different tokenizers.

The draft gives its guess probability 0.2. The target gives the same token 0.6. What is the chance to keep it?

Chapter 2

Why the Text Is Exactly the Big Model’s

Draw the replacement from the target’s leftover probability, and the two paths add up to p

Speculative decoding is not an approximation. Every token comes out with exactly the target’s probability p. The trick is where the replacement comes from after a rejection.

A token x can come out by two paths. Path one: the draft proposes x and we keep it. That happens with chance q(x) × min(1, p(x)/q(x)) = min(p(x), q(x)). Add this up over all tokens and you get α, the chance that a guess survives. Path two: a rejection, with chance 1 − α, followed by a draw from a residual distribution. Call it p′(x):

Say it aloud

p-prime of x equals the maximum of zero and p of x minus q of x, divided by the sum over all tokens x-prime of the same maximum.

p′(x)
p-prime of x the residual: the probability of drawing x after a rejection.
max(0, ·)
the maximum of zero and keep a positive gap; turn a negative one into 0.
p(x)
p of x the target’s probability of x.
q(x)
q of x the draft’s probability of x.
Σx′
the sum over x-prime add the gaps over the whole vocabulary, so p′ adds up to 1. The total equals 1 − α.
In plain words

For each token, see how much more the target likes it than the draft does, p(x) − q(x). Drop the tokens where the draft already gives too much. Scale the rest to add up to 1. That is p′(x): it refills exactly the probability the draft missed.

With numbers

With made-up numbers on four tokens A, B, C, D: p = 0.45, 0.30, 0.15, 0.10 and q = 0.25, 0.20, 0.40, 0.15. The gaps are 0.20, 0.10, 0, 0, so p′ = 0.667, 0.333, 0, 0. Token A: kept 0.25, plus 0.30 × 0.667 = 0.20 from the residual: 0.45, its target value.

In general: min(p, q) + max(0, p − q) = p, for every token. Path one gives the first term. Path two gives (1 − α) × p′(x), which is the second term.

Sample, and compare with the target

Filled blue bars are the target’s p, outlined bars the draft’s q. The pink ticks are how often each token came out of draft-and-check. Pick a draft, then add draws.

Illustrative toy with a four-token vocabulary; the probabilities are ours. The sampler runs the real rule: draft from q, keep with min(1, p/q), else draw from p′.

Symptom: text from the speculative path reads differently from the target’s own samples.

Measure: token frequencies of both paths on the same prompts.

Fix: apply the same temperature and top-p to p and to q before the keep test. A mismatch breaks the guarantee.

Why does draft-and-check give exactly the target’s distribution?

Chapter 3

How Much Faster

Count the tokens one check yields, charge the draft’s cost, and find the best number of guesses

How many tokens does one big pass give? Assume each guess survives with the same chance α, independently. The pass yields the run of kept guesses plus one token from the target. With γ guesses, the run stops at the first rejection or after all γ.

The draft is not free. Call the time of one draft pass, measured in big passes, c. One cycle then takes γc + 1 big passes of time. Divide the tokens per cycle by that time:

Say it aloud

The speedup equals one minus alpha to the gamma plus one, divided by one minus alpha, times gamma c plus one.

speedup
speedup how many times faster than the target alone, on average.
α
alpha the acceptance rate: the average chance a guess survives, between 0 and 1.
γ
gamma the number of guesses per check, a whole number from 1 up.
c
c the time of one draft pass divided by the time of one target pass.
In plain words

The top over 1 − α is the average number of tokens per cycle: 1 + α + α² + … up to α to the γ. The bottom charges γ draft passes at c each, plus one target pass. Tokens per unit of time is the speedup.

With numbers

From Leviathan et al.’s Table 4, T5-small drafting for T5-XXL: α = 0.75, c = 0.02, γ = 7. Tokens per cycle: (1 − 0.758) / 0.25 = 3.60. Time per cycle: 7 × 0.02 + 1 = 1.14. Speedup: 3.60 / 1.14 = 3.16. They measured 3.4.

Tune the number of guesses

The pink curve is the speedup for each γ; the dot is your γ. Start from a row of the paper’s table, then move the sliders.

0.75
0.02
7

The chips load α, c and γ from Table 4 of Leviathan et al. (T5-XXL, English to German) and show their measured speedup from Table 2. The formula assumes every guess survives independently with the same α; real text is burstier.

A bigger draft agrees more but costs more. T5-large has α = 0.82 and 4.42 tokens per cycle, but c = 0.11 makes a cycle cost 1.77 passes: 2.50 in theory and 1.7 measured. The 77M T5-small wins. On a 70B model, Chen et al. report 2 to 2.5 times with a 4B draft.

The lecture lists newer drafters, all supported by vLLM or SGLang. Medusa adds extra heads to the target that guess tokens further ahead. EAGLE-3 drafts from the target’s own hidden features. SuffixDecoding uses no model: it matches the current text against a suffix tree of earlier text. That suits repetitive agent loops.

Symptom: decoding with a draft is slower than without.

Measure: α and c on your own traffic.

Fix: a smaller draft or fewer guesses. Each extra guess costs c but survives only with chance α to the k.

T5-large agrees with T5-XXL more often than T5-small does. Why is it the slower draft?

Chapter 4

Stale Rollouts

See why fast RL systems train on samples from older weights, and measure how much those samples still count

RL for reasoning works in rounds. The model writes answers, called rollouts; a checker scores them; the trainer updates the weights. With chains of thousands of tokens, writing the rollouts takes most of the time. So fast systems run generation and training at the same time, often on separate GPUs.

The lecture names two splits. Online RL keeps interacting with the task during training; offline RL learns from a fixed log. On-policy RL trains only on rollouts from the current weights, as REINFORCE, PPO and GRPO assume. Off-policy RL trains on rollouts from any policy, such as older weights.

Asynchronous RL is online but off-policy. By the time a rollout reaches the trainer, the weights have moved a few steps. PipelineRL (Piché et al., 2025) even swaps in new weights halfway through a rollout. This gap is off-policy drift.

The repair weights each rollout. Call the current policy π and the older policy that wrote rollout i μ. The importance weight wi = π(yi) / μ(yi) says how much more likely the new weights make that answer. For a chain, it multiplies one ratio per token. How much do N weighted rollouts still count?

Say it aloud

E-S-S equals the square of the sum over i of w-i, divided by N times the sum over i of w-i squared.

ESS
E-S-S the normalized effective sample size: the share of the batch that still counts, from near 0 to 1.
Σi
the sum over i add one term for each rollout in the batch.
wi
w-i rollout i’s importance weight, π(yi) / μ(yi). Fresh rollouts have w = 1.
N
N the number of rollouts in the batch.
In plain words

Add the weights wi and square the total. Divide by N times the sum of the squared weights. If all weights are equal, ESS is 1. If one weight dwarfs the rest, ESS falls to about 1/N: one rollout decides the update.

With numbers

With made-up weights for N = 4 rollouts: 2.0, 0.5, 0.5 and 1.0. The sum is 4.0, squared 16. The squares add to 5.5. ESS = 16 / (4 × 5.5) = 0.727: the four rollouts count like 2.9.

Weigh stale rollouts

Each teal bar is one rollout; its blue cap is its weight, on a log scale around 1. Make the rollouts staler or the chains longer, and watch a few weights take over.

2 steps
4,000

Illustrative toy. Each token’s log ratio is random with a spread of 0.004 per step of staleness, independent across tokens. Real ratios move together, but the trend holds: products of thousands of ratios spread wide. ESS uses 2,000 rollouts; the chart shows 48.

PPO and GRPO weight each token by its own ratio and clip it to a band such as 0.8 to 1.2. That trades a little bias for far less noise. Asynchronous RLHF trained a LLaMA 3.1 8B chatbot about 40% faster with the same final score (Noukhovitch et al., 2025). PipelineRL reports about 2 times faster learning.

Symptom: reward climbs, then training blows up or the model starts to exploit the checker.

Measure: ESS of each batch, or the share of token ratios that hit the clip.

Fix: the lecture’s list: PPO clipping, a KL penalty to a reference model, fewer passes over each batch, and fresher weights through in-flight updates.

Why does staleness hurt more when each rollout is a long chain of thought?

Chapter 5

Learn From Your Own Mistakes

Let the student write and the teacher grade every token, with a loss that rewards one good mode over a blur

To make a small model reason like a big one, distill: train the small student to match the big teacher. The old way trains on the teacher’s text. At test time the student reads its own text, mistakes included, and it never practised recovering. This gap is exposure bias.

On-policy distillation (Gu et al., 2023; Agarwal et al., 2023) flips it. The student writes, and the teacher scores every token. The student learns in the states it visits, with a signal at every token instead of RL’s one score per answer.

What loss? Call the student’s next-token distribution πθ and the teacher’s πT. The reverse KL weights each token by the student’s own probability:

Say it aloud

The KL from pi-theta to pi-T equals the sum over x of pi-theta of x, times the log of pi-theta of x over pi-T of x.

πθ
pi-theta the student’s next-token distribution; θ are its weights, the ones training changes.
πT
pi-T the teacher’s next-token distribution, after the same prefix. It stays fixed.
Σx
the sum over x one term for each token in the vocabulary.
log
log the natural log. The ratio’s log is positive where the student gives more than the teacher.
In plain words

For each token x, take the log of how much more the student likes it than the teacher does. Weight it by the student’s own probability πθ(x), and add. Tokens the student never says cost nothing. Tokens it says that the teacher dislikes cost a lot.

With numbers

With made-up numbers on three tokens: student 0.90, 0.05, 0.05 and teacher 0.50, 0.45, 0.05. Reverse KL = 0.90 × log 1.8 + 0.05 × log(0.111) + 0 = 0.529 − 0.110 = 0.419. The forward KL, weighted by the teacher, is 0.695: it punishes the missed second token harder.

Fit a student two ways

The blue curve is the teacher with two modes. The purple bump is the student, which can only make one. Pick a loss and press Fit.

±2.0

Illustrative toy on a number line, not a vocabulary. The teacher is an even mix of two bumps with spread 0.6; the student is one bump. Fit searches the student’s centre and spread for the lowest KL.

Forward KL covers every mode: the student spreads out, even between the modes. Reverse KL is mode-seeking: the student settles on one mode and is sharp there. In text, it commits to one good way to say it.

The Qwen3 report (Table 21) starts two runs from the same distilled Qwen3-8B. RL reached 67.6% on AIME’24 in 17,920 GPU hours. On-policy distillation from a larger Qwen3 teacher reached 74.4% in 1,800 hours, about a tenth.

Symptom: the student copies teacher text well, then drifts once its own early tokens go wrong.

Measure: the per-token reverse KL on the student’s own samples.

Fix: on-policy distillation. A sampled token with student 0.40 and teacher 0.10 gets a penalty of log 4 = 1.39.

What makes on-policy distillation "on-policy"?

Chapter 6

Positions by Rotation

Turn each query and key by an angle that grows with its position, so their dot product sees only the distance

Long reasoning needs long context: a whole repository, or a chain with many false starts. The lecture lists three walls. Few web documents are long, attention cost grows with the square of the length, and position encodings trained on short text do not carry over.

Attention alone ignores order. GPT-2 and BERT learned one position vector per slot. A slot never seen in training has no vector at all. RoPE, rotary position embedding (Su et al., 2021), adds no vectors. It rotates each query and key by an angle set by its position.

Take one pair of numbers from a query and a key, as a 2-D arrow. Call the query’s position m, the key’s n, and the angle per position θ. Call the rotation by an angle a R(a). Rotating both, and then taking the dot product, gives:

Say it aloud

R of m theta times q, dot R of n theta times k, equals q dot R of n minus m, times theta, times k.

R(a)
R of a turn a 2-D arrow by angle a, in radians. It keeps the arrow’s length.
m
m the query token’s position in the sequence.
θ
theta the angle this pair turns per position. Each pair of the head has its own.
q
q two numbers of the query vector, before rotation.
n
n the key token’s position.
k
k the same two numbers of the key vector, before rotation.
In plain words

Turn the query by mθ and the key by nθ, then take their dot product. Only the gap n − m survives, because turning both by the same amount changes nothing between them.

With numbers

With made-up vectors q = (0.8, 0.6), k = (1.0, 0.2) and θ = 0.5: at positions m = 10, n = 11 the dot product is 1.018. At m = 100, n = 101 it is again 1.018. At m = 10, n = 14 it is 0.017.

Rotate a query and a key

Purple arrows are the query and key after rotation; the blue number is their dot product. Move one position, or shift both together.

10
30

We made up the vectors. The angles are RoPE’s for a head of size d = 128: pair i turns 10000 to the power −2i/128 radians per position.

A head of size 128 has 64 pairs, each with its own angle θi = 10000−2i/128. Pair 0 turns 1 radian per token, a full turn every 6.3 tokens: it sees order inside a phrase. Pair 63 turns 0.000115 radians, a full turn every 54,410 tokens: it sees where in a long text you are. RoPE turns queries and keys only, never values, in every layer.

Symptom: a model trained on 4,096 tokens writes nonsense past token 4,096.

Measure: loss or perplexity by position: it climbs past the trained length.

Fix: rescale the angles and fine-tune briefly (Chapter 7).

Why does RoPE make attention depend only on the distance between two tokens?

Chapter 7

Stretch the Window

Find the slow pairs that never finished a turn in training, and squeeze new positions into angles the model knows

If RoPE only sees distance, why does a model fail past its trained length? Look at the slow pairs. With a trained length of 4,096 and a head of 128, pair 0 turns 652 times. Pairs 46 to 63, 18 of the 64, never finish one turn. Past 4,096 they show angles the model never saw.

Position Interpolation (PI; Chen et al., 2023, at Meta) squeezes positions back into the trained range. Call the trained length L, the new length L′, and a token’s position m:

Say it aloud

m-prime equals m times L over L-prime.

m′
m-prime the position RoPE uses instead, possibly a fraction.
m
m the token’s real position, from 0 up to L′.
L
L the context length used in pretraining, in tokens.
L′
L-prime the new, longer context length. The ratio L′/L is the scale s.
In plain words

Shrink every position m by the same factor L/L′. The last position lands at L, so no angle goes past what training saw. The price: neighbours now sit only L/L′ apart.

With numbers

LLaMA trained with L = 2,048. To reach L′ = 8,192, position 8,000 becomes 8,000 × 2,048 / 8,192 = 2,000. Two neighbouring tokens are now 0.25 apart, so pair 0 turns 0.25 radians between them instead of 1.

Stretch a 4K model

One column per frequency pair, fast on the left. Purple height is each pair’s turn per token after the change, against the trained one. Red marks a pair that now shows unseen angles. Pick a method and a length.

32K (s = 8)

The pair angles, the NTK-aware base b·sd/(d−2), YaRN’s ramp with α = 1 and β = 32, and its temperature are the formulas of Peng et al. (YaRN, 2023), for a trained length of 4,096 and d = 128. Which angles a model can use is our simplification.

PI took LLaMA 7B to 65B up to 32,768 tokens with at most 1,000 fine-tuning steps. But it blurs neighbours, and YaRN’s authors saw PI degrade past about s = 8. NTK-aware scaling raises RoPE’s base instead: at s = 8, 10,000 becomes 82,685. Fast pairs barely change; slow pairs stretch.

YaRN (Peng et al., 2023) treats pairs by how often they turn in L tokens. It leaves pairs with more than 32 turns alone, squeezes pairs with less than one turn like PI, and ramps between. It also sharpens attention: the logits grow by (0.1 ln s + 1)², a factor of 1.46 at s = 8.

The lecture’s recipe: change the position encoding, then keep pretraining on long documents at growing lengths, such as 8K, 32K, then 128K. Its rule of thumb is 0.1 to 1% of the original pretraining tokens.

Symptom: after a big PI stretch, the model gets worse on short texts it used to handle.

Measure: perplexity on short documents, before and after.

Fix: leave the fast pairs alone, as NTK-by-parts and YaRN do.

Why does YaRN leave the fastest pairs untouched?

Chapter 8

Think Longer, Check Better

Sample many answers, let a checker pick one, and see why the checker sets the ceiling

The cheapest way to think longer is to answer many times. Sample N solutions at a temperature above 0, then pick one. Picking needs a rule. Majority voting takes the most common final answer, as in self-consistency (Lecture 12). A verifier is a model trained to score solutions, and best-of-N keeps the top-scored one.

An outcome reward model (ORM) scores the whole solution: is the final answer right? A process reward model (PRM) scores every step. Lightman et al. (2023) paid people to label steps of GPT-4 solutions to MATH problems as right, wrong or neutral. That is PRM800K: 800,000 step labels on 75,000 solutions to 12,000 problems. The PRM scores a solution as the product of its steps’ chances of being right.

A picker can only pick a right answer if the model wrote one. Call one sample’s chance of being right p and the number of samples N. The chance that at least one is right is the coverage:

Say it aloud

Coverage equals one minus, one minus p, to the N.

coverage
coverage the chance that at least one of the N samples is right. A perfect checker would score this.
p
p the chance that one sample is right, for this problem.
N
N the number of independent samples.
In plain words

One sample is wrong with chance 1 − p. All N are wrong with that chance multiplied N times. Coverage is everything else.

With numbers

With p = 0.1: one sample covers 0.10, ten cover 1 − 0.910 = 0.651, and a hundred cover 0.99997. With p = 0, coverage stays 0 for every N.

Pick the best of N

The grey line is coverage, what a perfect checker would get. The pink line is the picker you choose. Slide N to sample more.

16

Illustrative toy: 400 made-up problems with mixed difficulty, a tempting wrong answer on some, and scorers whose scores separate right from wrong solutions by 1.0 (ORM-like) or 2.0 (PRM-like) noise widths. The real gap is Lightman et al.’s: see below.

Lightman et al. scored 1,860 samples per problem on 500 MATH test problems. Picking with the PRM solved 78.2%, with the ORM 72.4%, and by majority vote 69.6%. Taking the minimum step score instead of the product gave 77.6%, so the choice barely matters. Step labels help because they say where a solution went wrong, not only that it did.

Symptom: accuracy stops rising, or falls, as N grows.

Measure: the gap between coverage and the picked accuracy.

Fix: a better verifier. Snell et al. saw search against a PRM hurt on easy questions, where it chases the PRM’s quirks.

A model never writes a right answer to some problem (p = 0). What does best-of-1,000 with a perfect verifier give on it?

Chapter 9

A Bigger Model, or More Thinking?

Give a small model the compute a 14 times bigger model would cost, spend it on samples, and see which questions it wins

Snell et al. (2024, UC Berkeley and Google DeepMind) asked the budget question. On MATH, with PaLM 2-S*, they chose the test-time method per question by its difficulty. That beat best-of-N while using about 4 times less test-time compute. Then they compared against a model with about 14 times more parameters, at equal FLOPs.

The exchange rate comes from two rules of thumb. Pretraining costs about 6 FLOPs per parameter per training token; generating costs about 2 per parameter per token. Call the size ratio of the big model M. Call the ratio of tokens served to tokens pretrained R. The small model may spend K times its usual inference compute:

Say it aloud

K equals M plus three times M minus one, over R.

K
K how many times its normal inference compute the small model may use; with best-of-N, about K samples.
M
M how many times more parameters the big model has. Snell et al. use about 14.
R
R tokens generated at inference divided by tokens used in pretraining: the inference load.
In plain words

The big model costs M times more on every token it serves: that gives M. It also cost M − 1 extra in pretraining, at 3 times the per-token price of serving. Spread that extra over the R served tokens: that adds 3(M − 1)/R.

With numbers

With M = 14, Snell et al.’s three loads: R = 0.16 gives K = 14 + 39 / 0.16 = 257.75. R = 0.79 gives 63.37. R = 22, heavy serving, gives only 15.77.

Spend the budget

Five difficulty levels. Pink bars: the small model with K samples and a verifier. Purple rings: the bigger model answering once. Change the load, the size gap and the verifier.

14×
40%

Illustrative toy. The per-level accuracies and the bigger model’s growth with M are ours; only the exchange rate K and the three R values are Snell et al.’s. With the verifier off, the toy picks by majority vote. "Hard" means levels 4 and 5.

The toy reproduces the paper’s pattern. On easy and medium questions, which the small model sometimes solves, extra samples beat the bigger model. On the hardest questions it almost never writes a right answer, so no checker helps, and the bigger model wins. Heavy serving shrinks K and moves the line toward pretraining.

The lecture’s timeline: Let’s Verify Step by Step showed test-time gains in May 2023. Snell et al. followed in August 2024, and OpenAI’s o1 made the idea popular in September 2024. Its takeaways: do not default to the largest model, and invest in verification.

Symptom: a big sampling budget buys almost nothing on your hardest questions.

Measure: one-shot accuracy and coverage per difficulty level.

Fix: route by difficulty. Sample more where coverage is rising; send near-zero cases to a bigger model.

When does a 14 times bigger model beat a small model with the same total FLOPs spent on samples?

Chapter 10

Field Guide

Keep the four tools, the numbers and the code, and see where to go next

A reasoning model pays for its chains four ways. Draft-and-check makes each big pass write several tokens with exactly the big model’s distribution. RL on long chains runs asynchronously, so its rollouts go stale and need weights or clipping. On-policy distillation lets a teacher grade every token the student writes. RoPE scaling stretches the window. More samples help only where a checker can find a right answer, and the checker sets the ceiling.

ToolWhat it buysKey ideaWatch for
Speculative decodingseveral tokens per big pass, same distributionkeep with min(1, p/q); else draw from the residuallow α; costly drafts; mismatched sampling settings
Asynchronous RLGPUs busy while long rollouts finishimportance weights, clipped per tokenESS falling as rollouts go stale
On-policy distillationa small model that reasons like a big one, cheaplystudent writes, teacher scores each token, reverse KLa weak teacher; dropped modes you needed
RoPE scalinglonger context with brief fine-tuningsqueeze slow pairs, keep fast pairsshort-text regressions; unused middle of the window
Best-of-N and verifiersaccuracy from extra samplescoverage 1 − (1 − p)N, then a checker picksp near 0; a checker the search can fool
NumberValueWhere
70B model, least time per token at 3.35 TB/s; a 10,000-token chain41.8 ms; 418 sChapter 0
Keep chances in the slides’ example; tokens per pass1, 1, 0.889, 0.375, 1; 4.56Chapter 1
T5-small for T5-XXL: tokens per cycle, predicted and measured speedup3.60; 3.16×; 3.4×Chapter 3
T5-large draft: predicted and measured speedup2.50×; 1.7×Chapter 3
Weights 2.0, 0.5, 0.5, 1.0: ESS0.727Chapter 4
Qwen3-8B on AIME’24: RL against on-policy distillation (GPU hours)67.6% (17,920); 74.4% (1,800)Chapter 5
RoPE, d = 128: full turn of pair 0, of pair 636.3; 54,410 tokensChapter 6
Trained length 4,096: pairs that never finish a turn18 of 64Chapter 7
YaRN logit factor at s = 8; NTK-aware base at s = 81.46; 82,685Chapter 7
MATH, best-of-1,860: PRM, ORM, majority vote78.2%, 72.4%, 69.6%Chapter 8
Exchange rate K at M = 14 for R = 0.16, 0.79, 22257.75, 63.37, 15.77Chapter 9

The core as code: one draft-and-check step, the effective sample size, the per-token reverse KL, RoPE with PI, and coverage.

python
import numpy as np
rng = np.random.default_rng(0)

def spec_step(p_rows, q_rows, drafts):
    """p_rows[i], q_rows[i]: target and draft distributions at guess i (one more p row at the end)."""
    out = []
    for i, x in enumerate(drafts):
        p, q = p_rows[i], q_rows[i]
        if rng.random() < min(1.0, p[x] / q[x]):      # keep with min(1, p/q)
            out.append(x); continue
        r = np.maximum(0, p - q); r /= r.sum()          # residual p'(x)
        out.append(rng.choice(len(p), p=r)); return out
    out.append(rng.choice(len(p_rows[-1]), p=p_rows[-1]))  # all kept: one bonus token
    return out

def ess(w):                                   # (sum w)^2 / (N sum w^2)
    w = np.asarray(w, float); return w.sum()**2 / (len(w) * (w**2).sum())
print(round(ess([2.0, .5, .5, 1.0]), 3))           # 0.727

def token_penalty(logp_student, logp_teacher):    # one sample of the reverse KL
    return logp_student - logp_teacher              # advantage = minus this
print(round(token_penalty(np.log(.4), np.log(.1)), 2))   # 1.39

def rope(x, pos, base=10000.0, L=None, L_new=None):
    d = x.shape[-1]
    if L and L_new: pos = pos * L / L_new             # Position Interpolation
    theta = base ** (-np.arange(0, d, 2) / d)         # one angle per pair
    a = pos[:, None] * theta[None, :]
    x1, x2 = x[..., 0::2], x[..., 1::2]
    return np.stack([x1*np.cos(a) - x2*np.sin(a), x1*np.sin(a) + x2*np.cos(a)], -1).reshape(x.shape)

coverage = lambda p, N: 1 - (1 - p)**N
print(round(coverage(.1, 10), 3))                     # 0.651

Where it went next

The slides point to faster drafters such as EAGLE-3 and SuffixDecoding, and to RL systems that update weights mid-rollout. They also show on-policy distillation restoring chat skills after training on a company’s documents. Lecture 14 turns to tokenization, which decides how many tokens a chain costs.

Keep going

Read next

The habit. Checking is cheaper than writing. A big model checks a small model’s guesses, a teacher grades a student’s tokens, a verifier picks among samples. Put the expensive model where it checks.
What do speculative decoding, on-policy distillation and best-of-N share?

Now teach it: press Present or Teach. Explain why draft-and-check gives the big model’s exact distribution, why stale rollouts lose weight, and why more samples cannot fix p = 0. Then go back to the hero, choose T5-large, and say why the better guesser loses the race.

Reasoning 2 · Stanford CS224N, Lecture 13
Before: Reasoning 1 · Next: Tokenization and Multilinguality · Course site · Back to Gleams