Mahir Shahriar Tamim

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

Part 1 of Pruning and the Lottery Ticket

What pruning is, and the first ideas that worked

Module 1 · 6 min read

What pruning is, and the first ideas that worked

TL;DR

  • Pruning zeroes weights for good, usually the smallest first.
  • Prune gradually and retrain. Han et al. cut AlexNet 9× and VGG-16 13× that way with no ImageNet accuracy loss.
  • Zeroed weights don’t speed anything up. Removing whole neurons or channels does.

Why make a model smaller at all?

Every weight costs memory and a multiplication on every run. Phones and small devices have little memory and a battery to protect. On servers, a model twice as fast serves twice the users for the same GPU bill. And users notice latency, 2 seconds versus 200 milliseconds.

The main tools are pruning (delete weights), quantization (fewer bits per weight) and distillation (train a small model to copy a big one). This series is about pruning, and part 5 comes back to the other two, which in practice matter a lot.

Pruning in one picture

Pruning (the name is from gardening) sets weights to zero for good. A zero adds nothing, so in theory you can skip that work and stop storing it. Dropout only switches neurons off temporarily during training, while pruning is permanent. You can prune single weights (unstructured), neurons or channels (a weight-matrix row or column, or a convolution filter), or bigger pieces like attention heads and whole layers.

Below, circles are neurons and lines are weights (thicker is bigger, red positive, grey negative).

Prune
0%

Toy weights. Weight mode drops the smallest lines, and a neuron left with no inputs or outputs turns pale since it can’t do anything anymore. Neuron mode drops the hidden neurons with the smallest total weight.

Both can leave the same number of weights but run very differently. Weight pruning keeps the 6×6 grid, zeros and all. Neuron pruning turns a layer of 6 into a layer of 4, an ordinary smaller network that any hardware runs faster (more on this in part 2).

Which weights go? Usually the small ones

Magnitude pruning removes the weights closest to zero, since 0.001 barely changes the output and 2.5 matters a lot. Raise the sparsity to remove the smallest first (darker red is larger positive, darker grey larger negative).

100%0% 0%50%100% sparsity →
prune, then retrainprune once, no retraining

Made-up weights and curves showing the usual shape, not measured on a real model. Real curves look similar.

Removing the smallest half changes little, then accuracy falls off a cliff. Where depends on the model and task, and a lot of research is about pushing the cliff right. In large studies, plain magnitude pruning with retraining is surprisingly hard to beat. It can fail badly (part 4), but every new method is measured against it.

Optimal Brain Damage: a smarter score

Optimal Brain Damage (Yann LeCun, John Denker and Sara Solla, 1989) asks how much the loss rises if you remove a weight, because a small weight in a sensitive spot can matter more than a big one. Using the loss curvature (second derivatives), each weight scores roughly curvature × weight², and the lowest go first. Optimal Brain Surgeon (Hassibi and Stork, 1993) also adjusts the remaining weights to compensate, an idea that comes back 30 years later for giant language models (part 4).

Why not always use the smart score? With millions of weights, exact curvature is a millions × millions matrix. Magnitude is free, and for a long time “free and nearly as good” won.

Prune, retrain, repeat

Learning both Weights and Connections for Efficient Neural Networks (Han, Pool, Tran and Dally, 2015) brought pruning back for deep learning:

  1. Train normally.
  2. Prune the small weights.
  3. Retrain the survivors so they take over the work, then repeat, pruning a bit more each time.

Retraining is the gap between the demo’s two curves. AlexNet went from 61 million to 6.7 million parameters (9× fewer) and VGG-16 from 138 million to 10.3 million (13×), with no ImageNet accuracy loss.

Deep Compression (Han, Mao and Dally, 2016) added few-bit storage (a form of quantization) and compression, shrinking AlexNet from 240 MB to 6.9 MB, small enough for a phone app. Pruning was just one of the three tools.

So we can delete 90% of a model?

Often, yes, but with two catches that drive the rest of the series. Zeros are not speed, since a 90%-zero matrix stored the normal way is exactly as slow as a dense one (part 2). And if 10% of the weights are enough, why not train a small model from the start? That question led to the Lottery Ticket Hypothesis (part 3).

Quick check

You prune 80% of a network’s weights by magnitude and accuracy drops a lot. What is the usual next step?

Q&A

Does a pruned weight come back later?

Not in the classic recipe, a mask keeps it at zero through retraining. Sparse training methods like RigL let weights “regrow” (part 6), but that’s a different family.

Should I prune every layer by the same amount?

Usually not. Some layers, often the first and last, are much more sensitive. Either prune each layer by a fixed share or rank all weights together (“global” pruning), which prunes the less sensitive layers harder automatically.

Papers