The LLM Surgeon

Tycho F. A. van der Ouderaa, Markus Nagel, Mart Van Baalen, Tijmen Blankevoort

TL;DR

The LLM Surgeon is a novel framework that leverages advanced curvature approximations to "surgically" remove unnecessary parameters from Large Language Models (LLMs). By accounting for complex correlations between weights, it achieves state-of-the-art results in unstructured pruning and makes structured pruning—removing entire rows and columns—practically viable for models like Llama-2.

The Challenge of Deploying Giant LLMs

As LLMs scale to hundreds of billions of parameters, deploying them on consumer hardware or within cost-sensitive cloud environments becomes increasingly difficult. Pruning, the process of removing redundant weights, is a classic solution, but applying it effectively to LLMs is notoriously challenging.

Existing methods often fall into two traps:

  1. Oversimplification: Techniques like "magnitude pruning" simply cut the smallest weights, or focus only on local reconstruction error, ignoring how pruning a specific weight affects the overall task loss.
  2. Computational Explosions: Classic "optimal" pruning methods require calculating the Hessian (a matrix of second-order derivatives), which is mathematically intractable for models with billions of parameters.

Furthermore, most LLM pruning research focuses on unstructured sparsity (randomly scattered zeros), which requires specialized hardware to realize any actual speedup. Structured pruning, which removes entire rows or columns, provides immediate speedups on standard hardware but traditionally destroys model performance.

Methods: Surgical Precision via Curvature Approximations

The authors introduce a framework that scales up Kronecker-factored curvature approximations (KFAC) to the LLM regime.

Loss landscape and likelihood density views illustrating the theoretical foundation of the LLM Surgeon's approximations.

Key innovations include:

  • Kronecker-factored Fisher Information: Instead of computing a massive, impossible Hessian, the framework approximates the loss landscape using the "empirical Fisher" matrix, broken down into smaller, manageable Kronecker products. This captures how weights interact without the prohibitive memory overhead.
  • Correlated Weight Updates: Unlike previous methods that update each remaining weight independently, LLM Surgeon calculates joint updates. When a group of weights is removed, the remaining weights are adjusted together to compensate for the collective loss.
  • Dynamic Global Thresholding: Rather than pruning every layer by a fixed percentage, the "Surgeon" uses a global cost threshold. This allows the algorithm to aggressively prune "cheap" layers while leaving "sensitive" layers nearly intact.
  • Multi-shot Pruning: To maintain the accuracy of mathematical approximations, the model is pruned in multiple small steps (shots) rather than one giant cut, re-estimating the curvature at each stage.

Datasets and Evaluation

The researchers evaluated their method primarily on the Wikitext-2 dataset, a standard benchmark for measuring the "perplexity" (predictive fluency) of language models. They tested the method across the OPT model family (125M to 6.7B parameters) and Llama-2-7B.

Key Insights

  • Gradients are Essential: Successful pruning requires looking at gradients, not just weight magnitudes. By using the Fisher Information Matrix, the "Surgeon" understands which weights actually contribute to the final objective.
  • Structured Pruning is Viable: By deriving specific update rules for entire rows and columns, the authors demonstrate that weight matrices can be physically shrunk by 20-30% with minimal performance impact.
  • The "Interpolation" Sweet Spot: LLM Surgeon allows developers to create models of "in-between" sizes. If a 7B model is too large but a 1.3B model is too weak, the 7B model can be pruned to exactly 5B parameters to fit specific VRAM constraints.
  • Varying Layer Sensitivity: Dynamic allocation reveals that the first layers of a model are often the most redundant, while middle layers are more sensitive—a nuance missed by fixed-rate pruning methods.

Key Results

  • State-of-the-Art Unstructured Pruning: LLM Surgeon consistently outperforms popular baselines like SparseGPT and K-OBD across almost all target sizes and model architectures.
Test set perplexity across different model sizes, showing LLM Surgeon outperforming SparseGPT.
  • Structured Pruning Success: On Llama-2-7B, the method achieved 20-30% structured pruning with negligible loss in perplexity. This is a significant milestone, as structured pruning directly translates to faster inference and lower memory usage on standard GPUs.
  • Efficiency: Despite the sophisticated mathematics, the method remains computationally efficient enough to run on standard research hardware, avoiding the need for massive clusters to perform the compression.

Limitations and Future Work

  • The 50% Wall: While excellent at 20-30% compression, performance drops significantly at 50% structured pruning. At that level, it is often better to train a smaller model from scratch.
  • LoRA Overfitting: Experiments with LoRA (Low-Rank Adaptation) to "patch up" the model between pruning shots helped small models (125M) but occasionally led to overfitting on larger models when using limited calibration data.
  • Data Dependence: Like all post-training pruning methods, result quality depends on the calibration data used to estimate curvature. Future work could explore how different data distributions affect this "surgical" precision.

Summary updated

BibTeX
@inproceedings{ouderaa2024llm,
  author = {Tycho F. A. van der Ouderaa and Markus Nagel and Mart Van Baalen and Tijmen Blankevoort},
  title = {{The LLM Surgeon}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=DYIIRgwg2i},
}
Figure