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

What Wanda is

Pruning sets some of a model's weights to zero. The classic rule, magnitude pruning, removes the weights with the smallest . In large language models that rule fails badly, because a few input channels carry activations far larger than the rest: a small weight on a loud channel can matter more than a large weight on a quiet one. Wanda (pruning by weights and activations) scores each weight by its magnitude times the size of the input it multiplies, compares the scores within each output row, and removes the lowest half. It needs one pass of calibration text and no weight update: the pruned model is used as it is.

This page prunes every linear layer of Qwen2.5-0.5B-Instruct to 50 % unstructured and to 2:4 sparsity, featuring layer 0's k_proj (128 × 896), and compares Wanda with magnitude pruning on the same matrices and the same calibration data.

Calibration

Wanda needs one number per input channel of each layer: the norm of that channel's activations over the calibration tokens,

Here 128 windows of 2,048 tokens of C4 run through the model, so layer 0's k_proj sees 262,144 input vectors of 896 numbers. The Calibration panel draws for every channel against the median (dashed); channels 56, 490 and 674 stand far above it.

The score

Wanda's score for weight , from input to output , is

and in each output row it keeps the half with the highest scores, 448 of 896. Magnitude pruning keeps every above one threshold for the whole matrix, so some rows lose more than half and others less. The Score panel shows one row's and its scores, with each method's kept weights in a lane below, and lists the columns where only Wanda keeps a weight: small weights on loud inputs.

The score has a second-order reading. Optimal Brain Surgeon measures what removing weight costs the layer's output as (up to a factor of one half), with . Keep only the diagonal of , as Optimal Brain Damage did, and , so that cost becomes , the square of Wanda's score. SparseGPT (the SparseGPT tab) uses the full inverse Hessian and also updates the remaining weights; Wanda drops both for speed.

Masks: 50 % and 2:4

50 % unstructured sparsity may zero any half of each row. 2:4 sparsity, chosen in the toolbar, keeps exactly two of every four consecutive weights, the pattern NVIDIA's sparse tensor cores (Ampere and later) can multiply at up to twice the dense rate; both methods then choose the two by their own criterion. The Mask panel draws the whole matrix as each method keeps it, and where they differ. Above each mask, the share of rows that keep each input column: Wanda keeps nearly every weight on the loud channels, however small, which magnitude pruning does not.

The layer's output error on the calibration inputs shows the effect. On the featured k_proj it is 0.0047 for magnitude and 0.0026 for Wanda at 50 %, and 0.0242 against 0.0073 at 2:4. The Layer output error chart repeats this for each kind of matrix in all 24 layers; each layer is pruned from the inputs that the already-pruned layers before it give.

The pruned model

All 168 linear matrices are pruned in one pass. On 146 windows of 2,048 tokens of WikiText-2's test split the dense model's perplexity is 14.24 (longer windows and more text than the quantization tabs' 4,088 tokens, so the numbers do not compare). At 50 % magnitude pruning gives 582.05 and Wanda 26.77; at 2:4 magnitude gives 18,521.61 and Wanda 89.91. The Next token strip shows the difference on a held-out sentence about the Shackleton crater: the dense model continues with Ernest Shackleton, Wanda's 50 % model with fluent but repetitive sentences about the crater, and magnitude pruning's with fragments of quotation marks and letters.

What it saves is counted from the tensors: 178.9 million of the 357.8 million linear weights are zero, 36 % of all 494.0 million parameters, since the tied embedding stays dense. Unstructured zeros only pay with sparse formats and kernels; stored as 2:4, each group of four bf16 weights takes 36 bits instead of 64. Wanda's masks for all 168 matrices took 16.2 s at 50 % on this Mac's CPU.

Where it came from

Optimal Brain Damage (1989) and Optimal Brain Surgeon (1992) pruned with second-order information; Han et al. (2015) popularised magnitude pruning with retraining. LLM.int8() (2022) found the outlier features of large language models, and SparseGPT (2023) pruned them in one shot with weight updates. Wanda (2023) showed that weighting magnitudes by activation norms and comparing within each output row performs competitively with SparseGPT without any weight update.

Papers

  1. A Simple and Effective Pruning Approach for Large Language Models Mingjie Sun, Zhuang Liu, Anna Bair, J. Zico Kolter · ICLR 2024 Wanda: the score |W| times the input norm, compared within each output row, with no weight update.
  2. SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot Elias Frantar, Dan Alistarh · ICML 2023 One-shot pruning with the inverse Hessian and weight updates, the method Wanda simplifies.
  3. Learning both Weights and Connections for Efficient Neural Networks Song Han, Jeff Pool, John Tran, William J. Dally · NeurIPS 2015 Magnitude pruning, the baseline on this page.
  4. LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale Tim Dettmers, Mike Lewis, Younes Belkada, Luke Zettlemoyer · NeurIPS 2022 The emergent large-magnitude features that make magnitude alone a poor score in language models.
  5. Accelerating Sparse Deep Neural Networks Asit Mishra, Jorge Albericio Latorre, Jeff Pool, Darko Stosic et al. · arXiv 2021 The 2:4 pattern and the sparse tensor cores that run it at twice the dense math throughput.
  6. Optimal Brain Damage Yann LeCun, John S. Denker, Sara A. Solla · NeurIPS 1989 Pruning by a diagonal second-order estimate of each weight's cost, the reading of Wanda's score given above.
  7. Qwen2.5 Technical Report An Yang et al. (Qwen Team) · arXiv 2024 The Qwen2.5 models, including the 0.5B instruct model this page prunes.

See also