Discovering Sparsity Allocation for Layer-wise Pruning of Large Language Models

Lujun Li, Peijie Dong, Zhenheng Tang, Xiang Liu, Qiang Wang, Wenhan Luo, Wei Xue, Qifeng Liu, Xiaowen Chu, Yike GuoNeurIPS 2024

Pruning Large Language Models (LLMs) is often a "one-size-fits-all" affair—most methods simply chop away a fixed percentage of weights from every single layer. But as any neural network researcher knows, not all layers are created equal. A new paper introduces DSA (Discovering Sparsity Allocation), an automated framework that uses evolutionary algorithms to find the perfect "pruning recipe" for each layer, leading to massive performance gains over standard uniform pruning.

TL;DR

DSA is the first automated framework that discovers optimal layer-wise sparsity ratios for LLMs by searching through a mathematical space of "allocation functions." By moving away from uniform pruning, DSA achieves up to a 10.65% accuracy gain on LLaMA-3 models compared to state-of-the-art methods like SparseGPT and Wanda.

What Problem Does This Paper Address?

Pruning is essential for deploying massive LLMs on consumer hardware, but it usually involves a trade-off: the more you prune, the more the model's "intelligence" degrades.

The current bottleneck is uniformity. Most popular pruning techniques (like Wanda or SparseGPT) apply the same sparsity ratio (e.g., 50%) to every layer. However, empirical evidence suggests that the initial layers of a model are often more critical for fundamental language understanding than deeper layers. While some "non-uniform" methods exist (like OWL), they rely on handcrafted heuristics and manual hyperparameter tuning that don't always generalize across different model architectures or tasks. The challenge is: How do we efficiently find the mathematically optimal sparsity for every layer without expensive trial-and-error?

Methods

The researchers treat the search for a sparsity allocation strategy as an AutoML problem. They developed an expression discovery framework that maps element-wise weight importance scores to a specific sparsity ratio for each layer.

The DSA framework constructs a search space based on four cascading operations:

  1. Pre-process ($T_{pre}$): Normalizes or transforms raw importance scores (e.g., using Log or Abs).
  2. Reduction ($T_{reduce}$): Aggregates element-wise data into a single per-layer score (e.g., Mean, Geometric Mean, or Entropy).
  3. Transform ($T_{trans}$): Models the distribution of layer scores into a sparsity pattern (e.g., using Sine or Sigmoid).
  4. Post-process ($T_{post}$): Ensures the final ratios are valid (between 0 and 1) and meet the overall model size constraints.
The DSA framework uses an evolutionary algorithm to search through a space of mathematical operations, mapping element-wise scores to optimal layer-wise sparsity ratios.

To find the best combination of these operations, DSA employs an Evolutionary Algorithm. It starts with a population of random functions, evaluates their performance (using perplexity on a validation set), and then performs "crossover" and "mutation" on the winners to evolve even better strategies. Remarkably, this search is highly efficient, taking only about 0.5 days on a single NVIDIA H800 GPU.

Datasets

The authors evaluated DSA across a massive range of benchmarks to prove its generalizability:

  • Language & Reasoning: WikiText-2 (perplexity), GSM8K (arithmetic), MMLU (general knowledge).
  • Zero-shot Tasks: Winogrande, OpenBookQA, HellaSwag, BoolQ, ARC, and RTE.
  • Multimodal: VQAv2, SQA, and VQA (using the LLaVA-1.5 architecture).
  • Models: The framework was tested on LLaMA-1/2/3, Mistral, and OPT, ranging from 7B to 70B parameters.

Key Insights and Ideas

  • The "Front-Loading" Intuition is Real: The discovered functions naturally tended to assign lower sparsity (preserving more weights) to the earlier layers of the models, confirming that these layers are indeed more sensitive.
  • Complexity Wins: The top-performing discovered function was surprisingly intricate, involving nested logarithms and geometric means. This suggests that human-designed heuristics are likely too simple to capture the true redundancy patterns in LLMs.
  • Plug-and-Play Compatibility: DSA isn't a new pruning metric; it’s an allocation strategy. It can be seamlessly integrated into existing methods like Wanda or SparseGPT, acting as a "force multiplier" for their effectiveness.
  • Robustness at Extremes: DSA shines most at high sparsity levels (70-80%). While uniform pruning causes models to "collapse" at these levels, DSA-allocated models maintain significantly better performance.

Key Results

Performance gains of DSA when integrated with standard pruning methods like Magnitude, Wanda, and SparseGPT across various LLM architectures.
  • LLaMA-3 Performance: When integrated with SparseGPT on LLaMA-3 8B, DSA achieved a 10.65% gain in mean accuracy across zero-shot tasks.
  • Magnitude Pruning Boost: On LLaMA-3 8B, it provided a staggering 14.58% improvement over standard magnitude pruning.
  • Multimodal Superiority: For LLaVA-1.5 (Vicuna-7B) at 50% sparsity, DSA achieved a top score of 76.08% on VQAv2, outperforming all other pruning baselines.
  • Perplexity Stability: At 80% sparsity on LLaMA-1-7B, DSA maintained a perplexity of 736.81, while the next best method (OWL) shot up to 1002.87, and uniform pruning exploded to 3499.88.

Limitations and Future Work

  • Search Cost: Although 0.5 days on an H800 is relatively cheap, it is still an additional step compared to "one-shot" pruning.
  • Domain Knowledge: The current search is purely mathematical. The authors suggest that incorporating more architectural domain knowledge (like attention head dynamics) could further refine the search space.
  • Future Direction: The team plans to develop even more efficient search algorithms and explore how these discovered allocation functions might change during the actual training or fine-tuning process of an LLM.

Summary updated

BibTeX
@inproceedings{li2024discovering,
  author = {Lujun Li and Peijie Dong and Zhenheng Tang and Xiang Liu and Qiang Wang and Wenhan Luo and Wei Xue and Qifeng Liu and Xiaowen Chu and Yike Guo},
  title = {{Discovering Sparsity Allocation for Layer-wise Pruning of Large Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=rgtrYVC9n4},
}
Figure