Production AI
Speculative Decoding

Speculative decoding speeds up LLM generation by exploiting a key asymmetry: ๐๐ผ๐ธ๐ฒ๐ป ๐ด๐ฒ๐ป๐ฒ๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐ถ๐ ๐๐ฒ๐พ๐๐ฒ๐ป๐๐ถ๐ฎ๐น, ๐ฏ๐๐ ๐๐ผ๐ธ๐ฒ๐ป ๐๐ฒ๐ฟ๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐ถ๐ ๐ฝ๐ฎ๐ฟ๐ฎ๐น๐น๐ฒ๐น.
๐ ๐ฎ๐ถ๐ป ๐ฏ๐ผ๐๐๐น๐ฒ๐ป๐ฒ๐ฐ๐ธ: Standard autoregressive decoding is memory-bandwidth bound. Each new token requires another full pass over the model weights in HBM, so GPUs spend much of their time waiting on memory rather than doing math.
๐๐ผ๐ฟ๐ฒ ๐ถ๐ฑ๐ฒ๐ฎ: Use a cheap draft proposer to guess several future tokens, then have the large target model verify them all at once in a single parallel forward pass.
๐๐ผ๐ ๐ถ๐ ๐๐ผ๐ฟ๐ธ๐: The draft model proposes K tokens; the target model checks them left-to-right, accepts matching tokens, and replaces any mismatch with a token sampled from the target distribution.
๐ช๐ต๐ ๐ถ๐โ๐ ๐น๐ผ๐๐๐น๐ฒ๐๐: With modified rejection sampling, the final output distribution is identical to sampling from the target model alone, so quality is preserved exactly.
๐๐ฟ๐ฎ๐ณ๐ ๐บ๐ฒ๐ฐ๐ต๐ฎ๐ป๐ถ๐๐บ๐:
- ๐ฆ๐บ๐ฎ๐น๐น ๐ฑ๐ฟ๐ฎ๐ณ๐ ๐บ๐ผ๐ฑ๐ฒ๐น + ๐น๐ฎ๐ฟ๐ด๐ฒ ๐๐ฎ๐ฟ๐ด๐ฒ๐ ๐บ๐ผ๐ฑ๐ฒ๐น โ good accuracy, but extra VRAM.
- ๐ฃ๐ฟ๐ผ๐บ๐ฝ๐ ๐น๐ผ๐ผ๐ธ๐๐ฝ / ๐ป-๐ด๐ฟ๐ฎ๐บ ๐บ๐ฎ๐๐ฐ๐ต๐ถ๐ป๐ด โ no extra model, very fast, best when output overlaps with context (๐ฒ.๐ด., ๐ฅ๐๐).
- ๐ฆ๐ฒ๐น๐ณ-๐๐ฝ๐ฒ๐ฐ๐๐น๐ฎ๐๐ถ๐ผ๐ป ๐ต๐ฒ๐ฎ๐ฑ๐ โ extra heads on the target model predict future tokens without a separate draft model.
๐ฃ๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป ๐๐ฟ๐ฎ๐ฑ๐ฒ-๐ผ๐ณ๐ณ:
- At ๐น๐ผ๐ ๐ค๐ฃ๐ฆ, speculative decoding usually helps a lot because GPUs have idle compute.
- At ๐ต๐ถ๐ด๐ต ๐ค๐ฃ๐ฆ, it can hurt latency because the system is already compute-saturated, so extra verification adds overhead.
๐ฃ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฎ๐น ๐๐ฟ๐ฒ๐ป๐ฑ: Modern systems use ๐ฑ๐๐ป๐ฎ๐บ๐ถ๐ฐ ๐๐ฝ๐ฒ๐ฐ๐๐น๐ฎ๐๐ถ๐ผ๐ป, adjusting speculative length based on current load.
Speculative decoding trades a little extra draft work for fewer expensive target-model passes, giving substantial latency gains when the GPU is memory-bound and underutilized.
flowchart TB
A["Faster generation โ bigger model"] --> B["GPU trace reveals bottleneck"]
B --> C["Memory bandwidth, not math"]
C --> D["Speculative decoding"]
D --> E["Cheap draft model"]
D --> F["Expensive target model"]
E --> G["Sequential token proposals"]
F --> H["Parallel verification pass"]
D --> I["Same target distribution"]
D --> J["Faster execution"]
subgraph R1["Core requirements"]
K["Tokenizer + vocabulary must match"]
L["Target model defines quality"]
M["Draft only proposes"]
end
subgraph R2["When it helps or hurts"]
N["Low-QPS: latency drops"]
O["High-QPS: may backfire"]
P["Spec length = dynamic knob"]
end
subgraph R3["Implementation options"]
Q["Small draft model"]
R["Prompt / N-gram lookup"]
S["Self-speculation heads"]
end
Q --> T["Trade-offs: VRAM, acceptance, complexity"]
R --> T
S --> T
D --> K
D --> L
D --> M
D --> N
D --> O
D --> P
classDef insight fill:#dbeafe,stroke:#2563eb,color:#111827;
classDef process fill:#dcfce7,stroke:#16a34a,color:#111827;
classDef constraint fill:#fef9c3,stroke:#ca8a04,color:#111827;
classDef tradeoff fill:#fee2e2,stroke:#dc2626,color:#111827;
classDef option fill:#ede9fe,stroke:#7c3aed,color:#111827;
class A,B,C,D insight;
class E,F,G,H process;
class K,L,M constraint;
class N,O,P tradeoff;
class Q,R,S,T option;