TL;DR
Standard speculative decoding uses one small "drafter" model to speed up a large "target" model. This paper introduces Hierarchical Speculative Decoding (HSD), which stacks multiple drafters of increasing size into a hierarchy. By reducing the search for the optimal hierarchy to a classic graph problem, the authors achieve up to a 1.2x speedup over the best single-drafter methods without any loss in output quality.
What Problem Does This Paper Address?
Large Language Models (LLMs) are notoriously slow because they generate text "autoregressively"—one token at a time. Each token requires a full pass through the massive network. Speculative Decoding (SD) was a breakthrough that addressed this: a tiny, fast model "speculates" several tokens ahead, and the big model verifies them all in a single parallel pass.
However, there is a catch: the "Pareto frontier" of drafters. A tiny model is fast but often wrong (low acceptance rate); a medium model is more accurate but slower. Most current systems just pick one drafter and hope for the best. The authors of this paper ask: Why use only one drafter when we could use a chain of them? If we have a hierarchy where each model verifies the one below it, can we squeeze out even more performance?
Methods
The authors introduce the Hierarchical Speculative Decoding (HSD) algorithm and a rigorous way to optimize it.
- The HSD Algorithm: In HSD, models are stacked. The smallest model ($M_0$) generates tokens autoregressively. The next model ($M_1$) verifies those tokens. If $M_1$ accepts them, they are passed to $M_2$, and so on, until the final target model ($M_K$) gives the ultimate seal of approval.
- Latency Analysis: The authors derive a mathematical expression for the "expected latency per token" for any given hierarchy. This formula accounts for the cost of each model's forward pass and the probability that one model will accept another's suggestions.
- Optimal Hierarchy Construction: This is the paper's "secret sauce." Choosing which models to include in the stack and how many tokens each should draft is a massive combinatorial problem. The authors prove this can be reduced to the Generalized Shortest Path (GSP) problem. This allows them to find the mathematically optimal hierarchy in polynomial time using standard graph solvers.
Datasets
The researchers evaluated HSD across several standard LLM benchmarks and model families:
- Models: They tested LayerSkip (7B, 13B, and 70B), Gemma2-9B, and T5-XXL (11B). For Gemma, they specifically trained auxiliary "early-exit" heads to create a pool of internal drafters.
- Datasets:
- CNN-DM and XSUM: Standard benchmarks for document summarization.
- GSM8K: A dataset of grade-school math word problems to test reasoning.
- MMLU: A massive multitask benchmark covering 57 subjects across STEM, the humanities, and more.
Key Insights and Ideas
- Models as Both Drafters and Verifiers: In HSD, intermediate models play a dual role. They act as a "target" for the model below them and a "drafter" for the model above them.
- The Power of Early Exits: The paper shows that you don't necessarily need separate draft models. Using "early-exit" layers (where you attach a prediction head to an intermediate layer of the big model) provides a perfect, low-overhead pool of candidates for a hierarchy.
- Guaranteed Quality: Like standard speculative decoding, HSD is "lossless." The final output distribution is mathematically identical to what the large target model would have produced alone.
- Optimization is Feasible: The most surprising theoretical insight is that finding the "best" stack of models isn't a matter of trial and error; it’s a solvable optimization problem that takes only a couple of hours on a standard CPU.
Key Results
- Superior Speedups: HSD consistently outperformed single-drafter baselines. For example, on the LayerSkip-70B model, HSD achieved a 1.77x speedup over vanilla decoding, whereas the best single-drafter setup only managed 1.58x.
- Efficiency Gains: Compared to the best possible single-drafter baseline, HSD provided an additional 10% to 20% (1.2x) speedup.
- Robustness: The speedup held true across different model sizes (7B to 70B) and different tasks (summarization vs. math).
- Temperature Flexibility: The authors found that HSD remains effective even when the "temperature" (randomness) of the generation changes, which often breaks simpler speculative schemes.
Limitations and Future Work
- Memory Overhead: While HSD is faster, it can be memory-intensive. Storing multiple draft models or multiple language model heads (as seen with Gemma2) requires more VRAM.
- IID Assumption: The theoretical latency proof assumes that token acceptances are "Independent and Identically Distributed" (IID). While their empirical tests show this assumption works well in practice, language is naturally sequential and correlated, meaning there's room for even more sophisticated modeling.
- Integration with Other Tricks: The authors suggest that future work could combine HSD with other speculative techniques, such as Medusa (multiple-head prediction) or Tree-based decoding, to push the speed limits even further.
Summary updated