What SparseGPT does
Pruning sets weights to zero so that a model can be stored or multiplied more cheaply. Zeroing the smallest weights of a large language model, magnitude pruning, works badly: on this page, magnitude pruning to 50 % takes Qwen2.5-0.5B-Instruct's WikiText-2 perplexity from 14.24 to 582.05. SparseGPT prunes a trained model in one shot, without retraining, by treating each linear layer as a small reconstruction problem: choose which weights to remove, and move the weights that stay so that the layer's outputs on real inputs change as little as possible.
The page prunes all 168 linear matrices of Qwen2.5-0.5B-Instruct (seven per decoder layer, 24 layers) to 50 % unstructured sparsity and to the 2:4 pattern, calibrated on 128 C4 windows of 2,048 tokens, and runs Wanda and magnitude pruning on the same inputs for comparison. One matrix is followed in detail: layer 0's k_proj, 128 × 896.
The layer-wise problem and its Hessian
Let be a layer's weights (one row per output) and its calibration inputs, one column per token. SparseGPT looks for a mask and new weights that keep the output close:
The objective is quadratic and splits into one problem per row, and every row has the same Hessian, (the page divides by the number of tokens ). Its diagonal entry, , is twice the statistic Wanda keeps for input channel . The Hessian panel shows a 32-column crop of , columns 48–79 of the 896 inputs, where channel 56's row and column are loudest. A damping term of 1 % of the mean diagonal keeps safely invertible.
Optimal Brain Surgeon
For one row of a layer with Hessian , the Optimal Brain Surgeon (OBS) formula says what removing weight costs when every other weight of the row is allowed to compensate, and what that compensation is:
Pruning greedily by and applying each time is accurate, but every removed weight changes the inverse Hessian the next step needs, and different rows end up with different masks: done exactly, every row needs its own sequence of inverses. That is affordable for small networks and far too slow for a language model's matrices.
Column by column with a Cholesky factor
SparseGPT's trick is to visit the input columns in a fixed order, left to right, and let a pruned weight's error flow only into the columns not yet visited. Then every row needs the same inverses, those of restricted to columns , and all of them can be read off a single upper Cholesky factor of the inverse, . When the sweep reaches column and prunes the weight of a row, it subtracts
from that row's later weights. The Hessian panel's second picture shows the crop of , and the strip under it for all 896 inputs, which picks out the same loud channels as Wanda's input norms.
The Column by column panel replays the sweep over the 32 zoomed columns: the lanes are six rows of weights as the sweep sees them, with earlier columns' errors already pushed in, and the last lane is the selected row's change so far. The mask is chosen block by block: at 50 %, when the sweep enters a block of 128 columns it removes the half of the block with the smallest score over all rows; for 2:4 it removes the two lowest scores in each group of four. Almost every kept weight moves (99.8 % of them at 50 %), which the Mask and updates panel maps over the whole matrix, next to where its mask differs from Wanda's.
What the updates buy
On layer 0's k_proj, the relative output error at 50 % is for SparseGPT against 0.0026 for Wanda and 0.0047 for magnitude pruning; at 2:4 it is 0.0022 against 0.0073 and 0.0242. Pruning runs layer by layer, so each layer is calibrated on inputs that have already passed through the pruned layers below, and the Layer output error chart shows each run on its own inputs. On the very inputs the SparseGPT run gave each of the 168 matrices, Wanda's 50 % mask would leave 2.0× SparseGPT's error on average and magnitude's 5.0×.
The Perplexity chart (WikiText-2 test, 146 windows of 2,048 tokens) shows what that adds up to: dense 14.24; at 50 %, SparseGPT 23.67, Wanda 26.77, magnitude 582.05; at 2:4, SparseGPT 40.66, Wanda 89.91, magnitude 18,521.61. The Next token strip shows where on a held-out paragraph the pruned models become more surprised than the dense one.
What it saves and what it costs
Zeros only pay off with a sparse format and kernels that skip them: at 50 % unstructured, a 16-bit column index per kept bf16 value makes the matrix at least as large as the dense one. The 2:4 pattern stores two values and two 2-bit positions per group of four bf16 weights, 56 % of the bytes, and NVIDIA's sparse tensor cores (Ampere and later) multiply it at up to twice the dense rate; this Mac has none, so the page shows no inference speed.
The pruning itself is cheap: the column sweeps for all 168 matrices took 65.4 s on this Mac's CPU at 50 %, and the whole layer-by-layer run, calibration passes and the page's measurements included, 3.5 minutes.
Where it came from
Optimal Brain Damage (LeCun et al., 1989) ranked weights with the Hessian's diagonal; Optimal Brain Surgeon (Hassibi and Stork, 1993) used its full inverse and added the compensating update. Optimal Brain Compression (Frantar, Singh and Alistarh, 2022) made exact OBS practical layer by layer for networks of moderate size, and GPTQ introduced the fixed column order and the Cholesky factor, for quantization (see the GPTQ tab). SparseGPT (Frantar and Alistarh, 2023) brought them to pruning at scale: the paper prunes OPT-175B and BLOOM-176B in under 4.5 hours and reaches 60 % unstructured sparsity with a negligible increase in perplexity. Wanda (Sun et al., 2023) then showed that a score of times the input norm, with no Hessian inverse and no weight update, comes close; the Wanda tab runs it on the same model and matrix.
Papers
- SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot The method on this page: OBS updates in a fixed column order through one Cholesky factor, with masks chosen per block of columns, for 50 % and 2:4 sparsity.
- Optimal Brain Surgeon and general network pruning The cost of removing one weight under the inverse Hessian, and the compensating update of the remaining weights, that SparseGPT applies column by column.
- Optimal Brain Compression: A Framework for Accurate Post-Training Quantization and Pruning Exact layer-wise OBS for pruning and quantization of smaller networks, the starting point SparseGPT speeds up.
- GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers The same fixed column order, lazy block updates and Cholesky factor of the inverse Hessian, used to round weights to 4 bits instead of zeroing them.
- A Simple and Effective Pruning Approach for Large Language Models Wanda, the comparison on this page: prune by weight magnitude times input norm, per output row, with no weight update.
- Accelerating Sparse Deep Neural Networks NVIDIA's 2:4 structured sparsity: the storage format and the sparse tensor cores that make the 2:4 target worth having.
- Qwen2.5 Technical Report The Qwen2.5 family, including Qwen2.5-0.5B-Instruct, the model pruned here.