Speculative decoding is an inference acceleration technique where a small, fast draft model (e.g., a distilled model) proposes a sequence of candidate future tokens. The primary, larger target model then verifies these proposals in a single, parallel forward pass, accepting correct tokens and rejecting incorrect ones with a single rollback step. This process reduces the number of costly, sequential autoregressive steps required from the large model, directly lowering generation latency.
Glossary
Speculative Decoding

What is Speculative Decoding?
Speculative decoding is a latency reduction technique that accelerates the autoregressive generation of large language models by using a smaller, faster draft model to propose token sequences for parallel verification.
The technique hinges on a high acceptance rate for the draft tokens. It is most effective when the draft model's predictions align closely with the target model's, making it a form of approximate computation. Key implementations include Google's Medusa and speculative sampling. It is fundamentally a memory-bound optimization, as its primary gain comes from reducing the number of high-latency model evaluations rather than arithmetic operations, complementing other KV cache management strategies.
Key Characteristics of Speculative Decoding
Speculative decoding accelerates autoregressive generation by using a small draft model to propose token sequences, which are then verified in parallel by a larger target model. This reduces the number of costly sequential steps.
Draft-Verify Paradigm
The core mechanism involves a two-stage process:
- Drafting Phase: A small, fast draft model (e.g., a distilled version of the target) runs autoregressively for
ksteps to propose a candidate sequence of tokens. - Verification Phase: The larger, more accurate target model processes this entire candidate sequence in a single, parallel forward pass. It scores the draft tokens against its own predictions, accepting them in a contiguous block up to the first mismatch. This allows the target model to generate multiple tokens per its own expensive forward pass, breaking the sequential bottleneck.
Wall-Time Speedup
The primary goal is to reduce end-to-end latency (wall-clock time). Speedup is achieved when the time saved by verifying k tokens in parallel outweighs the time cost of running the draft model.
- Key Metric: The acceptance rate—the average number of draft tokens accepted per verification step. A high acceptance rate is critical for gains.
- Theoretical Limit: Speedup is bounded by the draft model's latency and the verification cost. It is most effective when the target model is significantly slower than the draft model.
- Real-World Impact: Can achieve 2-3x latency reduction for large models like Llama-70B when paired with a well-chosen draft model, without altering the final output distribution.
Lossless Acceleration
A defining feature of standard speculative decoding is that it is mathematically lossless. The output distribution is identical to what the target model would produce running standard autoregressive decoding.
- Verification Guarantee: The target model's parallel verification acts as a rejection sampling mechanism. Only tokens that match the target model's own probability distribution are accepted.
- No Quality Degradation: Unlike quantization or pruning, there is no approximation error or change in the model's behavior. This makes it ideal for production systems where output fidelity is paramount.
- Deterministic Output: Given the same random seed, the speculative decoding run will produce the exact same sequence as the standard autoregressive run.
Model Requirements & Pairing
Successful deployment depends on a strategic draft-target pairing.
- Draft Model Traits: Must be small, fast, and aligned. Common choices include:
- A distilled version of the target model.
- A shallower or narrower architecture (e.g., fewer layers).
- A n-gram or statistical model in some implementations.
- Alignment is Critical: The draft model must have a high probability of predicting the same next token as the target model. Poor alignment leads to low acceptance rates and negates the speedup.
- Training: Draft models are often specifically trained on the target model's outputs to maximize prediction alignment.
Memory and Compute Trade-off
Speculative decoding trades increased memory bandwidth and compute intensity for reduced latency.
- Memory Bandwidth: The verification phase requires loading the full target model parameters and the KV cache for a batch size equal to the draft length
k+1. This can be high but is amortized over multiple accepted tokens. - Compute: The draft model adds extra FLOPs. The verification phase is a single forward pass but on a batch of
k+1sequences. - Optimal
k: The lookahead lengthkmust be tuned. A largerkincreases the potential reward (more tokens accepted) but also the cost of a failed draft (more wasted verification compute). The optimalkis hardware and model-dependent.
Related Techniques & Evolution
The core idea has inspired several variants and adjacent optimizations:
- Medusa & Self-Speculative Decoding: Uses multiple prediction heads attached to the same target model to draft future tokens, eliminating the need for a separate draft model.
- Speculative Sampling: The original algorithm for lossless acceleration.
- Lossy Variants: Techniques like EAGLE modify the verification step for greater speedup at a potential, controlled cost to output quality.
- Integration with Other Optimizations: Often combined with PagedAttention (for efficient KV cache management of draft sequences) and continuous batching to maximize GPU utilization during verification.
Speculative Decoding vs. Standard Autoregressive Decoding
A technical comparison of two primary methods for generating tokens from a large language model, focusing on latency, throughput, and computational trade-offs.
| Feature / Metric | Standard Autoregressive Decoding | Speculative Decoding |
|---|---|---|
Core Mechanism | Sequentially generates one token per model forward pass. | Uses a small draft model to propose multiple candidate tokens in parallel for verification by the target model. |
Latency per Token | Directly proportional to the target model's latency. | Reduced; latency amortized over multiple verified tokens per target model call. |
Throughput (Tokens/sec) | Limited by serial dependency of the decode phase. | Increased; higher token generation rate due to parallel verification of token drafts. |
Computational Load | One full target model forward pass per generated token. | Variable; cost includes draft model passes + target model verification passes. Net reduction when acceptance rate is high. |
Memory Access Pattern | Predictable, sequential reads/writes to the KV Cache. | Irregular; depends on draft accuracy. Requires efficient, parallelizable KV Cache access for verification. |
Optimal Use Case | General-purpose, deterministic generation. | Scenarios with high draft-target model correlation (e.g., domain-specific tasks, summarization). |
Key Limitation | Inherently sequential; latency scales linearly with output length. | Performance degrades if draft model accuracy is low, leading to high rejection rates and wasted computation. |
Implementation Complexity | Standard, well-understood inference pattern. | High; requires coordinating two models, managing draft sequences, and implementing a verification/rollback mechanism. |
Frameworks and Implementations
Speculative decoding is an inference acceleration technique where a small, fast draft model proposes a sequence of candidate tokens, which are then verified in parallel by the larger target model, reducing the number of costly autoregressive steps required.
Core Mechanism: Draft & Verify
The technique operates in a two-stage loop. First, a small draft model (e.g., a distilled version of the target) runs autoregressively for γ steps to propose a candidate sequence. Second, the large target model processes this entire candidate sequence in a single, parallel forward pass. It scores the draft tokens and, upon finding a mismatch, rejects all subsequent tokens and generates a correction. This replaces γ serial target model calls with one parallel verification, achieving speedups of 2-3x.
Key Implementation: Medusa & Self-Speculation
Medusa is a prominent framework that adds multiple prediction heads (a 'medusa head') on top of the target model's backbone, enabling it to act as its own draft model. This self-speculation eliminates the need for a separate model. Key components include:
- Multiple Decoding Heads: Predict several future tokens in parallel.
- Tree Attention: Efficiently verifies a tree of candidate token sequences.
- Typical Acceptance Rates: Often achieves 2-4 accepted tokens per verification step, significantly reducing latency.
Speculative Sampling Algorithm
This is the standard algorithm for token acceptance. After the target model verifies the draft:
- It generates adjusted probability distributions.
- For each position, the draft token is accepted with probability
min(1, p_target / p_draft). - If a token is rejected, a new token is resampled from the adjusted distribution.
This ensures the output distribution is mathematically identical to that of the original target model, preserving quality. The speedup is directly tied to the draft model's accuracy and the number of speculative steps (
γ).
System Optimizations: vLLM & TensorRT-LLM
Leading inference engines integrate speculative decoding to maximize hardware utilization.
- vLLM: Leverages its PagedAttention mechanism to efficiently manage the KV caches for both draft and target models within its continuous batching scheduler, minimizing memory fragmentation.
- TensorRT-LLM: Provides optimized kernels for the draft and verification passes, fusing operations and leveraging in-flight batching to maintain high GPU utilization during the variable-length acceptance phase.
Draft Model Selection Strategies
Choosing the draft model is critical for performance. Common strategies include:
- Distilled Model: A smaller version of the target, trained to mimic its output distributions.
- N-gram or Lookup Model: Extremely fast, shallow models based on statistical frequency.
- Structured Drafting: Using a lossless method like BiLD, which employs a different, faster model family (e.g., a non-autoregressive model) to generate candidates without distributional mismatch. The goal is to maximize the acceptance rate while minimizing the draft model's computational overhead.
Limitations and Trade-offs
Speculative decoding introduces specific engineering trade-offs:
- Memory Overhead: Must maintain two sets of model weights and KV caches in GPU memory.
- Draft Model Accuracy: Speedup collapses if the draft model is poor; the rejection rate must be low.
- Context Length: The technique is most effective for the decode phase. Very long context prefill phases remain a bottleneck.
- Hardware Saturation: On memory-bound systems, the parallel verification pass may not fully hide the draft latency, diminishing returns.
Frequently Asked Questions
Speculative decoding is a key technique for accelerating large language model inference. These FAQs address its core mechanisms, trade-offs, and practical implementation.
Speculative decoding is an inference acceleration technique where a small, fast draft model proposes a sequence of candidate tokens, which are then verified in parallel by a larger, more accurate target model, reducing the number of costly autoregressive steps. The process works in three stages: 1) The draft model runs autoregressively for k steps to generate a speculative sequence. 2) The target model processes this entire sequence in a single, parallel forward pass, producing logits for each position. 3) A verification algorithm compares the draft and target model outputs, accepting consecutive tokens where the distributions align and rejecting the first mismatch, after which the process repeats. This allows the target model to generate multiple tokens per step when speculation is correct.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Speculative decoding operates within a broader ecosystem of techniques designed to reduce inference latency and cost. These related concepts address complementary aspects of the inference pipeline, from memory management to computational efficiency.
Continuous Batching
An inference scheduling technique that dynamically groups incoming requests into a single, continuously executing batch. Unlike static batching, it allows:
- New requests to join an ongoing batch.
- Completed sequences to exit the batch independently.
- Maximized GPU utilization by eliminating idle time, directly complementing speculative decoding's goal of higher throughput.
KV Cache
The key-value cache is a memory buffer in transformer models that stores computed key and value tensors from previous tokens during autoregressive decoding. It is fundamental to efficient inference because:
- It prevents recomputation of attention for past tokens.
- Its memory footprint grows with context length, becoming a primary bottleneck.
- Speculative decoding reduces the number of serial decoding steps, thereby reducing the rate of KV cache writes for the large target model.
PagedAttention
A memory management algorithm, central to the vLLM inference engine, that organizes the KV cache into non-contiguous, fixed-size blocks. It enables:
- Efficient memory sharing for the KV cache across sequences in a batch.
- Near-zero internal fragmentation, allowing larger batch sizes.
- Essential for practical deployment of speculative decoding, as it efficiently manages the variable-length KV caches of both draft and target models.
Multi-Query & Grouped-Query Attention
Attention variants designed to reduce the memory and bandwidth cost of the KV cache.
- Multi-Query Attention (MQA): All query heads share a single key and value head.
- Grouped-Query Attention (GQA): A tunable hybrid where groups of query heads share a key/value head.
- Both directly reduce the size of the KV cache that must be stored and accessed each decoding step, a critical optimization that works in parallel with speculative decoding's algorithmic speedup.
Prefill vs. Decode Phase
The two distinct computational phases of transformer inference:
- Prefill Phase: The initial, parallel processing of the entire input prompt to compute the initial KV cache. This phase is compute-bound.
- Decode Phase: The token-by-token autoregressive generation, which is heavily memory-bound due to sequential reads of the growing KV cache.
- Speculative decoding specifically accelerates the decode phase by reducing its sequential depth.
Model Distillation
A training technique where a smaller student model is trained to mimic the behavior of a larger teacher model. It relates to speculative decoding in two key ways:
- The small draft model in speculative decoding is often a distilled version of the large target model.
- While distillation creates a permanently smaller, faster model, speculative decoding uses the small model transiently as a draft engine, retaining the full quality of the large model for verification.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us