TL;DR
This paper introduces Hydra, a novel approach to speculative decoding for large language models (LLMs) that significantly boosts inference speed. By making "draft heads" (small models that propose text continuations) sequentially dependent on each other, Hydra achieves higher accuracy in predicting future tokens, leading to substantial throughput improvements over existing methods.
What Problem Does This Paper Address?
Large language models (LLMs) are becoming increasingly powerful, but their inference speed is often bottlenecked by memory bandwidth. Generating text token by token requires repeatedly fetching large model weights from memory, even though only a small amount of computation is performed per token. This "memory-bound" problem limits how quickly LLMs can generate responses. Speculative decoding aims to solve this by using a faster, less accurate "draft model" to propose multiple future tokens at once. A larger, more accurate "base model" then verifies these proposed tokens in parallel. However, existing methods for creating these draft models (specifically, "draft heads" that operate on the base model's internal states) make independent predictions for each future token, ignoring the strong sequential nature of language. This leads to suboptimal predictions and limits the overall speedup.
Methods
The core innovation of this paper is Hydra heads, a drop-in replacement for standard draft heads. Unlike previous approaches where each draft head predicts a future token independently, Hydra heads are sequentially dependent. This means each Hydra head considers not only the base model's hidden state but also the tokens already proposed by previous Hydra heads in the current sequence. This allows Hydra to better capture the linguistic dependencies between tokens.
The authors also introduce Hydra++, an enhanced version of Hydra that further optimizes draft head performance through:
- Scaling MLPs: Increasing the depth of the Multi-Layer Perceptrons used in the draft heads.
- Distillation: Training the draft heads to predict the base model's output distribution rather than just the ground truth token, leveraging a "teacher loss."
- Prefix Attention: Adding an extra decoder layer to the base model, specifically trained to provide richer contextual information to the Hydra heads.
The paper also details a data-driven approach to discovering optimal decoding trees for speculative decoding, which are crucial for maximizing throughput across different batch sizes and model configurations.
Datasets
- Training: The models were trained on the ShareGPT dataset, a collection of multi-turn conversations.
- Evaluation: Experiments were conducted on MT-Bench, a multi-turn conversation benchmark, and SpecBench, a suite of tasks including MT Chat, translation, summary, QA, math, and retrieval augmented generation (RAG).
Key Insights and Ideas
- Sequential Dependence is Key: The most significant insight is that making draft heads aware of previously proposed tokens in a candidate sequence dramatically improves their prediction accuracy. This aligns with the fundamental sequential nature of language.
- Hydra++: A Powerful Recipe: The combination of scaling MLPs, teacher distillation, and prefix attention (Hydra++) yields substantial gains, demonstrating that architectural and training improvements can significantly enhance speculative decoding.
- Trade-offs in Batching: While speculative decoding offers benefits across all batch sizes, the relative speedup decreases as batch size increases. This is because verification can become compute-bound at larger scales, requiring careful tree optimization.
- Typical Acceptance for Quality: Using a "typical acceptance" sampling criterion (instead of greedy acceptance) with Hydra++ allows for more diverse and creative generations while maintaining high acceptance rates and throughput, bridging the gap between speed and quality.
Key Results
- Hydra (basic sequentially-dependent heads) achieved up to 1.1x higher throughput compared to Medusa decoding.
- Hydra++ (enhanced version) achieved up to 1.31x higher throughput than Medusa decoding and up to 2.70x higher throughput than standard autoregressive decoding.
- Hydra++ demonstrated improved performance across various tasks in the SpecBench evaluation suite, with an average throughput improvement of 1.24x over Medusa.
- In batched inference, Hydra++ consistently outperformed Medusa across all tested batch sizes.
- With typical acceptance sampling, Hydra++ matched the generation quality of the base model while preserving speculative decoding's speed benefits.
Limitations and Future Work
- Overhead: Hydra decoding incurs some additional overhead compared to Medusa, particularly due to the prefix attention mechanism and the increased input features for Hydra heads. However, the paper argues that this overhead is more than compensated by the improved accuracy and acceptance length.
- Task-Specific Speedups: The speedup for summary and RAG tasks in SpecBench was smaller. The authors suggest further investigation into whether this can be improved by increasing training data for these tasks or if it's an inherent limitation of speculative decoding for these specific tasks.
- Future Work: The paper suggests exploring whether speedups on tasks like summarization and RAG can be improved. They also highlight that their work, alongside concurrent research like EAGLE, provides strong evidence for the robustness and replicability of sequential dependence in speculative decoding.
Summary updated