Skip to main content
Speculative decoding is a technique for accelerating LLM inference at low batch sizes. A lightweight drafting mechanism proposes candidate tokens, and the target model verifies them in a single forward pass. Tokens that match are accepted, reducing the number of sequential forward passes needed.

How It Works

Speculative decoding operates on a simple principle:
  1. A draft model (smaller/faster) generates candidate tokens
  2. The target model (larger/accurate) verifies all candidates in parallel
  3. Matching tokens are accepted, non-matching tokens trigger rejection and resampling
  4. The process repeats until the sequence is complete
Speculation is most effective at low batch sizes where GPU utilization is not saturated. Speed improvements are typically observed when batch size is small.

Supported Methods

TensorRT-LLM supports multiple speculative decoding algorithms:

Draft/Target

Use any smaller model as a draft for the target model

EAGLE 3

Specialized draft models trained for speculative decoding

N-gram

Prompt lookup decoding using token prefix matching

MTP

Multi-token prediction for DeepSeek models

Quick Start Examples

Draft/Target Decoding

The simplest form of speculative decoding uses an arbitrary draft model:
Make sure the draft and target models use the same tokenizer. Mismatched tokenizers result in extremely low acceptance rates and degraded performance.

EAGLE 3 Decoding

EAGLE 3 uses specialized draft models trained specifically for speculative decoding:

Available EAGLE 3 Models

Use checkpoints from the original EAGLE 3 authors:
  • yuhuili/EAGLE3-LLaMA3.1-Instruct-8B
  • yuhuili/EAGLE3-LLaMA3.1-Instruct-70B
TensorRT-LLM supports a modified version of EAGLE 3. Tree structures for draft sequences are not supported; instead, each request uses a single sequence of draft tokens with length max_draft_len.

N-gram Decoding (Prompt Lookup)

N-gram decoding maintains a map from token prefixes to candidate draft sequences:

N-gram Configuration Options

N-gram decoding works particularly well for repetitive text patterns and when prompts share common prefixes.

MTP (Multi-Token Prediction)

MTP is currently only supported for DeepSeek models:

MTP Configuration Options

Relaxed acceptance mode allows draft tokens to be accepted if they appear in a candidate set, providing more flexibility during the reasoning phase.

User-Provided Drafting

For advanced use cases, you can implement custom drafting logic:

Using with trtllm-bench and trtllm-serve

Speculative decoding options must be specified via --config config.yaml for both trtllm-bench and trtllm-serve.

YAML Configuration

Create a config.yaml file:

Running Benchmarks

Serving with Speculation

The field name speculative_model_dir can also be used as an alias for speculative_config.speculative_model.

Performance Considerations

Speculative decoding is most effective when:
  • Batch size is small (1-4 requests)
  • GPU utilization is low
  • Latency reduction is more important than throughput
  • Draft model is significantly faster than target model
  • Higher values (4-6): Better speedup potential, but lower acceptance rate
  • Lower values (2-3): Higher acceptance rate, but less speedup per iteration
  • Optimal value depends on model similarity and task
  • Start with 3 and tune based on acceptance rate metrics
  • Use models from the same family (better tokenizer match)
  • Smaller draft models (1-3B) work well with larger targets (7B+)
  • EAGLE-trained models typically achieve higher acceptance rates
  • Test acceptance rate on representative prompts

Backend Support

The PyTorch backend currently only supports EAGLE 3. The decoding_type: Eagle is accepted as a backward-compatible alias for Eagle3, but EAGLE v1/v2 draft checkpoints are incompatible.

Additional Resources

EAGLE 3 Paper

Technical paper: EAGLE-3: Scaling up Inference Acceleration

Speculative Decoding Modules

Browse NVIDIA’s draft model collection

Prompt Lookup Decoding

Original N-gram implementation reference