SGLang Speculative Decoding: A Runtime Lever for Faster LLM Inference

How SGLang and vLLM speculative decoding work, when acceptance and batch size make them help or hurt, and how to tune and measure them.

SGLang Speculative Decoding: A Runtime Lever for Faster LLM Inference
Written by TechnoLynx Published on 11 Jul 2026

SGLang supports speculative decoding through several drafting methods: EAGLE-2 and EAGLE-3, MTP, UNO, DFLASH, a classic draft-model mode and an n-gram variant. All of them follow the same overall draft-and-verify process. A cheap draft proposes a few tokens, and the target model checks them all in one forward pass and keeps the longest prefix it agrees with. vLLM speculative decoding also verifies multiple drafted tokens in a single target-model pass. In online serving with continuous batching the gain depends on the workload: it can turn into extra latency under high request rates or when the target rejects most of the draft.

TechnoLynx can profile the LLM serving path before speculative decoding is enabled, as part of its GPU performance engineering work. The first step is profiling your own traffic, to confirm that decode is the bottleneck and to measure draft acceptance and batch behaviour.

Draft, Verify, Accept: Why SGLang’s Speculative Outputs Stay Unchanged

The loop has two steps. First, a draft builds several candidate tokens. Then the target model computes probabilities for all of them in one inference step and decides which to accept, in order. Verification is cheap because the KV cache already holds the prefix, so only the new speculated tokens cost compute in that pass.

The accept rule is why the outputs match. Going left to right, a draft token is accepted if the target gives it at least the draft’s probability. Otherwise it is accepted with probability p_target/p_draft. The first rejection ends the round, and the target samples a corrected token from the leftover distribution. This rule means that, in expectation, the sequence is distributed exactly as if the large model had sampled every token itself. That is the guarantee the original Leviathan et al. paper set out: faster sampling with no change to the outputs.

Each decode step loads all the weights and KV cache to produce one token, so decode is limited by memory bandwidth, not by compute. Speculation uses spare compute to verify extra tokens in parallel. For the same reason it does not help where no spare compute exists.

The guarantee has one caveat. The vLLM documentation says it holds for the standard rejection sampler, and that vLLM’s FLy mode relaxes verification on purpose and does not preserve the distribution. Check which verifier you enabled before you tell anyone the outputs are unchanged.

Does SGLang Support Speculative Decoding, and How Does It Work Inside the SGLang Serving Engine?

SGLang runs speculative decoding through its V2 speculative workers (StandaloneWorkerV2, EAGLEWorkerV2) with the overlap scheduler on by default. --disable-overlap-schedule switches back to the synchronous path. The methods differ in how the draft component is designed and how it works with the target model.

Method Where the draft comes from What it needs Where it tends to fit
EAGLE-2 / EAGLE-3 A lightweight head attached to the target’s internal layers, which drafts a tree of candidates A head trained for that target model; training-based drafters need upfront training resources and data EAGLE-3 lost only 6% of its speedup as temperature rose from 0 to 0.6 on Qwen3-8B reasoning workloads in one 2025 benchmark
MTP Multi-token prediction heads built into the model, as in DeepSeek models A model that ships with MTP heads Models trained with MTP, where no separate drafter is needed
STANDALONE A smaller separate draft model, set with --speculative-algorithm STANDALONE A draft model that shares the target’s vocabulary Cases where a well-aligned small sibling model exists
NGRAM A cache of n-grams from earlier tokens, with no draft model CUDA only. No DP attention, and it disables the overlap scheduler and mixed chunked prefill Repetitive output
DFLASH A dedicated draft checkpoint that proposes a linear block, not a tree A DFlash checkpoint, configured around a block size Workloads where block drafting from that checkpoint is accepted well
UNO The target transformer itself, using a trained LoRA for the draft pass A trained UNO LoRA Setups that want to avoid loading a second model

There is one interaction you need to know about. The overlap scheduler currently supports only --speculative-eagle-topk 1. If you leave topk unset, auto-tuning may pick a value above 1 for some models such as Llama, and that does not always raise a config error straight away. So set it explicitly.

For an EAGLE-style head on your own fine-tuned model, training the drafter is a project of its own. Our explainer on SpecForge and training drafters for speculative decoding covers that side.

What Is the Acceptance Rate, and Why Can Low Acceptance Make Generation Slower?

