Skip to main content
SGLang provides several speculative decoding options, including EAGLE-2/EAGLE-3, MTP, UNO, DFLASH, classic draft-model decoding, and an NGRAM-based variant. Our implementation aims to maximize speed and efficiency and is considered to be among the fastest in open-source LLM engines.

Summary

Jump to sections

Quick guidance

  • Best speed/quality (recommended): Use EAGLE-3 with --speculative-algorithm EAGLE3.
  • Strong default / broad compatibility: Use EAGLE-2 with --speculative-algorithm EAGLE.
  • Workload acceptance changes over time: Use Adaptive speculative decoding on top of EAGLE with --speculative-eagle-topk 1.
  • Lower lm_head overhead for EAGLE-2: Enable FR-Spec with --speculative-token-map.
  • Model is MTP-enabled: Use MTP via speculative decoding (often with small speculative_num_steps/topk/num_draft_tokens, see the example section).
  • You have a UNO adapter for the target model: Use UNO with --speculative-algorithm UNO and --uno-lora-path ....
  • You have a DFlash draft checkpoint: Use DFLASH with --speculative-algorithm DFLASH and --speculative-draft-model-path ....
  • You have a smaller draft LLM: Use STANDALONE (--speculative-algorithm STANDALONE).
  • No extra model available: Use NGRAM (--speculative-algorithm NGRAM, CUDA-only).

Method comparison (mini table)

MethodDraft sourceSeparate draft model?How to enableNotes / constraints
EAGLE-2EAGLE draft model (feature drafting + tree)Typically yes—speculative-algorithm EAGLE + —speculative-draft-model-path …Tune —speculative-num-steps, —speculative-eagle-topk, —speculative-num-draft-tokens
EAGLE-2 + torch.compileSame as EAGLE-2Typically yesAdd —enable-torch-compile (optionally —torch-compile-max-bs)Benefit varies by hardware/model; benchmark to verify
EAGLE-2 + FR-SpecSame as EAGLE-2 + token subsetTypically yesAdd —speculative-token-map …Reduces lm_head overhead with high-frequency token vocab
EAGLE-3EAGLE3 draft modelYes—speculative-algorithm EAGLE3 + —speculative-draft-model-path …Best throughput in the benchmark below
MTPBuilt-in multi-token heads (model-specific)Often noSee Multi Token Prediction sectionUses speculative workflow; draft path may be auto-handled for some models
UNOTarget model with a trained UNO LoRA (linear chain or tree)No—speculative-algorithm UNO + —uno-lora-path …CUDA and FA3; currently requires TP=PP=1
DFLASHDFlash draft model (linear block verification)Yes—speculative-algorithm DFLASH + —speculative-draft-model-path …No —enable-dp-attention; pp_size == 1; disables overlap scheduler & mixed chunked prefill
STANDALONESmaller draft LLM (token-level)Yes—speculative-algorithm STANDALONE + —speculative-draft-model-path …Does not support —enable-dp-attention
NGRAMNgram cache from previous tokensNo—speculative-algorithm NGRAMCUDA-only; no —enable-dp-attention; disables overlap scheduler & mixed chunked prefill

Performance Highlights

Please see below for the huge improvements on throughput for LLaMA-Instruct 3.1 8B tested on MT bench that can be achieved via EAGLE3 decoding. For further details please see the EAGLE3 paper.
MethodThroughput (tokens/s)
SGLang (w/o speculative, 1x H100)158.34 tokens/s
SGLang + EAGLE-2 (1x H100)244.10 tokens/s
SGLang + EAGLE-3 (1x H100)373.25 tokens/s

EAGLE Decoding

