Speculative Decoding: How to Double Your LLM Inference Speed
Speculative decoding is one of the most effective techniques for speeding up LLM inference — achieving 2–3x throughput gains with zero quality loss. Here's how it works and how to enable it.
The Bottleneck: Autoregressive Decoding
Standard LLM inference generates one token at a time, sequentially. Each token requires a full forward pass through the model. On a 70B model, this means each token takes ~200ms — limiting throughput to 5 tokens/second even on an A100.
The root cause is memory bandwidth saturation. The GPU spends most of its time loading weights from VRAM into compute units, not doing computation. Memory bandwidth comparisons at LLMHardware.io show this bottleneck clearly across different GPU tiers.
How Speculative Decoding Works
Speculative decoding uses a small draft model (e.g., 1B params) to propose a sequence of K tokens cheaply. The large target model then verifies all K tokens in a single parallel forward pass. If most tokens are accepted, you get K tokens for the cost of ~1.2 forward passes of the large model.
- Llama 3 70B + Llama 3 8B draft: 2.3x speedup
- Mixtral 8x7B + Mistral 7B draft: 1.9x speedup
- Acceptance rate: 75–85% for general text
Enabling in vLLM
python -m vllm.entrypoints.openai.api_server --model meta-llama/Meta-Llama-3-70B-Instruct --speculative-model meta-llama/Meta-Llama-3-8B-Instruct --num-speculative-tokens 5 --tensor-parallel-size 2
Enabling in llama.cpp
./llama-speculative -m models/llama-3-70b.Q4_K_M.gguf -md models/llama-3-8b.Q4_K_M.gguf --draft 8 -p "Write a Python function that..."
When Speculative Decoding Helps Most
Speculative decoding works best when the draft and target models agree frequently. This happens with repetitive or predictable text: code generation, structured output, translations. It helps less with creative writing or tasks requiring high diversity.
The speedup also depends heavily on your hardware's memory bandwidth. GPUs with higher bandwidth see more benefit because the bottleneck shifts from memory loading to compute during the verification step.

Comments
Post a Comment