Speculative Decoding Speedup Calculator

Estimate the walltime speedup from speculative decoding using the acceptance rate, draft length and draft model cost.

Uses Theorem 3.8 from Leviathan, Kalman and Matias (2023) and finds the best number of draft tokens.

Last updatedHow we build & check our tools
Results will appear here once you enter your values.

How speculative decoding speeds up generation

Autoregressive decoding runs the large target model once per token, and each run is limited mostly by memory bandwidth, not arithmetic. Speculative decoding lets a small draft model propose gamma tokens, then the target model scores all of them in one parallel forward pass. Drafted tokens are accepted left to right with a rejection sampling rule that keeps the output distribution identical to the target model, so quality does not change.

Every step yields at least one token, because when a draft token is rejected the target model samples a corrected token in its place. When all gamma drafts are accepted, the step yields gamma + 1 tokens. The calculator turns three numbers into an expected speedup: the acceptance rate alpha, the draft length gamma, and the cost coefficient c, which is the time for one draft forward pass divided by the time for one target forward pass.

The formulas and a worked example

Tokens per target pass. Treating each acceptance as an independent event with probability alpha, the expected number of tokens per step is E = (1 - alpha^(gamma+1)) / (1 - alpha). At alpha = 1 this limit is exactly gamma + 1, and at alpha = 0 it is 1.

Walltime speedup. One step costs gamma draft passes plus one target pass, or gamma*c + 1 target-pass units. Theorem 3.8 of the paper divides the two: speedup = (1 - alpha^(gamma+1)) / ((1 - alpha)(gamma*c + 1)).

Example. The paper measured alpha = 0.8 for a T5-base draft of T5-XXL (11B) with argmax sampling and estimated c = 0.04. With gamma = 7, E = (1 - 0.8^8) / 0.2 = 4.16 tokens per pass and the speedup is 4.16 / 1.28 = 3.25x, which the paper reports as 3.3x expected. A target model decoding at 30 tokens/sec would reach about 97.5 tokens/sec. Searching gamma from 1 to 20 shows gamma = 9 is slightly better for these inputs.

When speculative decoding makes things slower

The speedup falls below 1x when drafting costs more than it saves. Corollary 3.9 of the paper shows that if alpha is greater than c, some gamma gives a real speedup, and gamma = 1 already gives at least (1 + alpha) / (1 + c). The reverse also holds: because 1 + alpha + ... + alpha^gamma is never more than 1 + gamma*alpha, no draft length helps when alpha is at or below c. For example, alpha = 0.1 with c = 0.5 and gamma = 4 gives a speedup of 0.37x.

Long drafts have diminishing returns. The probability that all gamma tokens survive is alpha^gamma, so with alpha = 0.6 an eighth draft token is accepted less than 2% of the time while it still costs a full draft pass. Even with a free draft model the speedup can never exceed 1 / (1 - alpha), which is 5x at alpha = 0.8.

These are expected values under simplifying assumptions: batch size 1, acceptance events that are independent and identically distributed, and a generation long enough that the prompt pass does not dominate. Large batches, verification overhead and KV-cache bookkeeping all reduce the real gain.

Measuring alpha and c for your own models

Acceptance rate. Log how many draft tokens are accepted per step on prompts like your production traffic. If a run of steps averages n accepted drafts plus the one bonus or corrected token, solve E = n + 1 for alpha, or use the fraction of accepted draft tokens as a first estimate. Alpha rises when the draft model is trained on the same data as the target, and it is usually higher for greedy decoding than for temperature 1 sampling. In the paper, a T5-small draft reached alpha = 0.75 at temperature 0 but 0.62 at temperature 1.

Cost coefficient. Time a single decoding forward pass of each model on the same hardware and divide draft by target. The paper estimated c = 0.02 for T5-small, 0.04 for T5-base and 0.11 for T5-large drafting for an 11B target. A trivial bigram draft has c close to 0 and still gave alpha of about 0.2, a 1.25x gain at gamma = 3.

Frequently Asked Questions

Common questions about the Speculative Decoding Speedup Calculator

Higher is always better, but what matters is alpha compared with the cost coefficient c. In the original paper, T5 draft models for an 11B T5-XXL target reached alpha between 0.62 and 0.82. At alpha = 0.8 and c = 0.04 the expected speedup is about 3.3x with 8 or 9 draft tokens. If alpha is not above c, no draft length can produce a speedup.
From the same team

Stop paying per token — route AI requests to your own GPU

Wide Area AI is a local-first AI gateway: repeated requests hit an edge cache, the rest run free on your own hardware, and the cloud is only a failover. OpenAI-compatible endpoint, free tier.

Start routing — free

Sources & References

Fast Inference from Transformers via Speculative Decoding

Equation 1 for expected tokens per step, Theorem 3.8 walltime improvement factor, Corollary 3.9, and the Table 4 alpha, c and expected speedup values used in the presets and unit tests.

Accelerating Large Language Model Decoding with Speculative Sampling

Independent speculative sampling method reporting a 2 to 2.5x decoding speedup for the 70B Chinchilla model without changing sample quality.

Assisted Generation: a new direction toward low-latency text generation

Practical implementation of draft-and-verify decoding in Hugging Face Transformers via the assistant_model argument.