Skip to main content
SGLang provides industry-leading speculative decoding implementations, including EAGLE-2/EAGLE-3, Multi-Token Prediction (MTP), standalone draft models, and n-gram speculation.
Our speculative decoding is considered among the fastest in open-source LLM engines.

Performance Highlights

Tested on LLaMA-3.1-8B-Instruct with MT-Bench (1× H100): For details, see the EAGLE-3 paper.

Quick Guidance

Best Speed (Recommended)

EAGLE-3 - Use --speculative-algorithm EAGLE3

Broad Compatibility

EAGLE-2 - Use --speculative-algorithm EAGLE

MTP-Enabled Models

Multi-Token Prediction - Use MTP via speculative decoding

No Draft Model

N-gram - Use --speculative-algorithm NGRAM (CUDA-only)

Method Comparison

EAGLE-2 Decoding

EAGLE-2 uses a specialized draft model that predicts feature vectors (hidden states) instead of tokens directly, enabling more accurate speculation.

Basic Setup

Making Requests

Key Parameters

Use bench_speculative.py to find optimal parameter combinations for your workload.

EAGLE-3 Decoding

EAGLE-3 improves upon EAGLE-2 by:
  • Removing the feature prediction objective
  • Incorporating low and mid-layer features
  • Training in an on-policy manner
For training your own EAGLE-3 models, see SpecForge, the SGLang team’s training framework.

Advanced EAGLE Features

torch.compile Optimization

Enable kernel-level optimizations for the draft model:
The benefit depends on hardware, model architecture, and batch size. On H100 with small draft models and CUDA graphs enabled, the improvement may be negligible. Always benchmark on your specific setup.

FR-Spec (Frequency-Ranked Speculation)

Reduce lm_head overhead by using a truncated high-frequency token vocabulary:
For more details, see the FR-Spec paper.

Multi-Token Prediction (MTP)

Some models have built-in multi-token prediction heads. Use speculative decoding to leverage them:
For DeepSeek MTP usage, see the DeepSeek V3.2 documentation.

Standalone Draft Model

Use a smaller model as a draft for token-level speculation:
Standalone speculative decoding does not support --enable-dp-attention.

N-gram Speculation

Use n-gram matching from previous generations (no separate draft model required):

N-gram Parameters

  • N-gram only supports CUDA
  • Does not support --enable-dp-attention
  • Disables overlap scheduler and mixed chunked prefill

Speculative Decoding V2 (Experimental)

Enable overlap scheduler for improved pipelining:
SpecV2 only supports --speculative-eagle-topk 1. Always set this explicitly when using SpecV2.

OOM Troubleshooting

Speculative decoding increases memory usage. If you encounter OOM errors:

Step 1: Lower Static Memory Fraction

This is the most effective adjustment.

Step 2: Reduce CUDA Graph Batch Size

Step 3: Reduce Draft Tree Size

Step 4: Limit Concurrent Requests

Quick Recovery Recipe

If OOM, start with this minimal config:
Then gradually increase parameters.

Implementation Details

EAGLE Process

  1. Feature Prediction: Draft model predicts next feature vector (last hidden state) using feature sequence and token sequence
  2. Tree Expansion: Branches out multiple continuations with speculative-eagle-topk branching factor
  3. Token Sampling: Samples tokens from lm_head(features)
  4. Verification: Target model verifies all draft tokens in parallel
  5. Acceptance: Accepts longest valid prefix
Source: python/sglang/srt/speculative/spec_info.py:15

SpeculativeAlgorithm Enum

Source: python/sglang/srt/speculative/spec_info.py:15

Training EAGLE Models

For training your own EAGLE draft models:

Full Parameter Reference

References