To enable EAGLE speculative decoding the following parameters are relevant:
ParameterDescriptionDefault
—speculative-draft-model-pathDraft model path/weights. Typically required for EAGLE/EAGLE3 and STANDALONE. For some MTP-enabled models, this can be omitted.None
—speculative-num-stepsDepth of autoregressive drafting. Increases speculation range but risks rejection cascades.Auto (5 for Llama/Grok; 3 for many other models)
—speculative-eagle-topkBranching factor per step. Improves candidate diversity and acceptance rate, but increases memory/compute consumption.Auto (4 for Llama/Grok; 1 for many other models)
—speculative-num-draft-tokensMaximum parallel verification capacity. Allows deeper tree evaluation but increases GPU memory usage.Auto (8 for Llama/Grok; 4 for many other models). If topk=1, it is adjusted to num_steps + 1.
—speculative-accept-threshold-singleAcceptance threshold for single-token verification. Lower values accept more aggressively.1.0
—speculative-accept-threshold-accAccumulated acceptance threshold across steps.1.0
—speculative-attention-modeAttention mode for speculative operations (prefill or decode), affecting both target verification and draft extension.”prefill”
—speculative-draft-attention-backendOverride attention backend for the draft model.None (same as target)
—speculative-dsa-topk-backendSelect the DSA indexer top-k backend for speculative draft workers independently of —dsa-topk-backend. Options are sgl-kernel, torch, and flashinfer; torch requires SGLANG_DSA_FUSE_TOPK=false.sgl-kernel
—speculative-draft-model-quantizationQuantization method for the draft model. Use “unquant” to force no quantization even when the target model is quantized.Same as target model
—speculative-draft-model-revisionSpecific revision/commit of the draft model to load.None (auto-set to “main” when —speculative-draft-model-path is set and revision is omitted)
—speculative-draft-load-formatLoad format for the draft model weights.None
These parameters are mostly the same for EAGLE-2 and EAGLE-3. --speculative-token-map is ignored for EAGLE-3 models. For --speculative-num-steps, --speculative-eagle-topk, and --speculative-num-draft-tokens: leave all three unset to use auto-tuning, or set all three explicitly when tuning. If you use EAGLE with --speculative-eagle-topk 1 and your acceptance rate varies across requests, see Adaptive Speculative Decoding. You can find the best combinations of these parameters with bench_speculative.py.

EAGLE-2 Decoding

You can enable EAGLE-2 Decoding by setting --speculative-algorithm EAGLE and choosing an appropriate model. Launch the server:
Command
Send a request:
Example

EAGLE-2 Decoding with torch.compile

You can optionally enable torch.compile to apply kernel-level optimizations (operator fusion, autotune) to the draft model. The actual speedup depends on your hardware, model architecture, and batch size. In some configurations (e.g., small draft models on H100 where cuBLAS is already optimal and CUDA graphs are enabled), the benefit may be negligible. We recommend benchmarking with and without this flag on your specific setup to verify whether it helps. To enable it, add --enable-torch-compile and optionally set --torch-compile-max-bs:
Command
Send a request:
Example

EAGLE-2 Decoding via Frequency-Ranked Speculative Sampling

By employing a truncated high-frequency token vocabulary in the draft model, EAGLE speculative decoding reduces lm_head computational overhead while accelerating the pipeline without quality degradation. For more details, check out the paper. In our implementation, set --speculative-token-map to enable the optimization. You can get the high-frequency tokens in FR-Spec from this model. Or you can obtain high-frequency tokens by directly downloading these tokens from this repo. Thanks for the contribution from Weilin Zhao and Zhousx.
Command
Send a request:
Example

EAGLE-3 Decoding

You can enable EAGLE-3 decoding by setting --speculative-algorithm EAGLE3 and choosing an appropriate model.
Command
Send a request:
Example

Multi Token Prediction

We support MTP (Multi-Token Prediction) in SGLang by using speculative decoding. We use XiaomiMiMo/MiMo-7B-RL as an example here (for DeepSeek MTP usage, refer to DeepSeek-V3.2 cookbook §4.2.3).
Command
For DSA-based MTP, draft workers default to the sgl-kernel top-k backend. Use --speculative-dsa-topk-backend to override the draft independently of --dsa-topk-backend for the target model. Send a request:
Example

UNO decoding

