TL;DR
This paper introduces DuoDecoding, a novel approach to accelerate Large Language Model (LLM) inference by strategically distributing draft and target models across CPU and GPU for parallel processing. By optimizing draft budgets and employing dynamic multi-sequence drafting, DuoDecoding achieves significant speedups (up to 2.61x) and reduces the time to first token (TTFT) while maintaining output quality.
What Problem Does This Paper Address?
Large Language Models (LLMs) are incredibly powerful but suffer from slow inference speeds due to their token-by-token autoregressive generation process. This sequential nature creates a bottleneck, limiting their practical use in real-time applications. Speculative decoding offers a solution by using a smaller "draft" model to predict multiple tokens ahead, which are then verified by the larger "target" model. However, the draft model itself introduces computational overhead, often becoming a bottleneck and increasing the time to generate the very first token (TTFT). Existing methods to alleviate this draft overhead often rely on heuristics and can compromise the quality of the draft predictions.
Methods
DuoDecoding tackles the draft overhead problem by introducing a hardware-aware heterogeneous speculative decoding strategy. The core idea is to leverage different computational resources: the larger, more accurate target model runs on the GPU, while the smaller, faster draft model runs on the CPU. This allows for parallel execution of the draft and verification phases, unlike traditional sequential speculative decoding.
Key innovations include:
- Heterogeneous Parallel Decoding: Distributing models across CPU and GPU to enable concurrent draft generation and target model verification.
- Hardware-aware Optimal Draft Budget: A mechanism to dynamically adjust the number of tokens the draft model generates per iteration. This budget is calculated based on the relative speeds of the CPU and GPU to minimize idle times and maximize hardware utilization.
- Dynamic Multi-Sequence Drafting: Instead of drafting a single sequence of tokens, DuoDecoding can draft multiple sequences simultaneously. This is guided by the "draft uncertainty" (approximated by token probabilities) to improve the acceptance rate of drafted tokens, especially when the draft model's initial predictions are less confident.
- Verification Process: An adapted verification strategy that handles both previously unverified tokens and the newly drafted multi-sequences, ensuring consistency with the target model's output distribution.
Datasets
The paper evaluates its method on seven diverse task categories, including:
- MT-bench: For multi-turn dialogue generation.
- Machine Translation: Using the WMT14 DE-EN dataset.
- Summarization: Using the CNN/Daily Mail dataset.
- Question Answering: Using Natural Questions.
- Mathematical Reasoning: Using GSM8k.
- Retrieval-Augmented Generation: Using Natural Questions with concatenated Wikipedia documents.
- Code Generation: Using HumanEval.
The paper also mentions using the SpecBench dataset for evaluation, which consists of 80 samples. For HumanEval, the full set of 164 samples was used.
Key Insights and Ideas
- CPU for Draft, GPU for Target is a Winning Combo: The paper demonstrates that offloading the draft model to the CPU, while counter-intuitive for speed, actually enables significant acceleration by allowing parallel execution with the GPU-bound target model. This is a crucial insight for efficient hardware utilization.
- Dynamic Drafting is Key: Simply increasing the number of draft tokens isn't always optimal. DuoDecoding's dynamic multi-sequence drafting, guided by uncertainty, proves more effective than static approaches, especially in tasks with more complex or error-prone draft predictions.
- Hardware Awareness Matters: A fixed draft budget can lead to inefficiencies. The hardware-aware budget, tailored to the specific CPU-GPU configuration, is essential for maximizing throughput and minimizing idle time.
- TTFT Improvement is Significant: Beyond overall latency, reducing the time to the first token is critical for interactive applications. DuoDecoding shows a substantial improvement in TTFT compared to standard speculative decoding.
Key Results
- Speedup: DuoDecoding achieves up to 2.61x speedup in generation latency across various tasks and models.
- Time to First Token (TTFT): The method reduces TTFT to approximately 83% of that achieved by conventional speculative decoding.
- Model Performance: On Vicuna-7b-v1.5, DuoDecoding provides an average speedup of 1.58x. When applied to Llama2-7b, the average speedup increases to a remarkable 2.57x.
- Task-Specific Performance: Exceptional effectiveness was observed in mathematical reasoning (3.31x speedup), question answering (3.18x), and translation (3.00x) on Llama2-7b.
- Draft Uncertainty: The analysis of sequence number prediction shows that in 56.5% of cases where the sequence number is 1, the entire prediction sequence would be rejected, highlighting the benefit of exploring multiple sequences.
Limitations and Future Work
- Batch Size: The current work focuses on single-instance inference and does not explore performance with large batch sizes.
- Model Size: Experiments were primarily conducted on 7B parameter models. The effectiveness on larger models remains to be explored.
- Hardware Configuration: Evaluations were performed on a single hardware setup (A800 GPU and Intel Xeon CPU). Performance characteristics on different computing platforms are yet to be investigated.
The authors suggest that their work inspires further research into leveraging heterogeneous resources for LLM inference, with speculative decoding serving as a promising framework for collaborative inference.
Summary updated