Beyond Size: How Gradients Shape Pruning Decisions in Large Language Models

Rocktim Jyoti Das, Liqun Ma, Zhiqiang Shen

Abstract

Large Language Models (LLMs) with billions of parameters are prime targets for network pruning, removing some model weights without hurting performance. Prior approaches such as magnitude pruning, SparseGPT, and Wanda, either concentrated solely on weights or integrated weights with activations for sparsity. However, they overlooked the informative gradients derived from pretrained LLMs. In this paper, we present a novel sparsity-centric pruning method for pretrained LLMs, termed Gradient-based Language Model Pruner (GBLM-Pruner). GBLM-Pruner leverages the first-order term of the Taylor expansion, operating in a training-free manner by harnessing properly normalized gradients from a few calibration samples to determine the pruning metric, and substantially outperforms competitive counterparts like SparseGPT and Wanda in multiple benchmarks. Intriguingly, by incorporating gradients, unstructured pruning with our method tends to reveal some structural patterns, which mirrors the geometric interdependence inherent in the LLMs' parameter structure. Additionally, GBLM-Pruner functions without any subsequent retraining or weight updates to maintain its simplicity as other counterparts. Extensive evaluations on LLaMA-1 and LLaMA-2 across various benchmarks show that GBLM-Pruner surpasses magnitude pruning, Wanda and SparseGPT by significant margins. We further extend our approach on Vision Transformer.

Introduction

As Large Language Models (LLMs) scale to hundreds of billions of parameters, their deployment on consumer-grade hardware is hindered by immense memory and computational requirements. Network pruning—the strategic removal of non-essential weights—offers a pathway to model compression. Existing "one-shot" pruning techniques, which avoid costly retraining, typically rely on weight magnitude (Magnitude Pruning) or a combination of weight size and activation intensity (Wanda). More sophisticated methods like SparseGPT utilize second-order Hessian information to update remaining weights.

However, these methods largely neglect the potential of gradients. The prevailing assumption has been that gradients in a converged, pretrained model are near zero and thus uninformative. GBLM-Pruner challenges this, demonstrating that properly normalized gradients provide critical insights into the geometric importance of parameters.

Methodology: GBLM-Pruner

GBLM-Pruner introduces a training-free, one-shot pruning metric derived from a first-order Taylor expansion of the loss function. The importance score for each weight is a weighted sum of two primary components: a gradient term and an activation term.

Figure 1: Overview of the GBLM-Pruner importance metric calculation, combining normalized gradients (G), weight magnitudes (W), and input activations (X).

The gradient term is the product of the weight magnitude and the $\ell_1$ or $\ell_2$ norm of the gradients across calibration samples. The activation term follows the Wanda approach, multiplying weight magnitude by the norm of input activations. A scaling factor $\alpha$ balances these terms, accounting for the smaller relative magnitude of gradients. This method requires only a small set of calibration data (e.g., 128 sequences) to compute importance masks without any weight updates.

Experimental Results

The researchers evaluated GBLM-Pruner against LLaMA-1 and LLaMA-2 models using the C4 dataset for calibration and WikiText for perplexity measurement. Zero-shot reasoning capabilities were tested via the Eleuther AI LM-Evaluation Harness.

Figure 5: Perplexity comparison of GBLM-Pruner against Magnitude, SparseGPT, and Wanda across LLaMA-1 and LLaMA-2 models at various sparsity levels.

As shown in the results, GBLM-Pruner consistently achieves lower perplexity than its counterparts. For instance, on LLaMA-2-7B at 50% unstructured sparsity, GBLM-Pruner reached a perplexity of 6.86, outperforming Wanda (6.92) and SparseGPT (7.00). In zero-shot tasks, LLaMA-1-7B pruned with GBLM-Pruner achieved 63.07% mean accuracy, a notable improvement over Wanda (61.17%). The method also demonstrated strong generalizability when applied to Vision Transformers (ViT) on ImageNet-1k.

Discussion and Conclusion

GBLM-Pruner demonstrates that gradients are not "dead" in pretrained models; rather, they provide a non-trivial signal that respects the underlying geometric interdependence of parameters. This is evidenced by the emergence of structural patterns even during unstructured pruning. The method is robust to calibration data size and relies on proper normalization to extract clean importance signals.

Future work includes automating the selection of the scaling factor $\alpha$ and exploring task-specific pruning by utilizing gradients from specialized datasets (e.g., medical or code). While SparseGPT maintains a slight advantage in specific 2:4 semi-structured scenarios for smaller models, GBLM-Pruner establishes a new state-of-the-art for general LLM pruning.

Summary updated

BibTeX
@misc{das2023beyond,
  author = {Rocktim Jyoti Das and Liqun Ma and Zhiqiang Shen},
  title = {{Beyond Size: How Gradients Shape Pruning Decisions in Large Language Models}},
  year = {2023},
  eprint = {2311.04902},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.04902},
}
Figure