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.
Originally published on LinkedIn.
Turn your expertise into LinkedIn posts like this one.
Try Postars free โ