Highlights

Contents

Part VI
06

Drafting more than one token

A cheap draft can reduce expensive sequential target work. Incorrect verification changes the generated distribution. Follow acceptance, replacement, and suffix rejection before asking whether the whole round is faster.

THE ARCHITECTURE INVESTIGATIONCost + future tokens01Sparse connections02Compressed history03Latent memory04Compare KV designs05Speculative decoding06Controlled experiment07Interpret + decide08

#Section 19Speculative decoding

The large model takes a costly pass to produce one token. A cheaper model could propose several tokens in that time, but a fast guess is no substitute for the target, so the target has to check it.

Draft model, target model, and candidate tokens

Speculative decoding uses a cheap draft model to propose tokens and a target model to verify them. From the accepted prefix, the draft samples candidates autoregressively. The target then runs the candidate sequence through one causally masked forward pass, getting its next-token distribution at every candidate position.

Each candidate is still conditioned on the ones before it. Verification runs in parallel only because all proposed inputs are already known. If every candidate passes, the same pass also gives the distribution for a bonus token.

VERIFY AN ORDERED PREFIX, THEN DISCARD THE REJECTED SUFFIXdraftboltisredtodaytarget argmaxboltisblueunusedemitboltisbluediscardverified prefixrestart after blue
Figure 6.20An illustrative four-token draft agrees with the target’s greedy choices for two tokens. At the first mismatch, the later draft suffix is discarded and the target token replaces the mismatch.

Verification and accept/reject behavior

For greedy decoding, compare each draft token with the target’s argmax under that prefix and keep the longest matching run. At the first mismatch, emit the target’s argmax, drop the remaining candidates, and draft again. With exact target computation and the same tie-breaking, this reproduces the greedy target output.

For sampling, keeping tokens that happen to match is not exact. Let q(x)q(x) be the draft probability of candidate xx and p(x)p(x) the target probability at the same prefix. Accept with probability

a(x)=min⁡(1,p(x)q(x)).a(x)=\min\left(1,\frac{p(x)}{q(x)}\right).

Read this as always accept proposals the draft underweights, and thin out those it overweights. On rejection, draw a replacement from the normalized positive difference max(0,p-q), drop later candidates, and continue. Use the distributions after the declared temperature and filters.

Accepting several tokens per target pass

The positive difference [max(0,0.3-0.6),max(0,0.7-0.4)]=[0,0.3] normalizes to [0,1], so every rejection becomes B. Final mass is [0.3,0.4+0.3]=[0.3,0.7], exactly the target.

CORRECT THE REJECTED MASS TO RECOVER THE TARGETdraft qA: 0.6 B: 0.4acceptedA: 0.3 B: 0.4replacementA: 0.0 B: 0.3final pA: 0.3 B: 0.7accepted plus replacement: [0.3, 0.7]
Figure 6.21Computed probability mass shows where rejected A proposals go. Accepted draft mass plus corrected replacement mass equals the target distribution.

In general, accepted mass at xx is min(p(x),q(x)) and the correction adds max(0,p(x)-q(x)); together they give p(x). Applied at each prefix, this preserves the target sampling distribution, though not identical sample paths unless the random draws are coupled.

Leviathan, Kalman, and Matias described exact speculative decoding in 2022, published 2023. Speculative decoding paper. The guarantee covers the declared target distribution, not a different sampler or approximate verification.

#Section 20Speculative decoding performance

A speculative implementation accepts many tokens and still runs slower than plain decoding. The verifier was efficient; the draft's cost and synchronization ate the saving.

Acceptance rate and draft-model speed

The acceptance rate is how often draft candidates survive verification. A smaller draft is cheaper but agrees less; a larger one agrees more but costs more. Measure agreement and cost together.

In a simplified model with draft length KK and a constant, independent acceptance probability α\alpha per position, the expected tokens per round, counting the replacement or bonus token, is

E[N]=∑i=0Kαi.E[N]=\sum_{i=0}^{K}\alpha^i.

Read this as a round always emits one token, a second if the first candidate survives, and so on up to all KK plus a bonus. Real acceptance varies with position and prefix; this is a simplification.

At K=4 and alpha=0.8, E[N]=1+0.8+0.64+0.512+0.4096=3.3616 tokens, an average over rounds rather than a count any round emits.

Verification cost and when speculation helps

With draft time tDt_D per token, verification time tV(K)t_V(K), and ordinary target time tTt_T per token, ignoring other overhead:

S=tTE[N]KtD+tV(K).S=\frac{t_T E[N]}{K t_D+t_V(K)}.

Read this as ordinary time for the expected output divided by one speculative round's time. Speculation helps when S>1S>1. Verification costs less than KK target passes but grows with KK.

ACCEPTANCE MUST PAY FOR THE ROUNDordinary decoding: 1x0.781x2.101x0.00.20.40.60.81.0conditional acceptance probability
Figure 6.22Computed speed ratios assume a 1 ms draft step, a 12 ms four-candidate verification pass, and a 10 ms ordinary target step. These are arithmetic fixtures, not hardware measurements.

Speculation has the most room when target decoding is bound by weight movement and verification reuses those weights across positions. At high batch or with a compute-heavy verifier the balance shifts, and draft memory, transfers, sampling, and synchronization all count. Measure end to end to pick the draft length.