UNO reuses the target transformer for both passes of each speculative decode cycle instead of loading a separate draft model. During the draft forward, the first row of each request uses the base weights and the remaining B - 1 rows use a trained UNO LoRA. Target verification is entirely base-only. UNO provides two sampling modes:
  • Linear constructs and verifies one chain of draft tokens, similar to DFlash’s proposal layout.
  • Tree expands multiple candidates at each draft depth and uses SGLang’s EAGLE tree-verification path.
For UNO modes, the three numbers are B/K/V: draft-forward width, candidates kept per expansion, and verification width. Thus, Linear 8/1/8 uses an 8-token draft width, one candidate per expansion, and an 8-token verification width. UNO’s K controls proposal-tree breadth and is unrelated to the request sampling parameter top_k. The command-line mapping depends on the mode:
  • In linear mode, B and V are both --speculative-num-draft-tokens; set --speculative-num-steps 1 and --speculative-eagle-topk 1.
  • In tree mode, B is --speculative-num-steps + 1, K is --speculative-eagle-topk, and V is --speculative-num-draft-tokens.
Use an adapter trained for the exact target-model checkpoint. The current integration has been validated with Qwen/Qwen3-8B; unsupported LoRA target layers are rejected at startup. Set the adapter’s local path or Hugging Face repository before starting the server:

Linear 8/1/8

Command

Tree 8/32/8

The following command selects tree mode because K is greater than one:
Command
Send requests through the standard OpenAI-compatible API:
Example

Key requirements and limitations

  • UNO requires CUDA with FA3 for prefill and decode, tensor and pipeline parallel sizes of 1, and no DP attention or context parallelism.
  • --uno-lora-path loads UNO’s fixed internal adapter and cannot be combined with request-selectable Multi-LoRA serving.
  • UNO manages its own stochastic verification; do not set --speculative-use-rejection-sampling.
  • Grammar decoding, returned logprobs or hidden states, sampling penalties, min_p, logit bias, custom logit processors, strict thinking, and deterministic inference are not yet supported.
  • In tree mode, both speculative acceptance thresholds must remain at 1.0, V must be at least B and at most 128, and V * K must not exceed 2048. SGLang validates the remaining tree-capacity and EAGLE parent-representation constraints at startup.
  • Mixed chunked prefill is disabled for UNO.
  • Ordinary overlap scheduling is supported. Tree mode does not yet support PDMux or the separate --enable-two-batch-overlap feature.

DFlash Decoding

SGLang also supports DFLASH speculative decoding using a dedicated draft model checkpoint. Compared with EAGLE-style tree verification, DFLASH verifies a linear draft block and is configured around a block size / draft window. This path is useful when the target model has a matching DFlash draft checkpoint, such as meta-llama/Llama-3.1-8B-Instruct with z-lab/LLaMA3.1-8B-Instruct-DFlash-UltraChat. Relevant parameters:
ParameterDescriptionDefault
—speculative-draft-model-pathRequired DFlash draft model path/weights.None
—speculative-num-draft-tokensDFlash verify block size.Inferred from draft config, otherwise 16
—speculative-dflash-block-sizeAlias of —speculative-num-draft-tokens for DFlash.None
—speculative-dflash-draft-window-sizeDraft KV sliding-window size. Must be >= speculative-num-draft-tokens when set.None
Command
Send a request:
Example

Standalone Speculative Decoding (Small Draft Model)

Besides EAGLE/MTP, SGLang also supports token-level speculative decoding using a smaller draft model. Enable it with --speculative-algorithm STANDALONE and provide a draft model via --speculative-draft-model-path. Relevant parameters:
ParameterDescriptionDefault
—speculative-draft-model-pathDraft model weights (smaller than the target model).None
—speculative-num-stepsDraft depth (how many steps the draft model runs autoregressively).3 (auto default for STANDALONE)
—speculative-eagle-topkBranching factor (token candidates per step).1 (auto default for STANDALONE)
—speculative-num-draft-tokensVerification capacity.4 (auto default for STANDALONE)
—speculative-draft-model-quantizationQuantization for the draft model. Use “unquant” to disable quantization on the draft even when the target is quantized.Same as target
Note: Standalone speculative decoding currently does not support --enable-dp-attention.
Command
Send a request:
Example

Speculative Decoding V2 (Overlap Scheduler)

