What exactly is Speculative Decoding?

· Source: LLM on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Advanced, long

Summary

Speculative Decoding is a technique that accelerates large language model (LLM) text generation by two to three times without altering the output tokens. Unlike other speed optimizations, it offers a "free lunch" by producing bit-for-bit identical text to what the large model would generate alone. The method employs a small, fast "draft" model to predict a burst of future tokens (e.g., gamma=4), which the large "target" model then verifies in a single parallel pass. This is efficient because a large model's forward pass is memory-bandwidth bound, meaning scoring multiple tokens costs almost the same as scoring one. If drafted tokens are correct, several words are accepted for the cost of one big-model step. The process is provably lossless, ensuring the emitted token distribution matches the target model's, with a bad draft only reducing speed, not correctness. Real-world speedups range from 2x to 3x, with TensorRT-LLM on H200 achieving up to 3.6x and EAGLE-3 up to 6.5x. This technique is most effective in low-latency, low-batch serving scenarios where the GPU has spare compute.

Key takeaway

For AI Engineers optimizing LLM inference latency, Speculative Decoding offers a significant speedup without compromising output quality. If you are deploying models in low-latency, low-batch serving environments, implementing this technique can yield 2x-3x faster generation. Be aware that it may cause slowdowns in high-batch, compute-bound scenarios, so carefully evaluate your operational context before adoption. Consider using a small draft model or exploring methods like Medusa or EAGLE for self-drafting.

Key insights

Speculative decoding uses a small draft model to predict tokens, verified by a large model in one pass, achieving lossless speedup.

Principles

Method

A small draft model proposes gamma tokens; the large target model verifies all in one parallel pass, accepting with `min(1, p/q)` and resampling rejections from `norm(max(0, p - q))`.

In practice

Topics

Best for: Machine Learning Engineer, AI Engineer, AI Scientist

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.