Mahir Shahriar Tamim

AI Researcher · Explainable & Responsible AI · Vision, Language & Agentic Systems

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.

Score

A made-up layer with 12 inputs, where input 4 is an outlier about 20× larger (bars above the columns show input size). The error is computed for real on 64 toy inputs, as how far the pruned layer’s outputs move from the original.

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.

MethodKindRetrainingWhat you get
SparseGPTunstructured or 2:4none (layer-wise weight update)50–60% zeros, same shape
Wandaunstructured or 2:4nonesame, simpler to run
LLM-Prunerstructuredshort LoRA fine-tunesmaller dense model
Sheared LLaMAstructuredcontinued pre-trainingsmaller dense model
Minitronstructureddistillationsmaller dense model family

Quick check

Why does Wanda multiply each weight by the size of its input?

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