Fast Inference from Transformers via Speculative Decoding
In speculative decoding a small draft model guesses several tokens, the large model verifies them in one parallel pass, and a sampling rule keeps the output distribution unchanged. This post reads the paper's formulas, recomputes its Tables 1 and 4, and explains the 1.4x to 3.4x measured on T5-XXL.
On this page
- Background: why decoding is slow and what came before
- Method: speculative sampling and one round of decoding
- Casting every sampling method as the same thing
- What one round does
- Why the output distribution does not change
- Analysis: what determines the speedup
- Recomputation: are the paper’s numbers right?
- Experiments: 1.4x to 3.4x on T5-XXL
- Setup
- Results
- Easy-to-miss details
- Limits, and what came after
- What to take away from this paper
- Further reading
- FAQ
The paper by Leviathan, Kalman and Matias (on arXiv in November 2022, an oral at ICML 2023) answers one concrete question: can a large model decode faster without changing the model, without retraining, and without changing the output distribution? Its answer is speculative decoding. A small, fast draft model first guesses tokens, the large model verifies those candidates in one parallel forward pass, each candidate is accepted with a probability, and at the first rejected position a token is resampled from a corrected distribution. Every call to the large model produces at least 1 token and at most . On T5-XXL (11B) the paper measures speedups of 1.4x to 3.4x (batch size 1, a single TPU-v4, against the standard T5X implementation).
This page reads the paper itself: its assumptions, its formulas, its experiments and the places where it is less than clear. If you would rather start with intuition and an interactive lab, read the wiki page on speculative decoding first.
Background: why decoding is slow and what came before
An autoregressive model needs serial runs to generate tokens, because each token depends on the previous one. The paper builds on two observations. First, a single inference step of a large model is often limited not by arithmetic but by memory bandwidth and communication, so the accelerator often has spare compute (a worked example is in KV Cache and Inference Performance and on the wiki page above). Second, not every step is hard: difficult generation tasks contain many easy subtasks that a small model approximates well.
Earlier speedups fall into two groups. One lowers the cost of every token equally: distillation, sparsification, quantization, architecture changes. The other is adaptive computation, which spends less on easy steps, for example early exit. The paper points out that these usually need a different architecture, a different training procedure or retraining, and that the outputs change. The two closest earlier works each have a limitation. Blockwise Parallel Decoding (Stern et al., 2018) also decodes several tokens in parallel, but it supports only greedy decoding (temperature 0), needs an extra custom-trained model, and aims at preserving downstream quality rather than guaranteeing identical outputs. Shallow Aggressive Decoding (Sun et al., 2021) can only copy the input into the output, which suits tasks like grammatical error correction where the output is nearly the input, and it does not support general stochastic sampling.
The starting point is an old trick in processors, speculative execution: start a task in parallel before it is known whether it is needed, and win concurrency if the guess was right. The paper generalizes it to stochastic sampling and makes two contributions: a new sampling method called speculative sampling, and a mechanism that uses it to accelerate autoregressive models, called speculative decoding.
Method: speculative sampling and one round of decoding
Casting every sampling method as the same thing
Greedy, top-, nucleus sampling and temperature are usually handled separately at the logits level. The paper (Section 2.2) observes that all of them can be seen as standard sampling from an adjusted distribution: greedy, for instance, zeroes out every probability except the maximum and renormalizes. So only two distributions, already adjusted for the sampling method, need to be handled: from the target model and from the draft model (the paper calls it the approximation model). In the experiments the draft distribution always receives the same adjustment as the target’s.
What one round does
- Guess. samples candidates autoregressively and records its distribution at each step.
- Verify. runs on the prefix extended by candidates, in parallel, which gives at positions.
- Accept. Draw for each candidate; is accepted if . Counting from the left, let be the number of candidates accepted before the first rejection, that is .
- Add one token. Sample a token from . If , , the corrected distribution; if , . The round outputs .
The target model contributes at least one token per round (the last one), so in the worst case its number of serial calls is no higher than in ordinary decoding; with luck a round yields tokens. Figure 1 of the paper gives an example: a 97M-parameter GPT-like target model trained on lm1b, a 6M-parameter draft, a sentence of 38 tokens, and the target model ran serially only 9 times, about 4.2 tokens per run.
Why the output distribution does not change
Look at a single position. Let be the total probability that a drafted token is accepted (Theorem 3.5); the normalizing constant of the corrected distribution is exactly . The probability of outputting is “proposed and accepted” plus “rejected and then filled in”:
That is the whole proof in Appendix A.1. It holds for any and , so however poor the draft model is, the output distribution does not change; only the speed does. Appendix A.1 proves the single-position statement; every token that is output is drawn after the tokens already output, from the target model’s conditional distribution, so the statement holds for the whole sequence as well. A step-by-step derivation and a runnable numerical check are on the wiki page on speculative decoding.
Analysis: what determines the speedup
Section 3 of the paper explains the speedup with a handful of formulas. Here is the overview, followed by how to read each item.
| Quantity | Formula | Where | Note |
|---|---|---|---|
| Acceptance rate | Definition 3.1, Theorem 3.5 | Probability that a drafted token is accepted for a given prefix; the paper’s is the total variation distance | |
| Mean acceptance rate | Corollary 3.6 | Depends only on the two models and the task, not on hardware | |
| Expected tokens per round | Equation (1) | Assumes the of different positions are i.i.d.; the count is a geometric variable capped at | |
| Cost coefficient | time of one draft step ÷ time of one target step | Definition 3.7 | Depends on hardware and implementation |
| Speedup | Theorem 3.8 | Assumes enough compute to run positions in parallel at no extra time | |
| Growth of total operations | Theorem 3.11 | is the ratio of operations per token, draft to target |
- Two numbers decide everything: and . is a property of the models and the task, a property of the hardware and the implementation. A bigger draft has a higher and a higher , which is the central trade-off. When the draft is almost free (the paper’s negligible-cost approximation models, ) the speedup is bounded by , and a larger comes closer to it.
- A speedup requires (Corollary 3.9). For the speedup is exactly . The paper proves that if some gives a speedup, every smaller does too, so if is not faster there is no point in trying longer drafts; conversely, when some always gives a speedup of at least .
- Operations go up, memory accesses go down. The target model computes positions in parallel each round and rejected candidates waste work, so the total number of operations exceeds that of ordinary decoding (Theorem 3.11). But the target model’s weights and KV cache are read once per round, so the number of reads per generated token shrinks by the factor . Latency falls because more arithmetic buys fewer reads, which only works when decoding really is memory-bound and compute is spare.
- is an integer, so solve for it numerically. Given and , the best is the integer that maximizes the speedup (Figure 3 of the paper). If the of each position could be predicted and adapted on the fly, a round would yield tokens in expectation; the paper estimates that, for typical and and unbounded compute, this could be up to about 60% higher than the speedup with a fixed , and leaves it to future work.
- The draft does not have to be a neural network. Section 3.6 lists several kinds: off-the-shelf small models of the same architecture, where about two orders of magnitude smaller usually worked best in the experiments; n-gram models, where evaluation is a table lookup and ; heuristics that find a matching prefix in the context and copy what follows, which suits summarization and editing where the output repeats the input; non-autoregressive models, called once in place of the draft loop; and even a “draft” that picks tokens at random, which still guarantees a very small speedup.
- Classical rejection sampling is worse than speculative sampling. Appendix A.2 compares it: its per-step acceptance probability is at most and can be much lower.
Recomputation: are the paper’s numbers right?
The script below writes Theorems 3.8 and 3.11 as three functions and checks the paper’s Table 1 (assuming ), the expected column of Table 4 (EXP) and a few numbers quoted in the text.
def tokens(a, g):
"""Equation (1): expected tokens per run of the target model."""
return (1 - a ** (g + 1)) / (1 - a)
def speed(a, g, c):
"""Theorem 3.8: walltime improvement factor."""
return tokens(a, g) / (g * c + 1)
def ops(a, g, c_hat):
"""Theorem 3.11: growth of the total number of arithmetic operations."""
return (g * c_hat + g + 1) / tokens(a, g)
# Table 1 of the paper (c = c_hat = 0): alpha, gamma, operations, speed
TABLE1 = [(0.6, 2, 1.53, 1.96), (0.7, 3, 1.58, 2.53), (0.8, 2, 1.23, 2.44),
(0.8, 5, 1.63, 3.69), (0.9, 2, 1.11, 2.71), (0.9, 10, 1.60, 6.86)]
same = all(round(ops(a, g, 0), 2) == o and round(speed(a, g, 0), 2) == s
for a, g, o, s in TABLE1)
print("Table 1, all 12 numbers reproduced:", same)
# Table 4: task, draft model, temperature, gamma, alpha, c, EXP, EMP
TABLE4 = [
("EnDe", "small", 0, 7, 0.75, 0.02, 3.2, 3.4),
("EnDe", "base", 0, 7, 0.80, 0.04, 3.3, 2.8),
("EnDe", "large", 0, 7, 0.82, 0.11, 2.5, 1.7),
("EnDe", "small", 1, 7, 0.62, 0.02, 2.3, 2.6),
("EnDe", "base", 1, 5, 0.68, 0.04, 2.4, 2.4),
("EnDe", "large", 1, 3, 0.71, 0.11, 2.0, 1.4),
("CNNDM", "small", 0, 5, 0.65, 0.02, 2.4, 3.1),
("CNNDM", "base", 0, 5, 0.73, 0.04, 2.6, 3.0),
("CNNDM", "large", 0, 3, 0.74, 0.11, 2.0, 2.2),
("CNNDM", "small", 1, 5, 0.53, 0.02, 1.9, 2.3),
("CNNDM", "base", 1, 3, 0.55, 0.04, 1.8, 2.2),
("CNNDM", "large", 1, 3, 0.56, 0.11, 1.6, 1.7),
]
print("task draft T mine EXP EMP range if alpha, c are rounded")
for task, m, t, g, a, c, exp, emp in TABLE4:
ends = [speed(a + da, g, c + dc)
for da in (-0.005, 0.005) for dc in (-0.005, 0.005)]
print(f"{task:5s} {m:5s} {t} {speed(a, g, c):4.2f} {exp:4.1f} {emp:4.1f}"
f" {min(ends):.2f} to {max(ends):.2f}")
print("bigram draft: alpha=0.2, c=0, gamma=3 ->", round(speed(0.2, 3, 0), 3))
print("gamma=1, alpha=0.75, c=0.02:", round(speed(0.75, 1, 0.02), 3),
"and (1+alpha)/(1+c) =", round(1.75 / 1.02, 3))
for c in (0.01, 0.05, 0.1):
best = {a: max(range(1, 40), key=lambda g: speed(a, g, c))
for a in (0.6, 0.7, 0.8, 0.9)}
print(f"c={c}, best gamma and speed:",
{a: (g, round(speed(a, g, c), 2)) for a, g in best.items()})
# Appendix A.5, lenience l = 1, 0.5, 0.3, 0.1, with c = 0.015
def best(a):
return max(speed(a, g, 0.015) for g in range(1, 60))
print("T=0, gamma=8:", [round(speed(a, 8, 0.015), 1)
for a in (0.75, 0.75, 0.80, 0.87)])
print("T=1, best gamma:", [round(best(a), 1) for a in (0.62, 0.71, 0.76, 0.84)])
Output:
Table 1, all 12 numbers reproduced: True
task draft T mine EXP EMP range if alpha, c are rounded
EnDe small 0 3.16 3.2 3.4 3.02 to 3.30
EnDe base 0 3.25 3.3 2.8 3.12 to 3.39
EnDe large 0 2.50 2.5 1.7 2.41 to 2.59
EnDe small 1 2.26 2.3 2.6 2.17 to 2.36
EnDe base 1 2.35 2.4 2.4 2.27 to 2.42
EnDe large 1 1.93 2.0 1.4 1.90 to 1.97
CNNDM small 0 2.40 2.4 3.1 2.32 to 2.48
CNNDM base 0 2.62 2.6 3.0 2.54 to 2.71
CNNDM large 0 2.02 2.0 2.2 1.99 to 2.06
CNNDM small 1 1.89 1.9 2.3 1.83 to 1.95
CNNDM base 1 1.80 1.8 2.2 1.77 to 1.84
CNNDM large 1 1.54 1.6 1.7 1.51 to 1.57
bigram draft: alpha=0.2, c=0, gamma=3 -> 1.248
gamma=1, alpha=0.75, c=0.02: 1.716 and (1+alpha)/(1+c) = 1.716
c=0.01, best gamma and speed: {0.6: (7, 2.3), 0.7: (9, 2.97), 0.8: (14, 4.23), 0.9: (24, 7.49)}
c=0.05, best gamma and speed: {0.6: (4, 1.92), 0.7: (6, 2.35), 0.8: (8, 3.09), 0.9: (13, 4.67)}
c=0.1, best gamma and speed: {0.6: (3, 1.67), 0.7: (4, 1.98), 0.8: (6, 2.47), 0.9: (10, 3.43)}
T=0, gamma=8: [3.3, 3.3, 3.9, 4.9]
T=1, best gamma: [2.3, 2.9, 3.4, 4.8]
- All 12 numbers of Table 1 are reproduced: the growth in operations and the speedup for six pairs . For example spends 1.63x the operations for 3.69x the speed, and spends 1.60x for 6.86x.
- The expected column of Table 4 is Theorem 3.8. Plugging in the and of the table, 9 of the 12 rows agree with the paper’s value (one decimal) and 3 rows (the temperature-1 English-German rows for T5-base and T5-large, and the temperature-1 summarization row for T5-large) differ by 0.05 to 0.07. The and in the table have only two decimals; when each is moved by up to 0.005 up or down, the recomputed range (last column) overlaps the paper’s value (read as a interval) in every row, so there is no hidden correction term.
- Bigram draft: gives 1.248x, matching the paper’s “about 1.25x”.
- The lower bound at : gives 1.716x, equal to .
- Best : the smaller and the larger , the longer it pays to guess. At the best is 8 for (3.09x) and 13 for (4.67x); at , needs (7.49x).
Experiments: 1.4x to 3.4x on T5-XXL
Setup
The target model is T5-XXL (11B, T5 v1.1) on two tasks from the T5 paper: English-German translation fine-tuned on WMT EnDe, and summarization fine-tuned on CNN/DM. The draft models are existing checkpoints: T5-large (800M), T5-base (250M) and T5-small (77M). On a single TPU-v4 at batch size 1, the paper compares wall time against the standard implementation in the T5X codebase, for greedy decoding (temperature 0) and standard sampling (temperature 1).
Results
The table merges the paper’s Tables 2 and 4: besides the measured speedup it lists the cost coefficient and the expected speedup from Theorem 3.8.
| Task | Draft model | Temperature | Expected speedup | Measured speedup | |||
|---|---|---|---|---|---|---|---|
| English-German translation | T5-small | 0 | 7 | 0.75 | 0.02 | 3.2 | 3.4 |
| English-German translation | T5-base | 0 | 7 | 0.80 | 0.04 | 3.3 | 2.8 |
| English-German translation | T5-large | 0 | 7 | 0.82 | 0.11 | 2.5 | 1.7 |
| English-German translation | T5-small | 1 | 7 | 0.62 | 0.02 | 2.3 | 2.6 |
| English-German translation | T5-base | 1 | 5 | 0.68 | 0.04 | 2.4 | 2.4 |
| English-German translation | T5-large | 1 | 3 | 0.71 | 0.11 | 2.0 | 1.4 |
| Summarization | T5-small | 0 | 5 | 0.65 | 0.02 | 2.4 | 3.1 |
| Summarization | T5-base | 0 | 5 | 0.73 | 0.04 | 2.6 | 3.0 |
| Summarization | T5-large | 0 | 3 | 0.74 | 0.11 | 2.0 | 2.2 |
| Summarization | T5-small | 1 | 5 | 0.53 | 0.02 | 1.9 | 2.3 |
| Summarization | T5-base | 1 | 3 | 0.55 | 0.04 | 1.8 | 2.2 |
| Summarization | T5-large | 1 | 3 | 0.56 | 0.11 | 1.6 | 1.7 |
- The smallest draft is the fastest. T5-small has of only 0.02 and a decent , and gives the largest speedup (English-German, temperature 0: 3.4x). T5-large accepts most often (0.82) but, with , is too expensive and gives only 1.7x. The paper attributes this to the balance between and ; T5-small is the best of the drafts tested.
- Greedy decoding gains more than standard sampling. For the same draft, is higher at temperature 0: the paper observes that the sharper the adjusted distribution, the easier it is for the draft to guess right. On English-German, T5-small’s rises from 0.62 to 0.75 and the speedup from 2.6x to 3.4x.
- Theory and measurement agree broadly, with systematic deviations. Measured minus expected ranges from −0.8x to +0.7x. All six summarization rows are at or above the expectation; on English-German, the larger drafts (T5-base and T5-large with greedy decoding, −0.5 and −0.8; T5-large at temperature 1, −0.6) fall clearly below it. In Appendix A.3 the paper attributes the gaps to two things: optimization differences between its implementation and the baseline, and the i.i.d. assumption on being only an approximation.
The paper also measured in more settings (Section 4.2, Table 3), estimating the expectation of Corollary 3.6 on 10K tokens generated by the target model.
| Target model and task | Draft model | (temperature 0) | (temperature 1) |
|---|---|---|---|
| GPT-like 97M, lm1b unconditional generation | Unigram | 0.03 | 0.03 |
| GPT-like 97M, lm1b unconditional generation | Bigram | 0.05 | 0.05 |
| GPT-like 97M, lm1b unconditional generation | GPT-like 6M | 0.88 | 0.89 |
| T5-XXL, English-German translation | Unigram | 0.08 | 0.07 |
| T5-XXL, English-German translation | Bigram | 0.20 | 0.19 |
| T5-XXL, English-German translation | T5-small | 0.75 | 0.62 |
| T5-XXL, English-German translation | T5-base | 0.80 | 0.68 |
| T5-XXL, English-German translation | T5-large | 0.82 | 0.71 |
| T5-XXL, CNN/DM summarization | Unigram | 0.13 | 0.08 |
| T5-XXL, CNN/DM summarization | Bigram | 0.23 | 0.16 |
| T5-XXL, CNN/DM summarization | T5-small | 0.65 | 0.53 |
| T5-XXL, CNN/DM summarization | T5-base | 0.73 | 0.55 |
| T5-XXL, CNN/DM summarization | T5-large | 0.74 | 0.56 |
| LaMDA 137B, dialog | LaMDA 100M | 0.61 | 0.57 |
| LaMDA 137B, dialog | LaMDA 2B | 0.71 | 0.71 |
| LaMDA 137B, dialog | LaMDA 8B | 0.75 | 0.74 |
- For drafts about two orders of magnitude smaller than the target, is mostly between 0.5 and 0.9. This is the paper’s summary (“tend to produce α values between 0.5 and 0.9”). Every neural draft in the table has an between 0.53 and 0.89: T5-small is about 140 times smaller than T5-XXL, LaMDA 100M more than a thousand times smaller than 137B, and the GPT-like 6M draft is only 16 times smaller than its 97M target yet has the highest (0.88 and 0.89).
- Almost free drafts are useful too. A unigram or bigram model is evaluated by table lookup and has an between 0.03 and 0.23, which is not zero. On English-German the bigram model has , and with and the speedup is 1.25x, far below T5-small’s 3.4x but needing no neural network at all.
- Temperature affects the neural drafts consistently. For the three neural drafts on T5-XXL, at temperature 0 is 0.11 to 0.18 higher than at temperature 1.
- LaMDA’s outputs went through a top-40 filter. The footnote of Table 3 says this has no effect on greedy decoding and some effect on standard sampling. LaMDA was only measured for ; the method was not implemented for it.
Easy-to-miss details
- The lenience variant (Appendix A.5). Multiply by a lenience factor before comparing it with . The acceptance rate rises, but the output distribution is no longer exactly : what is guaranteed is only that no token is sampled with probability above . With , for example, no token can be inflated by more than 10x and extremely rare tokens stay extremely rare; there is no guarantee on a lower bound of the probability, so the diversity of samples may suffer. The paper’s main results use the strictest version. In Table 5, for English-German with standard sampling, a T5-small draft has of 0.62, 0.71, 0.76 and 0.84 at , and T5-base 0.68, 0.80, 0.83 and 0.90. Greedy decoding has a similar relaxation, with of 0.75, 0.75, 0.80 and 0.87; with and the speedups are 3.3x, 3.3x, 3.9x and 4.9x, and the script above reproduces these numbers. For standard sampling the paper gives 2.5x, 3.1x, 3.6x and 5x; with Theorem 3.8, the best and I only get 2.3x, 2.9x, 3.4x and 4.8x, for reasons I could not find, so I do not quote those four.
- Beam search (Appendix A.4). It can be used, at some performance cost: run beam search with the draft model at a wider beam width for steps, check all candidates in parallel with the target model (a budget of target runs), and accept as long as the target’s top candidates are inside the draft’s top ; the result then equals that of beam search with the target alone. The paper leaves the analysis to future work.
- “Identical outputs” in the conclusion means distribution. The abstract says “identical outputs”; precisely, the output distribution is identical. At temperature 0 it is the same greedy sequence (up to floating-point differences); with sampling it is the same distribution, not the same sample path.
Limits, and what came after
The limits the paper states itself: latency is improved through increased concurrency at the cost of more arithmetic operations, so the method does not help in configurations without spare compute; it was implemented only for T5, and for other models only was measured; only text was tested; the draft model and are fixed during decoding; the main results do not use lenience, and the analysis for beam search is left to later work.
Two further cautions are the reader’s, not the paper’s. First, the 1.4x to 3.4x are for batch size 1, a single TPU-v4 and the T5X baseline. Online serving usually packs many requests into a large batch, where decoding no longer has spare compute and the gain shrinks; an estimate is on the wiki pages on speculative decoding and serving. Second, the paper’s was measured on text generated by the target model itself; another task or sampling setting changes it (on T5-XXL, at temperature 0 and 1 already differs by 0.11 to 0.18).
The idea has been widely reused since. Chen et al. at DeepMind (2023) independently implemented the same idea as speculative sampling and report 2x to 2.5x on Chinchilla 70B; the paper’s related-work section mentions it. Later, Medusa added decoding heads on top of the target model and EAGLE drafts at the feature level, so neither needs a separate draft model, and DeepSeek-V3 reuses its training-time multi-token-prediction module as the draft. The wiki page on speculative decoding compares these, and the DeepSeek-V3 report post also discusses the acceptance rate.
What to take away from this paper
- It exploits the fact that decoding is memory-bound with spare compute. Verifying positions in parallel is nearly free, so it pays to compute a little more in order to call the large model fewer times.
- Speculative sampling keeps the distribution unchanged for any draft model. The draft only affects speed, and the proof is one line: an accepted token contributes and a rejection adds .
- Two numbers decide everything: belongs to the models and the task, to the hardware and the implementation. At the speedup is , so it is worth trying only when ; a bigger draft has a higher but also a higher , and in the experiments a draft two orders of magnitude smaller worked best.
- The price is more arithmetic. The 1.4x to 3.4x was bought by spending compute on latency, and the numbers belong to a batch-size-1 T5-XXL experiment; do not extrapolate them directly to large-batch serving.
Further reading
- Wiki: Speculative Decoding has an interactive lab and a runnable numerical check; Decoding and Sampling explains greedy, top-, nucleus sampling and temperature; KV Cache and Inference Performance and Serving explain why decoding is memory-bound.
- Chen et al., Accelerating Large Language Model Decoding with Speculative Sampling (2023): the concurrent, independent work.
- Two other routes to faster inference: vLLM and PagedAttention optimizes cache management in the serving system, and FlashAttention optimizes the IO of the attention operator itself.
- The paper: Leviathan, Kalman and Matias, Fast Inference from Transformers via Speculative Decoding (ICML 2023). The formulas, tables and quotations on this page are from arXiv v2.
FAQ
- How does speculative decoding speed up autoregressive inference?
- A small, fast draft model first guesses γ tokens, and the large model verifies all of them in a single parallel forward pass. Accepted tokens are confirmed at once; at the first rejected position the large model resamples one token from a corrected distribution. Each round produces at least 1 and at most γ+1 tokens, so the number of serial calls to the large model is never higher than in ordinary decoding. On T5-XXL (11B) the paper measures speedups of 1.4x to 3.4x (batch size 1, one TPU-v4, against the standard T5X implementation).
- Does speculative decoding change the output distribution?
- No. A drafted token is accepted with probability min(1, p/q) and a rejected one is replaced by a sample from norm(max(0, p−q)), so the distribution at every position is exactly the target model's p, for any draft model q (Appendix A.1 of the paper). The draft model only affects speed. With temperature 0 the result is the target model's own greedy sequence, up to floating-point differences. The exception is the optional lenience variant of Appendix A.5, which trades some distribution change for a higher acceptance rate; the paper's main experiments do not use it.
- What determines the speedup, and how is it computed?
- Three quantities: the acceptance rate α (the average probability that a drafted token is accepted), the cost coefficient c (the time of one draft step divided by the time of one target step) and the draft length γ. The speedup is (1−α^(γ+1)) / ((1−α)(γc+1)) (Theorem 3.8). For γ=1 it is (1+α)/(1+c), so a speedup is only possible when α>c. In the paper's Table 4 the measured speedup differs from this expectation by −0.8x to +0.7x.
- How should the draft model be chosen, and what acceptance rate is typical?
- The paper used off-the-shelf small models of the same architecture and found that a draft about two orders of magnitude smaller than the target usually works best, because α and c have to be balanced; for such drafts α is mostly between 0.5 and 0.9. On T5-XXL the 77M T5-small was fastest (α=0.75 and a 3.4x speedup for English-German translation with greedy decoding), while the larger T5-large accepted more often (α=0.82) but gave only 1.7x. Even a trivial unigram or bigram model has a nonzero α (about 0.2 for a bigram model on translation, which gives 1.25x at γ=3).
- When is speculative decoding not worth it?
- The paper states that it buys lower latency with more concurrency, so the total number of arithmetic operations goes up (Table 1: with a free draft, α=0.8 and γ=5 spend 1.63x the operations to get 3.69x the speed). It does not help when there is no spare compute. If α≤c no choice of γ gives a speedup, and a draft that is too expensive or too inaccurate makes decoding slower.