E-Sparse: Boosting the Large Language Model Inference through Entropy-based N: M Sparsity

Yun Li, Lin Niu, Xipeng Zhang, Kai Liu, Jianchen Zhu, Zhanhui KangarXiv 2023 · DOI

Introduction

Deploying Large Language Models (LLMs) presents significant challenges due to their immense memory and computational requirements. While pruning—the removal of redundant weights—is a common strategy, traditional methods often require costly retraining. One-shot pruning techniques like Wanda and SparseGPT have emerged as alternatives, but they frequently struggle with N:M sparsity. This specific structured sparsity pattern (e.g., 2:4) is highly desirable because it is physically accelerated by modern NVIDIA Ampere and Hopper GPUs. However, LLMs contain "outlier" features—highly informative values concentrated in specific channels. When these critical features cluster together, standard N:M masking is forced to delete them, resulting in substantial accuracy loss.

Methodology

The E-Sparse framework addresses these challenges through two primary innovations: an entropy-based importance metric and a channel shuffling mechanism.

Entropy-based Pruning Metric

Unlike traditional methods that rely solely on weight or activation magnitudes, E-Sparse incorporates Information Entropy (Shannon Entropy) to quantify "information richness" within each channel. The importance score for a weight is calculated by combining its magnitude, the channel's overall amplitude, and its entropy. This approach recognizes that channels with diverse, informative signals are more critical to model performance than those with high magnitude but low information content.

Overview of the E-Sparse framework, illustrating the integration of feature norm and information entropy into the channel importance metric and subsequent N:M sparsity application.

Channel Shuffle

To mitigate the "clustering curse" where high-information channels are grouped together, E-Sparse employs a two-stage shuffling process:

  1. Global Naive Shuffle: Channels are sorted globally based on importance scores to distribute high-information features across the entire layer.
  2. Local Block Shuffle: A greedy search algorithm fine-tunes the order within smaller blocks (e.g., 256 channels). This ensures that the N elements preserved in every M-sized block are the most critical ones.

The framework is integrated into FasterTransformer, leveraging NVIDIA’s cuSPARSE libraries to achieve real-world hardware acceleration.

Experimental Results

E-Sparse was evaluated using the LLaMA (7B to 65B) and OPT (6.7B, 30B) model families across various benchmarks.

Accuracy and Perplexity

On LLaMA-13B with 2:4 sparsity, E-Sparse achieved a WikiText-2 perplexity of 8.26, significantly outperforming Wanda (9.58) and SparseGPT (9.11). Furthermore, zero-shot evaluations across tasks like HellaSwag and PiQA demonstrated that E-Sparse consistently maintains higher accuracy than competing one-shot methods, often staying within 1-2% of the original dense model's performance.

Zero-shot performance comparison of E-Sparse against other pruning methods across various LLaMA model sizes and benchmarks.

Efficiency and Speedup

The implementation delivered a 1.24x to 1.53x inference speedup over dense FP16 models on NVIDIA A100 GPUs. Additionally, it achieved memory savings between 42.64% and 43.52%, facilitating the deployment of larger models on restricted hardware.

Conclusion

E-Sparse demonstrates that incorporating information entropy into pruning metrics and redistributing critical features via channel shuffling can effectively enable N:M sparsity in LLMs without retraining. While currently focused on NLP, future work may extend this approach to other domains like Computer Vision or combine it with quantization techniques for further optimization.

Summary updated

BibTeX
@misc{li2023e,
  author = {Yun Li and Lin Niu and Xipeng Zhang and Kai Liu and Jianchen Zhu and Zhanhui Kang},
  title = {{E-Sparse: Boosting the Large Language Model Inference through Entropy-based N: M Sparsity}},
  year = {2023},
  eprint = {2310.15929},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.15929},
}
Figure