TL;DR
This paper introduces a novel sparse pretraining approach for Llama-2 7B models that achieves high accuracy recovery (up to 96.1% for 50% sparsity and 91.8% for 70% sparsity) even at significant sparsity levels. This method, combined with efficient inference engines, enables substantial speedups in both training and deployment, making LLMs more accessible and performant.
What Problem Does This Paper Address?
Large Language Models (LLMs) are incredibly powerful but suffer from massive computational requirements for training and inference. This size creates bottlenecks, limits accessibility, and has a significant energy impact. While techniques like quantization have helped, they face limits in preserving accuracy at higher compression levels. Weight pruning offers another avenue for compression, but existing methods often struggle to maintain high accuracy, especially at high sparsity levels and for complex tasks. This paper tackles the challenge of creating accurate, sparse foundational LLMs that can be efficiently trained and deployed without sacrificing performance on downstream tasks.
Methods
The core of this work lies in a novel sparse pretraining methodology. Instead of just pruning a dense model after training (post-training pruning), the authors combine the SparseGPT one-shot pruning method with subsequent sparse pretraining on a curated dataset. This pretraining phase enforces sparsity from the outset, creating a more robust foundation.
Key steps include:
- Sparse Pretraining: They start with a Llama-2 7B model and apply SparseGPT to achieve an initial sparsity (e.g., 50%). This sparse model is then further pretrained on a mixture of SlimPajama and The Stack (Python subset) datasets. For higher sparsity (70%), they iteratively prune and retrain. Algorithm 1 details how sparsity masks are maintained during this process.
- Sparse Fine-Tuning: The pretrained sparse models are then fine-tuned on downstream tasks. They compare several fine-tuning strategies, highlighting the advantage of starting with a sparse pretrained model.
- Efficient Inference: To realize the benefits of sparsity, they leverage Neural Magic's DeepSparse engine for CPUs and nm-vllm for GPUs. These engines are optimized for unstructured sparsity, employing techniques like bitmask expansion.
- Compounding Gains with Quantization: The authors also explore combining sparsity with post-training quantization (INT8) to achieve even greater speedups, demonstrating a synergistic effect.
Datasets
- Training/Pretraining:
- SlimPajama [18]: A large, cleaned, and deduplicated dataset.
- The Stack (Python subset) [19]: A compilation of permissively licensed source code from GitHub, specifically the Python portion.
- The authors created a mixed dataset for pretraining, using approximately 2% to 8% of the tokens used for the original Llama-2 model.
- Fine-tuning/Evaluation:
- Limited Context Tasks:
- GSM8K [26]: For arithmetic reasoning.
- Limited Context Tasks:
- CNN Daily Mail [27]: For summarization.
- Large Context Tasks: * UltraChat200k [29, 30]: For chat.
- Dolphin [31] + Open Platypus [32]: For instruction following.
- Evol Code Alpaca [33]: For code generation.
Key Insights and Ideas
- Sparse Pretraining is Crucial for High Sparsity Recovery: The paper strongly suggests that simply pruning a dense model and fine-tuning is insufficient for achieving high accuracy at significant sparsity levels (e.g., 70%). Starting with a sparse pretrained model is key to robust performance.
- Sparsity Acts as a Regularizer: For simpler tasks, moderate sparsity can even lead to better than baseline accuracy, indicating a regularizing effect.
- Task Complexity Matters: The effectiveness of different sparse fine-tuning strategies varies with task complexity. Large context tasks (chat, code generation) benefit more from the broad knowledge embedded in sparse pretraining, while limited context tasks are more forgiving.
- Hardware-Software Co-design for Sparsity: The Cerebras CS-3's architecture and Neural Magic's software stack are highlighted as critical enablers for realizing the performance benefits of sparsity, showcasing the importance of specialized hardware and optimized software.
- Synergy of Sparsity and Quantization: Combining sparsity with quantization offers compounding performance gains, suggesting a powerful path towards highly efficient LLMs.
Key Results
- Accuracy Recovery:
- Achieved 96.1% recovery of Llama Evaluation metrics at 50% sparsity using sparse pretraining.
- Achieved 91.8% recovery at 70% sparsity, a significant improvement over post-training pruning methods.
- For large context tasks, sparse pretrained models consistently outperformed other methods, achieving full recovery on average at 50% and 99.6% at 70% sparsity for chat.
- Training Acceleration: Sparse training on Cerebras CS-3 showed close to ideal theoretical speedups.
- Inference Acceleration:
- Up to 3x speedup on CPUs using Neural Magic's DeepSparse engine.
- 1.7x speedup on GPUs using Neural Magic's nm-vllm engine.
- Combined Sparsity and Quantization:
- Up to 3.86x faster prefill performance on CPUs.
- Up to 8.6x faster decode performance on CPUs for sparse-quantized Llama models.
Limitations and Future Work
- Limitations:
- The current work focuses on the Llama-2 7B model. Scaling these techniques to larger models is a natural next step.
- The paper mentions that for 70% sparsity, instruction tuning fell slightly below the full recovery threshold on average for large context tasks, though still significantly better than other methods.
- The ablation study on sparsity profiles (uniform vs. OWL) found uniform to be slightly better for pretraining, but further investigation might be warranted.
- Future Work:
- Scaling studies with larger LLM architectures.
- Adaptations to novel LLM architectures.
- Refined quantization techniques (e.g., INT4).
- Investigations into optimal pretraining dataset composition and size.
- Exploring the impact of different sparsity patterns beyond uniform.
Summary updated