↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
target row 0
Loading the Wanda and SparseGPT recordings…

Two one-shot pruners

Wanda and SparseGPT both prune a trained language model in one shot, setting half of each linear layer's weights to zero from a few calibration sequences, with no retraining. Both tabs pruned every linear layer of Qwen2.5-0.5B-Instruct to 50 % unstructured and to 2:4 sparsity from the same 128 windows of 2,048 C4 tokens, and both feature layer 0's k_proj (128 × 896), whose inputs are identical in every run because nothing before it is pruned. This page puts their recordings on the same axes.

Both simplify one older idea, Optimal Brain Surgeon, in opposite directions. To separate their two differences, the mask each picks and the update only SparseGPT makes, the page adds a third model recorded for this tab: Wanda's mask with SparseGPT's update.

Optimal Brain Surgeon

Pruning a linear layer should change its outputs on the calibration inputs as little as possible. The error splits into one quadratic per output row, and every row has the same Hessian

(896 × 896 here, with the number of calibration sequences). Optimal Brain Surgeon (OBS) asks what dropping one weight costs when the other weights of its row may then move to make up for it. Up to a factor of one half, the cost and the move that achieves it are

Doing this exactly, weight by weight, means a new inverse Hessian after every removal and a different sequence of them for every row: fine for the small networks OBS was made for, far too slow for a language model.

Wanda keeps the diagonal

Optimal Brain Damage, OBS's predecessor, assumed is diagonal. Then and the cost becomes , the square of Wanda's score up to a constant, since :

Wanda drops the move as well: it compares scores only within each output row, keeps the top half, and leaves the kept weights as they were. One pass of statistics and a sort per row is all it costs. In the Input weighting panel Wanda's strip is , the size of each input channel alone, dominated by the loud channels 56, 490 and 674.

SparseGPT keeps the inverse

SparseGPT keeps the full inverse but fixes an order: it sweeps the input columns from left to right, and a dropped weight's error may only move the columns not yet visited. Then every row needs the same inverses, and all of them can be read off one upper Cholesky factor of , with 1 % of the mean diagonal. Its score is , and

over the inputs after (with on the diagonal): the part of input that the later inputs cannot reproduce, and so cannot take over once 's weight is gone. The Input weighting panel draws on the same scale as Wanda's strip. Squared, it is a median 61 % of , but only 8 %, 19 % and 6 % on the three loud channels: the later channels follow them closely enough to absorb much of their loss.

SparseGPT also chooses its mask differently. At 50 % it drops the lowest half of the scores of a whole 128-column block at once, across all rows, so on this matrix rows keep between 65 and 802 of their 896 weights; at 2:4 it picks two of every four as the sweep reaches each group, from weights the sweep has already moved.

The same matrix, two masks

The Two scores scatter puts both scores of all 114,688 weights on one log scale, in the same units, the output error of dropping that weight alone; on the dashed line the two agree. At 50 %, 82 % of the weights fall below it, because SparseGPT counts only what the later inputs cannot replace and scores weights its sweep has already moved. Even so the masks mostly agree: in the Masks and Overlap panels both keep 40.1 % of the weights and both prune 40.1 % at 50 %, and they agree on 89 % of the weights at 2:4. Kept weights zooms into one row: Wanda's kept weights are the dense ones, while SparseGPT has moved 99.8 % of its kept weights to make up for the ones it dropped.

Mask or update?

The Mask or update? panel separates the two differences on the featured matrix, replaying SparseGPT's sweep from its recorded Hessian with Wanda's mask held fixed, and SparseGPT's mask without its update. At 50 % the update cuts the error of Wanda's mask from 0.0026 to 0.0011, but SparseGPT's own mask still ends 3.4 times lower, at . At 2:4 the update does nearly all the work: Wanda's mask with it reaches 0.0026, within 16 % of SparseGPT's 0.0022, while SparseGPT's mask without its update is worse than Wanda's, 0.0079 against 0.0073.

The whole-model run repeats this on all 168 matrices, each pruned from the inputs the already pruned layers give. The update lowers the error of Wanda's mask on every one of them. In the Layer output error chart, each run on its own inputs, Wanda's error averages 1.96 times SparseGPT's at 50 % and 1.37 times with the update; at 2:4 it is 1.78 times, and 1.15 with the update. Same inputs puts all three on the inputs of the run recorded for this page. The Perplexity chart shows the same split: at 50 % the update takes Wanda from 26.77 to 25.36, less than half of the way to SparseGPT's 23.67, while at 2:4 it takes Wanda from 89.91 to 48.55, most of the way to 40.66.

When the cheaper score is enough

Wanda's masks for all 168 matrices took 2.5 s of CPU in SparseGPT's 50 % run, against SparseGPT's own 65.4 s (10.2 s and 138.6 s at 2:4). What that buys depends on the pattern. At 50 % Wanda's perplexity is 13 % above SparseGPT's although its per-matrix error is about twice as large: the mask has room to avoid the weights that matter. On LLaMA the Wanda paper finds the two within a few hundredths of a point at 50 %, with its score up to 300 times faster to compute.

2:4 forces two of every four weights out whatever their score, and the error they leave only goes somewhere if the kept weights move. There Wanda's perplexity is more than twice SparseGPT's, and the update alone recovers 84 % of that gap (45 % at 50 %). On LLaMA-7B the Wanda paper likewise found the update did not help its 50 % mask but did at 2:4 (11.53 to 10.89). Solving that update cheaply for a fixed mask is the subject of later work on weight updates for pruned language models.

Papers

  1. SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot Elias Frantar, Dan Alistarh · ICML 2023 OBS made affordable for language models: a fixed column order, one Cholesky factor of the inverse Hessian, and the update.
  2. A Simple and Effective Pruning Approach for Large Language Models Mingjie Sun, Zhuang Liu, Anna Bair, J. Zico Kolter · ICLR 2024 Wanda: the diagonal of the same cost, compared within each output row, with no update; its analysis adds SparseGPT's update to its mask.
  3. Optimal Brain Surgeon and general network pruning Babak Hassibi, David G. Stork, Gregory J. Wolff · IEEE International Conference on Neural Networks 1993 The cost of dropping a weight and the move of the others that compensates, from the inverse Hessian.
  4. Optimal Brain Damage Yann LeCun, John S. Denker, Sara A. Solla · NeurIPS 1989 The diagonal approximation that turns the cost into Wanda's score.
  5. Optimal Brain Compression: A Framework for Accurate Post-Training Quantization and Pruning Elias Frantar, Sidak Pal Singh, Dan Alistarh · NeurIPS 2022 Exact layer-wise OBS for pruning and quantization, the step before SparseGPT's approximation.
  6. Fast and Effective Weight Update for Pruned Large Language Models Vladimír Boža · arXiv 2024 Solving the update for a fixed mask, such as Wanda's, on its own.
  7. Qwen2.5 Technical Report An Yang et al. (Qwen Team) · arXiv 2024 The Qwen2.5 models, including the 0.5B instruct model both tabs prune.

See also