Inferensys

Glossary

Speculative Decoding

A latency-reduction technique where a small, fast draft model predicts multiple future tokens that are then verified in parallel by a larger target model, accelerating text generation.
ML engineer running AI model benchmarks, performance charts on multiple screens, late night home office setup.
INFERENCE ACCELERATION

What is Speculative Decoding?

A latency-reduction technique for autoregressive text generation that uses a small, fast draft model to predict multiple future tokens, which are then verified in parallel by a larger target model.

Speculative Decoding is a parallel inference strategy where a lightweight draft model proposes k future tokens, and a large target model verifies them in a single forward pass. By accepting matching tokens and rejecting mismatches, it preserves the exact output distribution of the target model while dramatically reducing the number of sequential decoding steps.

This technique exploits the observation that most next-token predictions are computationally cheap for a small model but expensive for a large one. The target model processes the draft tokens in parallel using a modified attention mask, accepting a prefix of correct predictions. Rejected tokens trigger a single correction step, ensuring zero quality degradation.

LATENCY REDUCTION

Key Characteristics of Speculative Decoding

Speculative decoding is a pivotal inference optimization technique that accelerates autoregressive text generation by leveraging a lightweight draft model to propose multiple future tokens, which are then verified in parallel by the primary target model.

01

Draft-Target Model Architecture

The core mechanism relies on a dual-model setup: a small, fast draft model (often 10-50x smaller) generates a sequence of K candidate tokens sequentially. The larger target model then processes these K tokens in a single parallel forward pass to verify their correctness against its own probability distribution. This replaces the standard sequential token-by-token generation of the large model, converting a memory-bandwidth-bound process into a compute-bound one.

02

Rejection Sampling Mechanism

Verification uses rejection sampling to guarantee the output distribution is identical to the target model's. The target model computes probabilities for each draft token. A token is accepted if its draft probability exceeds the target probability, or via a random acceptance criterion when the target probability is higher. Upon the first rejection, the target model generates a corrected token, and all subsequent draft tokens are discarded. This ensures zero statistical degradation in output quality.

03

Memory-Bandwidth Wall Mitigation

Standard autoregressive decoding is memory-bandwidth-bound: each token generation requires loading the full model weights from GPU HBM to SRAM, but performs minimal computation. Speculative decoding amortizes this cost by performing a single weight load for K tokens. This directly addresses the primary bottleneck in LLM inference, achieving speedups of 2x-3x in typical deployments without any model compression or quantization.

04

Draft Model Selection Criteria

Optimal draft models balance three factors:

  • High acceptance rates: The draft must closely approximate the target's distribution. Models from the same family (e.g., a 0.5B parameter draft for a 7B target) work best.
  • Low inference latency: The draft must generate K tokens faster than the target would generate 1 token.
  • Speculative lookahead (K): Typical K values range from 3-8 tokens. Larger K increases potential speedup but reduces acceptance probability for later tokens.
05

Tree Attention for Multi-Candidate Speculation

Advanced implementations extend beyond linear speculation using tree attention. Instead of a single sequence of K tokens, the draft model proposes a tree of multiple candidate continuations at each step. The target model verifies all branches simultaneously using a specialized attention mask that prevents cross-branch contamination. This increases the expected number of accepted tokens per forward pass, pushing speedups beyond 3.5x.

06

KV Cache Management During Verification

Efficient KV cache handling is critical. During verification, the target model computes keys and values for all K draft tokens in parallel. Accepted tokens' KV entries are appended to the persistent cache. Rejected tokens' entries are discarded. PagedAttention implementations like vLLM integrate speculative decoding natively, managing memory at the block level to avoid fragmentation from the frequent cache extensions and truncations inherent in the rejection sampling process.

SPECULATIVE DECODING

Frequently Asked Questions

Clear answers to common questions about how speculative decoding accelerates large language model inference by using a draft model to predict tokens that are verified in parallel.

Speculative decoding is a latency-reduction technique for autoregressive text generation where a small, fast draft model predicts multiple future tokens that are then verified in parallel by a larger, more accurate target model. The process works in three phases: first, the draft model efficiently generates a sequence of K candidate tokens. Next, the target model processes this entire candidate sequence in a single forward pass, computing the probability distribution for each position. Finally, a rejection sampling mechanism compares the draft tokens against the target model's distributions, accepting matching tokens and discarding divergences. Because the target model's single forward pass verifies multiple tokens simultaneously rather than generating them one-by-one, the wall-clock time per generated token drops significantly while maintaining the exact output distribution of the target model.

LATENCY OPTIMIZATION COMPARISON

Speculative Decoding vs. Other Latency Reduction Techniques

A feature-level comparison of speculative decoding against other common inference acceleration methods for autoregressive text generation.

FeatureSpeculative DecodingQuantizationKnowledge Distillation

Primary Mechanism

Draft-then-verify parallelism using a small draft model

Reduced numerical precision of weights and activations

Training a compact student model to mimic a large teacher

Output Distribution Preservation

Requires Model Retraining

Hardware-Agnostic Speedup

Memory Footprint Reduction

Typical Throughput Gain

2x-3x

2x-4x

5x-10x

Risk of Quality Degradation

None (lossless)

Low to moderate

Moderate to high

Compatible with Continuous Batching

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.