← Reference · Nestor G Pestelos Jr · Print this page

Machine Learning · Systems Engineering

Speculative Decoding

Reference entry · last updated September 8, 2026

Speculative decoding (also termed assisted generation or speculative sampling) is an exact acceleration technique for autoregressive language model inference that uses an auxiliary draft mechanism to hypothesize candidate tokens for parallel validation by a larger target model in a single execution step. Because validating multiple tokens concurrently is compute-bound rather than memory-bound, speculative decoding reduces generation latency while provably preserving the target model's output probability distribution.

1. First Principles: Parallel Verification vs. Sequential Generation

Autoregressive text generation requires \(K\) sequential steps to emit \(K\) tokens. Because decoding each token is memory-bandwidth bound, generating \(K\) tokens requires reading the target model's entire parameter weight matrix \(P\) from memory \(K\) times [1, 2]. This serial dependency enforces an architectural latency barrier governed by memory bus throughput.

However, verifying \(K\) candidate tokens simultaneously requires only a single forward pass of the target model. Evaluating a sequence of length \(K\) performs matrix-matrix operations (GEMM) across the sequence dimension rather than matrix-vector operations (GEMV), unlocking high tensor core arithmetic intensity. Verifying \(K\) candidate tokens takes approximately the same wall-clock time on a modern GPU as generating a single token sequentially.

Speculative decoding exploits this asymmetry: a lightweight, fast draft mechanism generates \(K\) candidate tokens at low computational cost, and the large target model inspects all \(K\) candidates in parallel in one forward pass [1].

2. Algorithmic Formulation and Distribution Preservation

2.1 Modified Rejection Sampling

A key property of speculative decoding is mathematical exactness: the generated text distribution matches sampling from the target model \(M_{\text{target}}\) exactly, introducing zero degradation in output quality or reasoning capability [1, 2].

Let \(q(x)\) denote the token probability distribution from the draft model, and \(p(x)\) denote the true distribution from the target model. For each draft token \(x_i\) conditioned on preceding accepted tokens, the verification step accepts \(x_i\) with probability:

\[P(\text{accept } x_i) = \min\left(1, \frac{p(x_i)}{q(x_i)}\right)\]

If draft token \(x_i\) is accepted, the process evaluates candidate \(x_{i+1}\). If token \(x_i\) is rejected, speculative execution halts for that iteration. The algorithm draws a replacement token from adjusted distribution \(p'(x)\):

\[p'(x) = \frac{\max(0, p(x) - q(x))}{\sum_y \max(0, p(y) - q(y))}\]

This rejection sampling formulation guarantees that whether a token is accepted from the draft or sampled from the residual distribution, the marginal probability of emitting token \(x\) equals \(p(x)\) identically.

2.2 Expected Speedup and Acceptance Rate

If the draft model produces \(\gamma\) candidate tokens per iteration and achieves an average per-token acceptance rate \(\alpha \in [0, 1]\), the expected count of generated tokens \(\mathbb{E}[N]\) per verification pass is:

\[\mathbb{E}[N] = \frac{1 - \alpha^{\gamma + 1}}{1 - \alpha}\]

Let \(c\) represent the latency ratio between one draft step and one target model forward pass (\(c = T_{\text{draft}} / T_{\text{target}} \ll 1\)). The wall-clock speedup \(S\) is expressed as:

\[S = \frac{\mathbb{E}[N]}{\gamma \times c + 1} = \frac{1 - \alpha^{\gamma + 1}}{(1 - \alpha)(\gamma \times c + 1)}\]

When \(\alpha \approx 0.7\) to \(0.9\) and \(c \le 0.05\), speculative decoding yields a 2x to 3x reduction in Time Per Output Token (TPOT).

3. Drafting Architectures

3.1 Auxiliary Draft Models

The standard architecture pairs a small model from the same family with the large target model (for example, a 7B parameter draft model proposing tokens for a 70B parameter target model) [1]. Both models share the same vocabulary and tokenization scheme, allowing straightforward probability mapping.

3.2 Multi-Head and Non-Neural Drafting

Modern serving frameworks also support draft mechanisms that eliminate secondary models:

4. Operating Regimes and Systems Trade-offs

Speculative decoding operates most effectively under specific system constraints:

See also

References

  1. Y. Leviathan, M. Kalman, and Y. Matias, "Fast Inference from Transformers via Speculative Decoding," in Proceedings of the 40th International Conference on Machine Learning (ICML), 2023, pp. 19274–19286. Free full text: https://arxiv.org/abs/2211.17192
  2. C. Chen et al., "Accelerating Large Language Model Decoding with Speculative Sampling," arXiv preprint arXiv:2302.01318, 2023. Free full text: https://arxiv.org/abs/2302.01318
  3. T. Cai et al., "Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads," in Proceedings of the 41st International Conference on Machine Learning (ICML), 2024. Free full text: https://arxiv.org/abs/2401.10774
  4. Y. Li et al., "EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty," in Proceedings of the 41st International Conference on Machine Learning (ICML), 2024. Free full text: https://arxiv.org/abs/2401.15077
  5. R. Pope et al., "Efficiently Scaling Transformer Inference," in Proceedings of Machine Learning and Systems (MLSys), vol. 5, 2023, pp. 606–624. Free full text: https://proceedings.mlsys.org/paper_files/paper/2023/file/523f66f8510f27eb6f29633e73507d4c-Paper-Conference.pdf