The acceptance rate is the average number of accepted draft tokens per inference step. It is a key metric for judging a speculative decoding setup. The vLLM measurements report it as mean accepted length (MAL) and acceptance rate (AR). If every draft token is rejected, the step still yields the single token the target would have produced anyway.

The catch is that the end-to-end speedup is usually lower than the acceptance numbers suggest, because producing the draft costs time. Leviathan et al. show formally that if the acceptance rate α is higher than the drafter’s relative cost c, some draft length gives an improvement. With low acceptance, the target regenerates most tokens itself, the draft work is wasted, and the system can end up slower than plain decoding.

The vLLM team published measurements on AMD Instinct MI300X and MI355X GPUs. In one DFlash sweep, N=7 speculative tokens gave 2.87x throughput at a mean accepted length of 5.26 and 60.9% acceptance. N=15 accepted more tokens per step (MAL 6.40) but dropped to 2.40x, with acceptance at 36.0%. Another configuration in the same post ran at 0.71x of baseline with a single speculative token, even at 86.3% acceptance. So acceptance alone does not decide speed: the saved target work has to outweigh the cost of drafting and verification.

The same pattern shows up with separate draft models. In a benchmark of speculative decoding for LLM test-time scaling, classic speculative sampling had the highest mean accepted tokens. But a 0.6B drafter was still too heavy next to 8B and 14B targets, so most of the time it saved was lost to running the drafter. The reverse also holds. In the SmartSpec paper (2024), prompt lookup on Mistral-7B gave substantial speedups at only 0.3 to 0.4 acceptance, because proposing tokens cost almost nothing.

Sampling temperature also moves acceptance. In the same benchmark, the n-gram method SAM lost about 22% of its speedup when temperature rose from 0 to 0.6 (2.28x to 1.78x). EAGLE-3 lost only 6% under the same temperature rise (2.91x to 2.73x). So the n-gram method’s greedy-run speed shrank far more at higher temperature than EAGLE-3’s.

Batch Size, Request Rate and Context Length Decide Whether Speculation Pays

Speculative decoding brings significant gains in low-QPS environments. It loses ground at high request rates. The vLLM documentation describes it as a way to cut inter-token latency for medium-to-low QPS, memory-bound workloads. vLLM’s own 2024 results agree: up to 1.5x with a draft model on ShareGPT and up to 2.8x with prompt lookup on CNN/DailyMail summarisation, both in low-QPS settings. The same post warns that at high QPS the extra compute can slow the system down.

The mechanism is verification cost. One serving team’s n-gram tests found that iteration latency grows as the verification batch outgrows the original batch, and grows further with longer drafts. In their tests n-gram speculation sped things up for batch sizes up to 32 and worked best at batch size 1. The SmartSpec paper (2024) fixed acceptance at 0.7 and found that proposing 5 tokens stopped helping above a request rate of 12, and proposing 3 tokens degraded performance above 16. The authors also note that the larger the model, the narrower the range of request rates where speculation pays.

Long context changes this picture. The MagicDec authors argue that large batches only defeat speculation on short sequences. Past a critical length, loading the KV cache dominates even at large batch sizes, so verification becomes cheap by comparison. MagicDec reports up to 2.51x for LLaMA-3.1-8B at batch sizes of 32 to 256 on moderate-to-long sequences. That critical length depends on the model, the hardware and the drafting strategy.

Batching cannot rescue a bad draft-target pair. If the pair shows no speedup at batch size 1, because acceptance is low or the drafter is expensive, batching cannot create a gain that does not exist per sequence. Our reading for planning is this. Short-context interactive chat at modest concurrency is the strong case. High-QPS throughput serving on short prompts is where we would expect a regression until measurements show otherwise.

How Do You Enable and Tune Speculative Decoding in SGLang?

You enable speculative decoding in SGLang with --speculative-algorithm and the method name, for example STANDALONE with a draft model or NGRAM for the cache-based variant. Three parameters shape the draft for EAGLE-style methods:

  • --speculative-num-steps sets how deep the autoregressive drafting goes. More steps extend the speculation range but risk rejection cascades. The auto default is 5 for Llama and Grok and 3 for many other models.
  • --speculative-eagle-topk sets the branching factor per step. Higher values give more diverse candidates and better acceptance, at the cost of memory and compute. The auto default is 4 for Llama and Grok and 1 for many others.
  • --speculative-num-draft-tokens caps how many tokens are verified in parallel. Higher values allow a deeper tree but use more GPU memory. The auto default is 8 for Llama and Grok and 4 for many others.