Speculative decoding runs the V2 speculative workers (e.g. StandaloneWorkerV2, EAGLEWorkerV2) with the overlap scheduler enabled by default. Pass --disable-overlap-schedule to fall back to the synchronous (non-overlap) path. Notes:
  • The overlap scheduler currently only supports --speculative-eagle-topk 1; set --speculative-eagle-topk 1 explicitly.
  • If you explicitly set --speculative-eagle-topk > 1, the server will error.
  • If you omit --speculative-eagle-topk, auto-tuning may pick topk > 1 for some models (e.g. Llama). This is incompatible with the overlap scheduler and may not always trigger an immediate config error, so set --speculative-eagle-topk 1 explicitly.
Command
Send a request:
Example

Ngram Speculative Decoding

SGLang also supports ngram-based speculative decoding (no separate draft model). It retrieves draft tokens from an ngram cache built from previously generated tokens, and then verifies them with the target model. Enable it with:
  • --speculative-algorithm NGRAM

Ngram-specific parameters

ParameterDescriptionDefault
—speculative-num-draft-tokensNumber of draft tokens verified per step. If omitted, defaults to min(—speculative-ngram-max-trie-depth, 12).12 (with default ngram settings)
—speculative-ngram-min-bfs-breadthMinimum BFS breadth.1
—speculative-ngram-max-bfs-breadthMaximum BFS breadth.10
—speculative-ngram-match-typeNgram tree-building mode: “BFS” for recency-based expansion or “PROB” for frequency-based expansion.”BFS”
—speculative-ngram-max-trie-depthMaximum suffix length stored and matched by the ngram trie.18
—speculative-ngram-capacityCache capacity (number of entries).10,000,000
Notes:
  • Ngram speculative decoding only supports CUDA.
  • It currently does not support --enable-dp-attention.
  • It disables the overlap scheduler and mixed chunked prefill.
  • If --speculative-ngram-max-bfs-breadth > 1 (thus speculative_eagle_topk > 1) and page_size > 1, use --attention-backend flashinfer; otherwise the server will error.
  • Optional: set SGLANG_NGRAM_FORCE_GREEDY_VERIFY=True to force greedy verification.
Command
Send a request:
Example

Full Parameter Reference

Below is a comprehensive list of all speculative decoding parameters available in SGLang:

Core parameters

ParameterTypeDefaultDescription
—speculative-algorithmstrNoneAlgorithm to use: UNO, DFLASH, EAGLE, EAGLE3, STANDALONE, NGRAM, NEXTN (alias of EAGLE)
—speculative-draft-model-pathstrNonePath to the draft model weights
—uno-lora-pathstrNoneUNO-only path or Hugging Face repository for the draft LoRA checkpoint
—speculative-draft-model-revisionstrNoneSpecific revision/commit of the draft model (“main” is auto-used when draft path is set and revision is omitted)
—speculative-draft-load-formatstrNoneLoad format for draft model weights
—speculative-num-stepsintNone (auto-chosen when omitted)Autoregressive drafting depth. Some algorithms auto-tune it; tree UNO requires it and uses B = speculative_num_steps + 1.
—speculative-eagle-topkintNone (auto-chosen when omitted)Branching factor per drafting step. Some algorithms auto-tune it; UNO resolves an omitted value to 1, and values greater than one select UNO tree mode.
—speculative-num-draft-tokensintNone (auto-chosen when omitted)Maximum number of draft tokens for verification. Some algorithms auto-tune it; UNO requires it and uses it as linear width or tree verification width V.
—speculative-dflash-block-sizeintNoneDFlash-only alias of —speculative-num-draft-tokens
—speculative-dflash-draft-window-sizeintNoneDFlash-only draft KV sliding-window size
—speculative-accept-threshold-singlefloat1.0Single-token acceptance threshold
—speculative-accept-threshold-accfloat1.0Accumulated acceptance threshold
—speculative-token-mapstrNonePath to FR-Spec high-frequency token map
—speculative-attention-modestr”prefill”Attention mode for speculative operations (“prefill” or “decode”)
—speculative-draft-attention-backendstrNoneOverride attention backend for the draft model
—speculative-dsa-topk-backendstrsgl-kernelDSA indexer top-k backend for speculative draft workers, independent of —dsa-topk-backend (sgl-kernel, torch, or flashinfer)
—speculative-moe-runner-backendstrNoneMoE runner backend for the draft model
—speculative-moe-a2a-backendstrNoneMoE all-to-all backend for the draft model
—speculative-draft-model-quantizationstrSame as targetQuantization for the draft model (“unquant” to disable)

