Skip to content

Speculative decoding in vLLM-TorchTPU

Use this guide when decode latency (TPOT) matters more than peak throughput, typically at small batches, and you want the target model to verify several drafted tokens per forward pass. vLLM-TorchTPU supports six methods through --speculative-config. This guide picks one, launches it, and measures whether it pays with the benchmarking harness's spec_bench mode. Chapter 17 explains why a decode pass that scores several tokens costs about what one that scores a single token does; chapter 18 shows a speculation cycle.

Prerequisites

Steps

1. Choose the method

Method "method" Draft checkpoint Best for
EAGLE-3 "eagle3" yes (yuhuili/EAGLE3-*) High acceptance across chat, coding and reasoning
Multi-token prediction "mtp" (or "qwen3_next_mtp") built into the checkpoint (Qwen3.5, DeepSeek-V3/R1, GLM-5) Models trained with MTP heads; no draft model to manage
DFlash "dflash" yes (z-lab/*-DFlash-*) Block-diffusion drafts of up to 16 tokens in one forward pass (Qwen3, Qwen3.5)
DSpark "dspark" yes (deepseek-ai/dspark_*, Inferact/Kimi-K3-DSpark) Parallel block drafting with a sequential Markov head (Qwen3, DeepSeek-V4, Kimi-K3)
N-gram "ngram" no Repetitive prompts, code edits, citations, RAG extraction
Suffix decoding "suffix" no A suffix tree over the prompt and earlier responses

Check: if the method needs a draft checkpoint, one exists for your target model.

2. Launch with --speculative-config

--speculative-config takes a JSON object with "method", "num_speculative_tokens" and, for methods with a separate drafter, "model". The vLLM-TorchTPU speculative decoding guide's commands:

EAGLE-3 (builder profile spec-eagle3-qwen3-32b):

vllm serve Qwen/Qwen3-32B \
  --tensor-parallel-size 8 \
  --max-model-len 8192 \
  --speculative-config '{
    "method": "eagle3",
    "model": "RedHatAI/Qwen3-32B-speculator.eagle3",
    "num_speculative_tokens": 3
  }'

MTP, from heads inside the checkpoint (builder profile spec-mtp-qwen3.5-35b):

vllm serve Qwen/Qwen3.5-35B-A3B-FP8 \
  --tensor-parallel-size 4 \
  --enable-expert-parallel \
  --kv-cache-dtype fp8 \
  --speculative-config '{
    "method": "mtp",
    "num_speculative_tokens": 1
  }'

DFlash:

vllm serve Qwen/Qwen3-8B \
  --tensor-parallel-size 2 \
  --max-model-len 4096 \
  --speculative-config '{
    "method": "dflash",
    "model": "z-lab/Qwen3-8B-DFlash-b16",
    "num_speculative_tokens": 15
  }'

DSpark:

vllm serve Qwen/Qwen3-4B \
  --tensor-parallel-size 1 \
  --max-model-len 2048 \
  --speculative-config '{
    "method": "dspark",
    "model": "deepseek-ai/dspark_qwen3_4b_block7",
    "num_speculative_tokens": 7
  }'

N-gram (builder profile spec-ngram-llama3.1-8b) and suffix, with no draft model:

vllm serve meta-llama/Llama-3.1-8B-Instruct \
  --tensor-parallel-size 2 \
  --speculative-config '{
    "method": "ngram",
    "num_speculative_tokens": 5,
    "prompt_lookup_max": 4
  }'

vllm serve meta-llama/Llama-3.1-8B-Instruct \
  --tensor-parallel-size 2 \
  --speculative-config '{
    "method": "suffix",
    "num_speculative_tokens": 5
  }'

The book's builder prints the EAGLE-3 command and refuses an EAGLE-3, DFlash or DSpark config without a "model":

python code/ch18_vllm/launch_profiles.py --profile spec-eagle3-qwen3-32b

Check: Application startup complete, then a smoke request (python code/ch18_vllm/client.py smoke --model MODEL) returns a coherent answer. Every kept token is one the target would have chosen, so greedy outputs should match the server without speculation, up to near ties between numerics.

3. Measure speedup and acceptance with spec_bench

Choose num_speculative_tokens by measurement. run_benchmarks.sh in spec_bench mode sweeps batch size (SPEC_BS_LIST) by draft tokens (SPEC_K_LIST) on the Spec-Bench dataset. For each cell it restarts vllm serve with --max-num-seqs <BS> and the speculative config (K=0 runs without speculation as the baseline), runs warmup prompts and measured passes of vllm bench serve --dataset-name spec_bench --max-concurrency <BS>, and aggregates mean end-to-end time, speedup against K=0 and acceptance rate.

./scripts/vllm/benchmarking/run_benchmarks.sh --config qwen3-0.6b-ngram

The repository's Spec-Bench configs:

Config Model Method Draft K swept Topology
qwen3-0.6b-ngram Qwen3-0.6B ngram none 0 1 2 4 TP=1 (smoke)
llama-3-8b-ngram Meta-Llama-3-8B-Instruct ngram none 0 1 2 4 8 TP=1
llama-3.3-70b-eagle3 Llama-3.3-70B-Instruct eagle3 Llama-3.3-70B-Instruct-Eagle3 0 1 2 3 4 TP=8
gemma-4-31b-it-mtp gemma-4-31B-it mtp gemma-4-31B-it-assistant 0 1 2 3 4 5 TP=8
qwen3.5-397b-fp8-mtp Qwen3.5-397B-A17B-FP8 mtp built-in MTP head 0 1 2 3 4 5 TP=8, EP
qwen3-4b-dflash Qwen3-4B dflash Qwen3-4B-DFlash-b16 0 15 TP=1
qwen3-4b-dspark Qwen3-4B dspark dspark_qwen3_4b_block7 0 7 TP=1
qwen3.5-35b-fp8-dflash Qwen3.5-35B-A3B-FP8 dflash Qwen3.5-35B-A3B-DFlash 0 15 DP=2 × TP=4, EP

For your own model, copy a config and set SPEC_METHOD, SPEC_DRAFT_MODEL (and SPEC_DRAFT_TP), SPEC_K_LIST and SPEC_BS_LIST; SPEC_NUM_PROMPTS, SPEC_WARMUP_PROMPTS and SPEC_REPS default to 100, 20 and 2.

Check: the run directory holds bs<BS>/k<K>_rep<N>.json per cell and spec_benchmark_summary.md, with a speedup and an acceptance rate for each (BS, K). Pick the K with the best speedup at the batch sizes you serve; expect the gain to shrink as the batch grows, because a larger batch pushes each step toward the compute ridge.

Troubleshooting

Symptom Cause Fix
Startup fails for EAGLE-3, DFlash or DSpark No "model" in the config, or a draft for a different target Pass the draft checkpoint made for your target
spec_bench refuses to start K > 0 in SPEC_K_LIST without SPEC_METHOD Set SPEC_METHOD
Speedup near 1x or below Low acceptance on this traffic, or a batch large enough that the extra positions are no longer free Measure at your real batch size; try fewer draft tokens; n-gram only where prompts repeat
Good speedup on Spec-Bench, little in production Acceptance depends on the traffic; the harness defaults to the summarization category Set SPEC_BENCH_DATASET and SPEC_BENCH_CATEGORY closer to your prompts
Greedy outputs differ with speculation on A near tie between numerics, or a bug: verification keeps only tokens the target would choose Compare with client.py parity against the K=0 server and check divergences with the logprob tie rule of chapter 23

References