In SGLang’s EAGLE-2 path, the draft tree grows for the configured number of steps and is then reranked to keep the top speculative_num_draft_tokens nodes. The SGLang documentation reports 158.34 tokens/s without speculation, 244.10 with EAGLE-2 and 373.25 with EAGLE-3, for Llama-3.1-8B-Instruct on MT-Bench on one H100.

The draft tree, CUDA graphs and verification buffers all take extra VRAM. The documentation’s conservative fallback when you hit out-of-memory errors shrinks all three draft parameters:

--speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4

Lowering --mem-fraction-static also frees headroom for activations and CUDA graph buffers, because that setting controls the budget for weights plus the KV cache pool. SGLang’s auto-estimate of it can be too aggressive for some workloads. Optional torch.compile on the draft model may help or may do nothing measurable. The documentation advises benchmarking with and without it.

For MTP, SGLang’s MTP guidance suggests starting with draft_token_num at 2. Go to 4 or more only with GPU headroom, stay at 2 or 3 when GPUs already run large batches, and try longer drafts when average acceptance length stays above 2.

Adaptive Mode for Traffic Whose Acceptance Changes

One static step count is rarely optimal for traffic whose accept length changes over time. SGLang’s adaptive speculative decoding adjusts speculative_num_steps and speculative_num_draft_tokens at runtime. After each verify pass it reads the accepted length per request, smooths the batch average with an exponential moving average, and switches between candidate step tiers. It keeps separate trackers for separate batch-size ranges. In the built-in conservative default, batch sizes 8 to 31 may use 1 or 3 steps and batch size 32 and above locks to one step. The documentation also says that adaptive mode may not help if one static setting is already well tuned for stable traffic, and that a per-model config built from benchmarks can beat the presets.

A Tuning Procedure That Runs in Order

  1. Build a representative prompt set (chat, code, tool use, whatever production actually serves), because acceptance depends on the structure of real outputs.
  2. Record a non-speculative baseline for comparison.
  3. Enable one method with conservative draft settings and --speculative-eagle-topk 1 if the overlap scheduler stays on.
  4. Sweep the proposal length. Per-position acceptance shows when later positions add work but few accepted tokens.
  5. Repeat the sweep at several batch sizes, since the best step count is often lower at high batch sizes.
  6. Pick static per-range settings or adaptive mode, then check memory headroom at peak load.

How Does Speculative Decoding Interact with Continuous Batching and KV-Cache Management in SGLang?

Speculative decoding changes continuous batching because each step can yield several tokens per request instead of one. The proposals for every request in the batch are verified together in one target pass. Requests then accept different numbers of tokens, so the batch becomes ragged and position IDs, attention masks and KV-cache state can fall out of step. The authors of Batch Speculative Decoding Done Right (2025) note that vLLM and SGLang avoid that particular problem through continuous batching with paged attention. In the same tests, vLLM’s speculation underperformed its baseline at high concurrency and SGLang with EAGLE ran slower than non-speculative generation, which they attribute to the general difficulty of combining speculation with continuous batching.

KV memory is where they meet: --mem-fraction-static sets the budget for weights plus the KV cache pool, and lowering it leaves more headroom for CUDA graph buffers. Over-provisioning one starves the other. A separate draft model also needs its own KV cache kept in step with the target, which means running the draft’s prefill even for requests that end up proposing nothing. Adaptive mode captures CUDA graphs per step tier, so switching tiers is a reference swap rather than a recapture, and fewer candidate steps lower startup GPU memory. The NGRAM method disables the overlap scheduler and mixed chunked prefill.

How Does SGLang’s Speculative Decoding Implementation Compare with vLLM’s?

Both engines run the same draft-and-verify loop. They differ in method coverage and configuration. SGLang’s documentation calls its implementation among the fastest in open-source engines, which is the vendor’s own claim.

Aspect SGLang vLLM
Methods EAGLE-2/3, MTP, UNO, DFLASH, standalone draft model, NGRAM EAGLE, MTP, draft models, PARD, n-gram and suffix decoding; --speculative-config takes mtp, eagle3, dflash and dspark
Proposal length --speculative-num-steps, --speculative-eagle-topk, --speculative-num-draft-tokens num_speculative_tokens, required where it cannot be read from model metadata
KV handling Draft tree, CUDA graphs and verify buffers take extra VRAM; lowering --mem-fraction-static (weights plus KV pool) frees headroom for CUDA graph buffers The scheduler adds the draft tokens to the new-token count so allocate_slots reserves enough KV blocks
Load adaptation Adaptive step tiers per batch-size range Positioned for medium-to-low QPS; an auto-tune script searches configs against SLOs such as p99 latency
Lossless caveat LiLiCorr changes acceptance only, verification stays exact FLy mode is not distribution-preserving

