Speculative Decoding Math: Algorithms & Speedup Limits › Expected Speedup Analysis
Language AI HandbookAll chapters Speculative Decoding Math: Algorithms & Speedup Limits › Expected Speedup AnalysisOne section · Sections in this chapter4 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Understanding the expected speedup from speculative decoding requires analyzing how many tokens we expect to accept from each draft sequence and how this translates to wall-clock improvements. This analysis provides both theoretical insights and practical guidance for deploying speculative decoding systems.
The speedup analysis connects the abstract acceptance probability to concrete performance numbers. You might wonder why we need a full mathematical treatment rather than just running experiments. The answer is that experiments can only test specific configurations, while the mathematical framework reveals the basic tradeoffs. It tells us how speedup depends on draft model quality, draft length, and the relative speed of the two models. Armed with this formula, you can predict performance for new model pairs without running extensive benchmarks, and you can optimize configuration choices analytically.
Think of the speedup formula as a budget analysis. Each speculative decoding iteration has a cost (running the draft model multiple times and the target model once) and a benefit (generating multiple tokens in one iteration). The ratio of benefit to cost is the speedup. The mathematical framework makes this ratio precise and reveals how each parameter affects the balance.
Token Acceptance Probability
Let denote the average acceptance probability for a single token. Under simplifying assumptions where each position has the same acceptance rate, we can derive a clean expression for this probability. While real-world acceptance rates vary by position and context, this i.i.d. assumption provides valuable analytical insights and gives formulas that match empirical measurements reasonably well when using the observed acceptance rate as the input.
The expected acceptance probability is computed by averaging over all tokens that the draft model might propose, weighting each token's acceptance probability by how often the draft model proposes it:
where:
- : expected acceptance probability
- : expectation over tokens proposed by the draft model
- : draft model probability of token
- : target model probability of token
- : total probability mass overlap between the two distributions
This quantity measures the overlap between the draft and target distributions. When the distributions are identical, . When they are completely disjoint, . In practice, typically falls between 0.6 and 0.9 for well-matched draft and target model pairs. Because equals the distribution overlap, it directly measures draft model quality from first principles and connects acceptance rates to the statistical notion of distributional similarity.
Expected Accepted Tokens
Given a draft of length , the number of accepted tokens follows a truncated geometric distribution. This distribution arises because we accept tokens sequentially until the first rejection, but we stop at position even if no rejection has occurred. Under the i.i.d. assumption with uniform acceptance probability , the probability that the first tokens are all accepted is , and the probability of a rejection at position is .
Let be the number of tokens we generate (accepted drafts plus one from rejection sampling or the th position). The expected value is:
where:
- : expected number of accepted tokens (plus one verification)
- : draft sequence length
- : probability of accepting a single token
- : position of the first rejection
- : probability that the first rejection occurs at position
- : contribution from the case where all tokens are accepted
The first term accounts for rejecting at position (we keep tokens including the resampled one). The second term accounts for accepting all drafts (we get tokens including the bonus verification token).
We can simplify this sum by observing that is 1 plus the count of accepted draft tokens. Since the probability of accepting the first tokens is for all (under the simplified i.i.d. assumption), we can use the linearity of expectation:
where:
- : closed-form expected number of tokens generated per iteration
- : acceptance probability
- : draft length
- : sum of the geometric series
This closed-form expression shows that expected tokens per iteration grow as a geometric series in the acceptance probability. When is close to 1, almost all draft tokens are accepted, and approaches . When is close to 0, most drafts are rejected immediately, and approaches 1 (we generate just one token from the residual distribution). The geometric series structure is key: each additional draft token contributes to the expected yield, which decays exponentially with position, creating natural diminishing returns at longer draft lengths.
![Line chart showing expected tokens E[N] on the y-axis versus acceptance probability alpha on the x-axis for k values of 1, 3, 5, and 10; curves rise sharply toward their respective k+1 asymptotes as alpha approaches 1.](https://assets.mbrenndoerfer.com/_optimized/notebooks/12_speculative_decoding_math_files/expected-tokens-vs-alpha-1920w.webp)
The Speedup Formula
Let be the cost ratio, defined as the time for one target model forward pass divided by the time for one draft model forward pass. Typically since the target model is much larger. For example, if the target model has 70 billion parameters and the draft model has 7 billion parameters, we might expect to be roughly 10, depending on hardware and batching configurations. In memory-bandwidth-limited regimes (which describes most autoregressive inference), scales roughly with the ratio of model parameter counts.
Without speculative decoding, generating tokens requires target model passes, taking time . This is the baseline we are trying to beat. Each token requires a full forward pass through the large model, with no opportunity for parallelism across tokens in standard autoregressive generation.
With speculative decoding, each iteration requires:
- One draft model pass generating tokens, taking time
- One target model pass verifying all positions, taking time
The iteration produces tokens on average and takes time .
The speedup ratio compares how fast we generate tokens with speculative decoding versus standard autoregressive generation. We derive this by computing the time per token under both approaches and taking their ratio. Standard generation takes per token. Speculative decoding takes per token. The speedup is:
where:
- : speedup ratio (values above 1 mean speculative decoding is faster)
- : time for standard autoregressive generation per token
- : draft length
- : cost ratio ()
- : acceptance probability (used in )
- : cost of one speculative iteration in units of target model passes
- : average tokens produced per iteration
This formula captures the needed tradeoff in speculative decoding. The numerator measures benefit, specifically how many tokens we expect to generate per iteration. The denominator measures cost, specifically how much computation that iteration requires. Speedup greater than 1 means speculative decoding is faster than standard generation. The formula also shows that speedup depends on all three of , , and in ways that interact: high is more valuable when is large, and large is only worth it when is large enough.
When the draft model is very fast (), this simplifies to:
where:
- : theoretical maximum speedup with a zero-cost draft model
- : acceptance probability
- : draft length
This limiting case represents the best possible speedup when the draft model adds negligible overhead. In practice, draft models incur costs, so the actual speedup is lower than this bound. However, this formula provides a useful upper limit for what speculative decoding can achieve. When and , the theoretical maximum speedup is , meaning even with a free draft model, we cannot exceed 3.7 times the speed of standard generation in this configuration.
