TL;DR
This paper introduces SD$^2$ (Self-Distilled Sparse Drafters), a novel method for creating highly efficient "draft" language models that significantly speed up text generation. By combining self-distillation and fine-grained sparsity, SD$^2$ achieves better performance than existing methods, even when the draft and target models are from different families, offering a path to more accessible and faster LLMs.
What Problem Does This Paper Address?
Large Language Models (LLMs) are incredibly powerful but notoriously slow and computationally expensive, especially during text generation. This latency is a major bottleneck for real-time applications. While speculative decoding offers a way to speed things up by using a smaller "draft" model to predict tokens that a larger "target" model then verifies, finding efficient and well-aligned draft models has been a challenge. Traditional compression techniques like pruning layers can reduce model size but often lead to a drop in accuracy. This paper aims to bridge this gap by developing highly efficient, accurate, and well-aligned sparse draft models for speculative decoding.
Methods
The core of SD$^2$ lies in a three-pronged approach:
- Self-Data Distillation: This technique generates a new training dataset by having the target LLM produce outputs for given inputs. This ensures the draft model learns to mimic the target model's behavior, crucial for alignment. A key innovation here is that they accept these "distilled" labels even if they contain errors, as the goal is alignment, not perfect replication of the target's output distribution.
- One-Shot Fine-Grained Pruning: The authors use SparseGPT to prune the weights of the draft model. They explore both unstructured sparsity (randomly removing weights) and structured sparsity (like 2:4, where 2 out of 4 weights are kept, which is more hardware-friendly).
- Sparse Fine-Tuning: After pruning, the sparse draft model is fine-tuned using the self-distilled dataset. This step is critical for recovering any accuracy lost during pruning and ensuring the draft model is well-aligned with the target model. They specifically use a binary mask to keep pruned parameters at zero and prevent their gradients from affecting the active parameters during training.
As a baseline, they also implement a layer-pruning method, removing entire transformer blocks.
Datasets
The paper utilizes several datasets:
- Fine-tuning Datasets: They curate fine-tuning datasets by combining original inputs, ground truth labels, and task-specific context.
- Self-Data Distillation Datasets: They generate these using the target models (Llama-3.1-70B and Qwen-2.5-72B) on datasets like Opus-100 translation and MathInstruct-V2.
- Magpie Datasets: Publicly available datasets generated using the self-synthesis method Magpie are also used for Llama and Qwen target models.
- Evaluation Benchmarks:
- OpenLLM Leaderboard V1: Used for evaluating downstream task accuracy across various tasks (ARC-C, GSM8k, HellaSwag, MMLU, Winogrande, TruthfulQA, MC2).
- SpecBench: Used to assess draft token acceptance rates across tasks like translation, summarization, and RAG.
- WikiText-V2: Used for evaluating perplexity.
Key Insights and Ideas
- Alignment is Key: The paper strongly emphasizes that for speculative decoding, aligning the draft model's output distribution with the target model's is more important than perfect accuracy on the distilled data. This allows them to accept potentially erroneous but aligned draft tokens.
- Fine-Grained Sparsity Outperforms Layer Pruning: Contrary to expectations, fine-grained sparsity (unstructured and 2:4) combined with SD$^2$ fine-tuning leads to better Mean Accepted Length (MAL) and overall performance compared to layer-pruned models, especially for larger draft models.
- Universal Assisted Generation (UAG) Success: SD$^2$ demonstrates impressive alignment capabilities even when the draft and target models belong to different families (e.g., Qwen drafting for Llama), highlighting the robustness of their self-distillation approach.
- Sparsity for Larger Models: The results suggest that fine-grained sparsity becomes increasingly beneficial for larger draft models, potentially enabling the use of more capable, yet still efficient, drafters.
Key Results
- Improved MAL: SD$^2$ models achieve a 1.59x higher Mean Accepted Length (MAL) compared to layer-pruned draft models.
- Reduced MACs: SD$^2$ reduces Multiply-Accumulate operations (MACs) by over 43.87% while only experiencing an 8.36% reduction in MAL compared to dense draft models.
- Latency Improvements: 1.5B and 3B SD$^2$ unstructured sparse drafters outperform both dense and layer-pruned models of equivalent size in terms of end-to-end latency.
- Accuracy Recovery: After one-shot pruning, fine-grained sparse models using SD$^2$ recover significant accuracy, with some 50% unstructured Qwen-2.5 models even exceeding the accuracy of their dense counterparts.
- UAG Performance: Sparse Qwen drafters, when used in the UAG setting with a Llama target, outperform their dense counterparts.
Limitations and Future Work
- Hardware Dependency: The effectiveness of unstructured sparsity for latency improvements is highly dependent on specialized hardware and software kernels (like nm-vLLM for NVIDIA GPUs). Evaluating SD$^2$ on other hardware (e.g., TPUs) is crucial.
- Compute Intensive: Fine-tuning and self-data distillation require significant computational resources.
- Future Directions:
- Integrating quantization-aware training, draft-token trees, and compressed KV-cache implementations with SD$^2$.
- Benchmarking SD$^2$ on hardware optimized for unstructured sparsity (e.g., Cerebras wafer-scale engine).
- Exploring advanced fine-tuning strategies like speculative knowledge distillation or square-head distillation.
- Combining structured pruning with fine-grained sparsity and quantization for further latency reduction.
Summary updated