The sources disagree about draft-model support. A 2025 anatomy post from the vLLM team says vLLM V1 does not support the separate draft-model method. The 2025 batch-speculation paper says SGLang supports only EAGLE-family drafters. The current documentation for each engine lists draft-model support: SGLang through STANDALONE and vLLM under “draft models”. Pin the engine version before you plan around a method.

On method choice, the vLLM documentation says model-based methods such as EAGLE and MTP give the best latency reduction. Simpler n-gram and suffix methods give modest speedups without adding work during peak traffic. It adds that real gains depend on model family, traffic pattern, hardware and sampling settings.

How Do We Measure Whether Enabling It Improved p95 Latency, Time per Output Token and Tokens per Second?

Run an A/B test on the same hardware, prompt set and concurrency profile, with speculation off and then on, and compare the distributions rather than the averages. The vLLM team recommends treating speculative decoding as a runtime optimisation tuned on representative workloads, with throughput, mean accepted length, overall acceptance and per-position acceptance as the signals. Add p95 latency and time per output token, measured before and after enabling it. A gain at QPS 1 says nothing about the evening peak. The SmartSpec authors use goodput (accepted and bonus tokens per second) instead of raw throughput, because not every token processed is a token generated.

Before production, a performance audit should confirm the following:

  • Decode-bound path. Profiling shows decode, not prefill or host overhead, dominates time per request. Speculation needs spare compute that only a memory-bound regime provides. Our guide to profiling GPU kernels to find the real bottleneck covers how to read this.
  • Acceptance on real prompts. Measure acceptance at the deployed temperature, not on greedy runs, since it drops as temperature rises.
  • Peak-load behaviour. p95 and time per output token are compared before and after at the highest request rate you serve.
  • Memory headroom. The KV pool still fits your context lengths and batch sizes with the draft buffers allocated.
  • Output equivalence. At temperature 0, speculative and non-speculative outputs match token for token. Any difference points to an implementation error.

This is where context beats dogma. “Enable speculative decoding” is good advice only once profiling has established the acceptance rate and batch behaviour of your workload.

How Does Speculative Decoding Fit Alongside Other SGLang Runtime Settings When Porting an LLM to a Faster Serving Path?

Speculative decoding is one runtime setting among several. In an LMSYS deployment from 2025 on 16 H200 GPUs serving long-context DeepSeek traffic, overlap scheduling alone took output from 51 to 60.4 tokens/s per rank, which met the production threshold without MTP. Adding a 3-token MTP window with topk=1 reached 81.5 tokens/s per rank. At 128 H200 GPUs with prefill-decode disaggregation and 128 concurrent requests per rank, MTP raised output throughput by 14.2% over a baseline with neither overlap scheduling nor MTP. When prefill and decode are split across nodes, the decode pool’s batch size decides how much speculation can do, which is why prefill/decode disaggregation in SGLang and speculation are best tuned together.

Speculative decoding can recover latency headroom without an architecture change, retraining or replacing the model, and the output distribution stays the same, provided the path is decode-bound and acceptance holds. A smaller model changes the outputs, so it means re-running quality evaluation, which speculation avoids. The smaller model is the better choice when the larger model’s quality is more than the task needs, or when the serving path is compute-bound at the concurrency you need, where speculation has nothing to work with. The same logic runs through our piece on porting AI inference to a faster runtime without a model swap.

TechnoLynx judges any runtime move by cost per request. Our load-aware cost-per-request model for inference sets up that calculation, and the unit-economics view of speculative inference applies it to this technique.

FAQ

What Is Eagle 3 Speculative Decoding?

EAGLE-3 attaches a lightweight drafting head, typically one Transformer decoder layer plus a linear layer, to the target model’s internal layers instead of using a separate draft model. It combines low, middle and high-level features from the target and proposes a dynamic tree of candidates, which the target verifies with tree attention.

What Is a Speculative Decoding Draft Model?

A draft model is a smaller, faster model that proposes candidate tokens for the larger target model to verify. It has to share the target’s vocabulary, and it must be small enough to avoid heavy overhead while staying accurate enough to be accepted often.