Part 4 of Pruning and the Lottery Ticket
Pruning large language models
Module 4 · 4 min read
Pruning large language models
TL;DR
- Nobody can afford repeated retraining at 175 billion weights, so LLM pruning is one-shot, with a little calibration text.
- SparseGPT prunes OPT-175B and BLOOM-176B to 50–60% sparsity in under 4.5 hours. Wanda matches it on LLaMA with a simpler |weight| × input score.
- For real speed, structured methods cut whole pieces and then recover with fine-tuning or distillation.
The old recipe breaks
Everything so far relied on retraining. At 175 billion weights one training run costs millions of dollars, and nobody will do ten to find a lottery ticket. So LLM pruning has to be one-shot. You prune the trained model once, without full retraining, and keep the quality, using at most a little calibration data (around a hundred short text samples, only to measure each layer’s inputs).
SparseGPT: remove, then compensate
SparseGPT (Frantar and Alistarh, 2023) takes Optimal Brain Surgeon (part 1), which was too expensive for large networks in 1993, and makes a version fast enough for the largest open models. Layer by layer, it records the inputs on a small batch of real text, then prunes so the layer’s outputs on that text change as little as possible, updating the remaining weights to compensate. No gradients, no training loop.
It pruned OPT-175B and BLOOM-176B to 50–60% unstructured sparsity in one shot, in under 4.5 hours, with only a small increase in perplexity. At 60%, that’s over 100 billion weights you can ignore. It also supports the 2:4 pattern (part 2).
Wanda: look at the inputs too
LLMs have outlier features, a few input dimensions far larger than the rest (documented in the LLM.int8() paper). A small weight on one still moves the output a lot, but magnitude pruning deletes it. Wanda (Sun et al., 2023, Pruning by Weights and activations) scores each weight by |weight| × size of its input (the input’s norm over calibration text), comparing weights within each output row. There are no weight updates or retraining, and on LLaMA models it performed about as well as SparseGPT. Here’s a toy layer with one loud input.
Structured pruning for LLMs
Unstructured and 2:4 sparsity still need special kernels or hardware for speed (part 2). Removing whole attention heads, MLP neurons or layers gives you a genuinely smaller dense model.
- LLM-Pruner (Ma et al., 2023) removes groups of connected structures using gradient information, then recovers with a short, cheap LoRA fine-tune.
- Sheared LLaMA (Xia et al., 2023) prunes LLaMA2-7B to target shapes of 1.3B and 2.7B parameters, then keeps training. The authors report about 3% of the compute of training such models from scratch.
- Minitron (NVIDIA, 2024) prunes Nemotron-4 15B to 8B and 4B by width and depth, then retrains with knowledge distillation from the original, reporting up to 40× fewer training tokens per model than training from scratch.
In the last two, pruning picks the starting point and a fair amount of training (often distillation) restores quality. Pruning alone rarely does the job at high compression. Blunter cuts work too. Several studies dropped some middle layers of large LLMs with modest loss, especially after a short healing fine-tune, and the result is easy to deploy.
| Method | Kind | Retraining | What you get |
|---|---|---|---|
| SparseGPT | unstructured or 2:4 | none (layer-wise weight update) | 50–60% zeros, same shape |
| Wanda | unstructured or 2:4 | none | same, simpler to run |
| LLM-Pruner | structured | short LoRA fine-tune | smaller dense model |
| Sheared LLaMA | structured | continued pre-training | smaller dense model |
| Minitron | structured | distillation | smaller dense model family |
Quick check
Why does Wanda multiply each weight by the size of its input?
A weight’s contribution is weight × input, and a few LLM input features are huge. Judge by the weight alone and you delete small weights on those loud inputs, so the output changes a lot.
Q&A
Can I combine pruning with quantization?
Yes. SparseGPT showed joint sparsity and quantization, and Deep Compression (part 1) combined them back in 2016. In practice quantization usually comes first because it’s more reliable (part 5).
Why can’t I prune an LLM to 90% like a CNN?
At that scale LLMs seem far less redundant per weight, and without retraining there’s no way to recover. Quality usually drops sharply beyond roughly 50–60% unstructured sparsity in one shot.
Papers
- Frantar, Alistarh (2023). SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot.
- Sun et al. (2023). A Simple and Effective Pruning Approach for Large Language Models (Wanda).
- Dettmers et al. (2022). LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale (outlier features).
- Ma et al. (2023). LLM-Pruner.
- Xia et al. (2023). Sheared LLaMA.
- Muralidharan et al. (2024). Compact Language Models via Pruning and Knowledge Distillation (Minitron).