Ngram-specific parameters

ParameterTypeDefaultDescription
—speculative-ngram-min-bfs-breadthint1Minimum BFS breadth
—speculative-ngram-max-bfs-breadthint10Maximum BFS breadth
—speculative-ngram-match-typestr”BFS”Ngram tree-building mode: “BFS” for recency-based expansion or “PROB” for frequency-based expansion
—speculative-ngram-max-trie-depthint18Maximum suffix length stored and matched by the ngram trie
—speculative-ngram-capacityint10,000,000Cache capacity

Environment variables

VariableDefaultDescription
SGLANG_NGRAM_FORCE_GREEDY_VERIFYFalseForce greedy verification for ngram decoding
ParameterDescription
—enable-multi-layer-eagleEnable multi-layer EAGLE (auto-enabled for MiMoV2 and Step3p5 models)
—enable-torch-compileEnable torch.compile for kernel-level optimizations
—torch-compile-max-bsMaximum batch size for torch.compile

OOM Troubleshooting

[!WARNING] Out of Memory (OOM)? Speculative decoding may increase GPU memory usage because the draft tree, CUDA graphs, and verification-related buffers consume additional VRAM. If you encounter OOM errors, try the following adjustments.

Step 1: Lower static memory fraction (most effective)

Command
  • --mem-fraction-static controls the memory budget for model weights + KV cache pool.
  • Lowering it directly increases dynamic headroom for activations and CUDA graph buffers.
  • If omitted, SGLang auto-estimates this value from other settings, and those auto settings can still be too aggressive for some workloads.

Step 2: Reduce CUDA graph batch size

Command
  • If omitted, --cuda-graph-max-bs-decode is auto-selected based on GPU memory and TP size, and can be much larger on high-memory GPUs.

Step 3: Reduce draft tree size

These three parameters directly control how much memory the draft tree consumes:
Command

Step 4: Limit concurrent requests

Command

Quick OOM recovery recipe

If you’re hitting OOM and just want something that works, start with this minimal configuration and scale up:
Command
Then gradually increase --speculative-num-draft-tokens, --speculative-eagle-topk, and --cuda-graph-max-bs-decode. Increase --mem-fraction-static last, only after the run is stable.

References

EAGLE process is as follows:
  • Within EAGLE the draft model predicts the next feature vector, i.e. the last hidden state of the original LLM, using the feature sequence (f1,...,fk)(f_1, ..., f_k) and the token sequence (t_2, ..., t_{k+1}).
  • The next token is then sampled from p_{k+2}=\text{LMHead}(f_{k+1}). Afterwards, the two sequences are extended in a tree style—branching out multiple potential continuations, with the branching factor per step controlled by the speculative_eagle_topk parameter—to ensure a more coherent connection of context, and are given as input again.
  • In SGLang’s EAGLE-2 implementation, the draft tree is expanded for the configured steps and then reranked to select the top speculative_num_draft_tokens final nodes as draft tokens.
  • EAGLE-3 removes the feature prediction objective, incorporates low and mid-layer features, and is trained in an on-policy manner.
This enhances drafting accuracy by operating on features instead of tokens for more regular inputs and by additionally passing tokens from the next timestep to reduce sampling randomness. For more details, see the EAGLE-2 and EAGLE-3 papers. For guidance on how to train your own EAGLE model please see the EAGLE repo. For EAGLE-3 training specifically, check out SpecForge, the SGLang team’s training framework designed for EAGLE-3 speculative decoding models with seamless porting to SGLang serving. See the SpecForge documentation and blog post for details.