Before you use the demo in the newer notebook, say what you expect to change.
Foundation reference
Pruning: Removing Unnecessary Weights
Pruning removes weights from a trained network, often followed by retraining. By pruning and retraining, Han et al. (2015) reduced AlexNet from 61 million to 6.7 million parameters with no loss of ImageNet accuracy.
Study guide
Where to start
Why is a weight's magnitude only a proxy for its importance, and how do second-order criteria such as Optimal Brain Surgeon use curvature to choose better (Hassibi & Stork, 1992)?
How to study this pagePredict · Check · Generalize · Continue
Compare what the notebook demo shows with the key equation here and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
The newer notebook covers the same concept and has an interactive demo.
Why It Matters for Modern Models
- Pruning removes weights from a trained network, often followed by retraining. By pruning and retraining, Han et al. (2015) reduced AlexNet from 61 million to 6.7 million parameters with no loss of ImageNet accuracy.
- SparseGPT prunes the 175- and 176-billion-parameter OPT and BLOOM language models in one shot, without retraining, reaching 60% unstructured sparsity with a negligible increase in perplexity (Frantar & Alistarh, 2023).
- The lottery ticket hypothesis asks whether the small network could have been trained from the start: the winning tickets Frankle & Carbin (2019) found were less than 10% to 20% of the size of the original fully connected and convolutional networks for MNIST and CIFAR-10.
- Speed-ups depend on the pattern of zeros: removing whole neurons or heads shrinks dense matrices, while scattered zeros need sparse kernels or hardware support, such as the 2:4 pattern on NVIDIA Ampere GPUs (Mishra et al., 2021).
Questions to Think About
- Why does removing 90% of the weights at scattered positions often give little speed-up on a GPU, while removing whole neurons, heads or 2:4 blocks does?
- Why does pruning a little at a time, with retraining in between, usually reach higher sparsity than pruning once (Han et al., 2015), and how does SparseGPT manage without retraining?
Interactive Demo
The interactive demo for this concept is in the newer notebook.
Core Math
If you prefer intuition first, try the demo in the newer notebook, then come back for the math.
Magnitude pruning removes the weights with the smallest absolute values, using a mask :
Structured pruning removes whole neurons, channels or attention heads, which leaves smaller dense matrices:
Second-order criteria estimate how much the loss rises when weight is removed, using the Hessian of the loss at a trained minimum. Optimal Brain Damage uses only the diagonal of (LeCun, Denker & Solla, 1989):
When is positive definite, Optimal Brain Surgeon uses its inverse and also adjusts the remaining weights to compensate (Hassibi & Stork, 1992):
Lottery tickets. Frankle & Carbin (2019) found that a dense, randomly initialized network contains sparse subnetworks that, trained in isolation from the same initial weights , reach test accuracy comparable to the full network in a similar number of steps: