Inferensys

Glossary

Speculative Decoding

An inference acceleration method that uses a smaller draft model to generate candidate tokens quickly, which are then verified in parallel by a larger target model.
Developer testing AI inference on mobile phone in hand, laptop with optimization code visible, casual tech review moment.
INFERENCE ACCELERATION

What is Speculative Decoding?

Speculative decoding is an inference optimization technique that accelerates autoregressive text generation from a large target model by using a smaller, faster draft model to propose multiple candidate tokens, which are then verified in parallel by the target model.

Speculative decoding is a lossless acceleration algorithm for large language model inference. It leverages a lightweight draft model to generate a sequence of k candidate tokens quickly. The larger target model then processes these candidates in a single parallel forward pass, evaluating their correctness against its own probability distribution. This shifts the bottleneck from sequential memory bandwidth to parallel compute, achieving a 2x–3x speedup in tokens-per-second without altering the target model's output distribution.

The core mechanism relies on rejection sampling to guarantee statistical equivalence to the target model's standard autoregressive output. If a draft token's probability diverges from the target's, it is rejected, and the target model resamples from an adjusted distribution. This ensures zero quality degradation. The technique is particularly effective for memory-bound workloads on modern accelerators, where the cost of running the draft model is negligible compared to the latency saved by parallel verification.

Inference Acceleration

Key Characteristics of Speculative Decoding

Speculative decoding is a lossless acceleration technique that leverages a lightweight draft model to propose multiple candidate tokens, which a larger target model then verifies in parallel. This approach maintains identical output distributions while dramatically reducing latency.

01

Draft-Target Model Architecture

Speculative decoding relies on a dual-model setup where a small, fast draft model (often 10-100x smaller than the target) generates k candidate tokens autoregressively. The large target model then processes these candidates in a single parallel forward pass, accepting or rejecting each token based on its own probability distribution. This shifts the workload from sequential to parallel computation, exploiting the fact that verifying multiple tokens is nearly as fast as generating one on modern accelerators.

02

Rejection Sampling for Lossless Quality

The verification step uses modified rejection sampling to guarantee that the output distribution exactly matches what the target model would have produced on its own. For each draft token, the target computes its probability and compares it to the draft's probability. If the draft token is too improbable under the target distribution, it is rejected and the target resamples from an adjusted distribution. This ensures zero degradation in output quality while still achieving speedups.

03

Wall-Clock Speedup Factors

Practical speedups range from 2x to 3x in typical deployments, with theoretical maximums determined by the acceptance rate of the draft model. Key factors influencing performance include:

  • Draft model alignment: Higher agreement between draft and target distributions yields higher acceptance rates
  • Draft latency ratio: The draft must generate tokens significantly faster than the target's per-token latency
  • Speculation length (k): More candidate tokens increase potential speedup but risk wasted computation on rejected sequences
2-3x
Typical Speedup
Lossless
Output Quality
04

Tree Attention for Multi-Candidate Verification

Advanced implementations use tree-structured speculation where the draft model proposes multiple branching sequences simultaneously. The target model verifies all branches in parallel using a specialized tree attention mask that prevents cross-branch contamination. This increases the expected acceptance length by exploring alternative token paths, particularly useful at decision points where the draft model has low confidence.

05

Self-Speculative Decoding Variants

Some architectures eliminate the need for a separate draft model by skipping layers of the target model itself. Early layers act as the draft, generating candidates using a subset of the full computation, while all layers participate in verification. This approach simplifies deployment by removing the need to maintain and align two distinct models, though it typically yields more modest speedups than a dedicated draft model.

06

Integration with Continuous Batching

Speculative decoding composes effectively with continuous batching in production serving systems. While one request undergoes draft generation, other requests can utilize the GPU for verification or their own draft phases. This overlapping of draft latency with useful computation from other sequences maximizes overall throughput. Serving frameworks like vLLM have begun incorporating speculative decoding into their scheduling algorithms.

SPECULATIVE DECODING

Frequently Asked Questions

Clear, technically precise answers to the most common questions about speculative decoding, the draft-target inference acceleration paradigm.

Speculative decoding is an inference acceleration technique that uses a smaller, faster draft model to generate multiple candidate tokens autoregressively, which are then verified in a single parallel forward pass by the larger, more accurate target model. The target model computes the probability distribution for each candidate token position simultaneously. If a candidate token matches the target model's distribution (typically via rejection sampling), it is accepted; if rejected, the target model's own token is used instead, and the process repeats. This converts the inherently sequential token-by-token generation into a parallelizable verification step, achieving 2-3x wall-clock speedups without altering the target model's output distribution.

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.