Majid Al-RaimiTrain, prune, fine-tune: what pruning achieves

COE 592Lecture 4.1Part 02

Train, prune, fine-tune: what pruning achieves

The Han et al. pipeline of training connectivity, pruning and retraining, how iterative pruning pushes the pruning ratio past 90 percent without accuracy loss, the resulting parameter and MAC reductions, and hardware support for sparsity.

Concepts
6
Slides
7-13
Reading
36 min
Understood
0/6 concepts

Why this part matters

Part 01 ended with the reason to prune: a 32-bit DRAM access costs about 640 pJ, roughly 200 times a multiply, so a model that fits in on-chip memory wins on energy before it wins on anything else. This part is where the lecture proves that pruning actually delivers: AlexNet loses 9x of its parameters and VGG-16 loses 12x with no accuracy loss at all.

The proof comes as one chart built up over four slides, a five-row reduction table, a set of image captions and a slide of hardware. Along the way it exposes the two traps that catch most first attempts: pruning without retraining, which throws away several percent of accuracy for nothing, and assuming that fewer parameters means faster inference, which is only true when the hardware knows how to skip zeros. The pipeline chart and the reduction table are classic exam material, and the hardware slide is the bridge to the granularity discussion in Part 03.

By the end you can

  1. Explain the train, prune, retrain pipeline and why retraining is the step the paper calls critical.
  2. Read accuracy loss and reduction factor off the pruning-ratio chart for one-shot, retrained and iterative pruning.
  3. Explain from layer tables why parameter reduction and MAC reduction differ across AlexNet, VGG-16, GoogleNet, ResNet-50 and SqueezeNet.
  4. State what hardware needs, a 2:4 pattern or a sparse engine, before sparsity turns into speed.

Take AlexNet as Han, Pool, Tran and Dally trained it for their NeurIPS 2015 paper: 57.2% top-1 and 80.3% top-5 on ImageNet. Its first fully connected layer alone holds 38 million weights, and if you histogram them you get a narrow bell centered on zero, almost all of it inside [-0.015, 0.015] by the paper's own account. Now pick a threshold that removes the smallest half of every layer. Nothing happens to accuracy. Remove three quarters, and top-5 accuracy falls by about 2.2%. Remove four fifths, and it falls by about 4%. That single experiment is the whole of slides 7 and 8.

The rule behind it is a two-step recipe. Step one is ordinary training, but Han reads it differently: the dense network is not trained to learn final weights, it is trained to learn which connections are important. Step two removes every weight whose magnitude falls below a threshold, which the paper sets as a quality parameter times the standard deviation of that layer's weights. A dense layer becomes a sparse layer. This is Pruning at its simplest, Synapse pruning in the vocabulary of Part 01, and it is the plainest form of Magnitude-based pruning: importance is |w| and nothing else. Once connections are gone, some neurons are left with no surviving input or no surviving output. Those neurons contribute nothing and are removed too, so Neuron pruning falls out of synapse pruning for free.

The bell of a trained layer. On hover the weights inside ±t collapse from the center outward, leaving the gap that is the visual signature of magnitude pruning. The bell is a model with sigma = 0.03 drawn on the slide inset's ±0.1 axis, not the paper's fc6 histogram.

The right-hand inset of slide 8 shows exactly that gap: the same bell with its center cut out, a hole of width 2t around zero, and nothing else changed. The paper's discussion of its Figure 7 describes the distribution as "centered around zero with tails dropping off quickly" before pruning, then "the center of the distribution" removed. The weights that survive have not moved. They will move in the next concept, and that movement is what retraining does.

Reading the prune-only curve

The chart on slide 8 plots top-5 accuracy loss against the Pruning ratio, the fraction of parameters pruned away, from 40% to 100% on the x axis and from +0.5% to -4.5% on the y axis. The dashed purple curve is what happens with no retraining. It sits at zero up to 50%, which the paper calls a "free lunch of reducing 2x the connections without losing accuracy even without retraining". It reaches about -1% at 67%, about -2.2% at 75%, about -4% at 80%, and leaves the chart just past 82%. Without retraining, the paper says, accuracy "begins dropping much sooner", once only a third of the connections remain.

The x axis counts what is removed, so you have to translate it into a reduction factor before you can compare with a table that reports "9x". Keeping a fraction 1 - r of the weights makes the model 1 / (1 - r) times smaller.

k=11rr=11kk = \frac{1}{1 - r} \qquad r = 1 - \frac{1}{k}
Reduction factor k from pruning ratio r, and back

Anchor points to memorize

50% pruned
2x
67% pruned
3x
75% pruned
4x
80% pruned
5x
87.5% pruned
8x
88.9% pruned
9x
90% pruned
10x

Where the threshold comes from

Because the criterion is magnitude, the threshold and the pruning ratio are two views of the same cut. If the weights of a layer are roughly Gaussian with standard deviation sigma, removing a fraction r means removing everything inside ±t where the Gaussian mass inside ±t equals r. That is an inverse normal lookup: t = sigma × z with z = 0.674 for 50%, z = 1.282 for 80% and z = 1.645 for 90%.

Worked example

Threshold for a Gaussian layer with sigma = 0.03

  1. Half the weights

    t = 0.03 × 0.674 = 0.020. Everything with |w| < 0.020 goes. The model is 2x smaller and, on AlexNet, loses nothing.
  2. Four fifths

    t = 0.03 × 1.282 = 0.038. This is the cut in the visual above: 5x smaller, about -4% top-5 without retraining.
  3. Nine tenths

    t = 0.03 × 1.645 = 0.049. 10x smaller. Prune-only is off the chart here, one-shot retraining loses about 1.7%, and only the iterative recipe of the third concept holds zero loss.
  4. The threshold scales with sigma, the ratio does not

    Han sets t per layer as a quality parameter times that layer's standard deviation, so a layer with wider weights gets a proportionally wider cut and the same share removed.

Recall

What does the x axis of the pruning chart measure, and how do you turn 80 percent into a reduction factor?

The share of parameters pruned away. Keeping 1 - 0.8 = 0.2 of the weights makes the model 1 / 0.2 = 5x smaller.

Return to the AlexNet that lost 4% at 80% pruned. Keep the mask fixed, so the removed weights stay at zero, and train the survivors again with a learning rate one hundredth of the original. The loss comes back to 0.0%. That run took 173 hours on a Titan X against 75 hours for the original training, which is why the paper says pruning is "not used when iteratively prototyping the model, but rather used for model reduction when the model is ready for deployment".

This is step three of the pipeline, and the paper is blunt about its status: retraining "learns the final weights for the remaining sparse connections. This step is critical. If the pruned network is used without retraining, accuracy is significantly impacted." The lecture calls it Fine-tuning. The green curve on slide 9 shows what it buys. It stays at zero, or a hair above, all the way to 80%, then bends: about -0.25% at 84%, about -0.9% at 88%, about -1.7% at 90%, about -4% at 93%. The paper summarizes the same curve as "with retraining we are able to reduce connections by 9x".

The prune-only curve is the dashed line. On hover the retrained curve draws itself along the zero line and the accuracy that retraining gives back is shaded between them.

Two of the green points sit slightly above zero. The authors do not treat that as noise: "We believe this accuracy improvement is due to pruning finding the right capacity of the network and hence reducing overfitting." In other words, Pruning behaves like a regularizer, and an over-parameterized network can lose most of its weights and generalize a little better for it.

What retraining does to the weights

The third inset on slide 9 is the most informative picture in this part. After pruning, the histogram was a bell with a hole. After retraining it is two smooth lobes, one on each side of zero, and the whole distribution is wider. The paper's text on Figure 7 states the numbers: the original weights lived inside [-0.015, 0.015]; after retraining "the parameters form a bimodal distribution and become more spread across the x-axis, between [-0.025, 0.025]". The survivors have grown in magnitude to take over the work of the connections that were removed. Nothing has been restored; the mask still holds the pruned weights at zero.

Three rules the paper gives for retraining

  • Keep the surviving weights; do not reinitialize them. The paper argues that networks contain "fragile co-adapted features" that gradient descent finds when the network is first trained but cannot find again from scratch on a sparse layout.
  • Shrink dropout. Pruning has already removed capacity, so the retraining dropout D_r is scaled from the original D_o by the square root of the fraction of connections kept.
  • Choose the regularizer for the stage. L1 pushes more weights toward zero and gives better accuracy straight after pruning, but L2 gives better accuracy once the survivors are retrained, so the paper uses L2 for the curves on these slides.
Dr=DoCirCioD_r = D_o \sqrt{\frac{C_{ir}}{C_{io}}}
Dropout for retraining (Han et al. 2015, equation 2): C_io connections before, C_ir after

Worked example

Dropout for a fully connected layer kept at 9 percent

  1. Fraction of connections kept

    AlexNet's fc6 keeps 9% of its weights, so C_ir / C_io = 0.09.
  2. Scale the original dropout

    With D_o = 0.5: D_r = 0.5 × sqrt(0.09) = 0.5 × 0.3 = 0.15.
  3. Result

    Retrain with dropout 0.15, not 0.5. A sparse layer already regularizes itself.

One more observation from the paper's sensitivity study (Figure 6) matters for your own experiments: convolutional layers are more sensitive to pruning than fully connected ones, and the first convolutional layer is the most sensitive of all, because its input has only three channels and there is little redundancy to remove. That is why the per-layer keep rates in the next concepts are so uneven.

Quick check

In Han's three-step pipeline, which step does the paper call critical because skipping it makes accuracy drop significantly?

Recall

State the three steps of Han's pipeline and say which one the paper calls critical.

Train the dense network to learn connectivity, prune the connections below a magnitude threshold, retrain the survivors. Retraining is the critical step: without it accuracy drops significantly, about 4% top-5 at 80% pruned.

Iterate: prune a little, retrain, repeat

Start from the retrained network at 80% pruned, the last green point still on the zero line, a 5x model with no loss. Now prune it again, using the retrained magnitudes, and fine-tune again. The paper describes what happens: "The leftmost dot on this curve corresponds to the point on the green line at 80% (5x pruning) pruned to 8x. There's no accuracy loss at 9x. Not until 10x does the accuracy begin to drop sharply." The red curve on slide 10 is that experiment: flat through 90%, about -0.5% at 92%, -1% at 93%, -2% at 94%, and about -4% between 95% and 96%.

This is Iterative pruning, and the paper states the rule and the payoff in one breath: "Pruning followed by a retraining is one iteration, after many such iterations the minimum number connections could be found. Without loss of accuracy, this method can boost pruning rate from 5x to 9x on AlexNet compared with single-step aggressive pruning." Each iteration is a greedy search. VGG-16 used five rounds; ResNet-50 in Han's thesis used three. The left side of slide 10 draws the loop: train connectivity, prune connections, train weights, and an arrow from train weights back to prune.

Train connectivity
dense network

Learn which connections matter.

magnitudes
Prune connections
below threshold

Cut a fraction of the survivors.

mask fixed
Train weights
fine-tuning

Survivors redistribute, then loop back to prune.

The prune and retrain loop. The return arrow is what lifts AlexNet from 5x to 9x.

Why several small cuts beat one big cut

A single cut to 90% judges every weight by the magnitude it had in the dense network. But the previous concept showed that retraining changes those magnitudes: the survivors grow and the distribution becomes bimodal. Weights that looked expendable in the dense network may become load-bearing after the first round, and weights that looked important may shrink once their neighbours take over. Iterating lets each cut use the freshest evidence. Frankle and Carbin reach the same conclusion in a different setting: iterative pruning over n rounds, each removing p^(1/n) of what remains, "finds winning tickets that match the accuracy of the original network at smaller sizes than does one-shot pruning". The price, which they also state, is that repeated retraining is expensive.

Worked example

Compounding a pruning schedule

  1. Equal halves

    Three rounds that each remove half of the survivors leave 0.5 × 0.5 × 0.5 = 12.5%, an 8x model. Four rounds leave 6.25%, which is 16x.
  2. Hitting a target in equal rounds

    To reach 90% overall in three equal rounds, each round must keep 0.1^(1/3) = 0.464 of what remains, so it removes 53.6% of the current survivors.
  3. Han's actual path

    80% in one round (5x), then re-pruned to 8x, then 9x, all at zero loss. The drop only starts past 10x.
Pruning ratioPrune onlyPrune + fine-tuneIterative
80% (5x)about -4%0%starting point: the retrained 80% model
90% (10x)off the chartabout -1.7%about 0%
93% (14x)off the chartabout -4%about -1%
Top-5 accuracy loss for the three recipes, read from slides 8 to 10
SimulatorPruning curve explorer: prune, fine-tune, iterate
80% pruned away
+0.5%0.0%-1.0%-2.0%-3.0%-4.0%-4.5%40%50%60%70%80%90%100%pruning ratio (parameters pruned away), AlexNet top-5 accuracy loss80% pruned: -4.05%
-0.10-0.050.000.050.10after the cut: the bell with its center removedgrey: dense reference, dashed: ±t = ±0.038
Top-5 loss-4.05%read off the active curve
Reduction5.0xsmaller1 / (1 - ratio)
AlexNet left12.2M weights61 M × (1 - ratio)
Threshold t0.038sigma = 0.03, Gaussian weights

Slide to 80% and switch recipes: prune-only sits near -4%, both retrained recipes sit at zero. Slide to 90%: only the iterative loop is still at zero. The red curve begins at the 80% retrained model, as on slide 10, so below that it has no data. The histogram is a model, not the paper's data: a zero-mean Gaussian with sigma = 0.03, cut at the threshold that removes the chosen share, then redrawn as two lobes once retraining lets the survivors grow.

Quick check

Reading slide 10, roughly how far can iterative prune-and-retrain go before top-5 loss exceeds half a percent?

Recall

At 80 percent pruned, what top-5 loss do prune-only and prune-plus-retrain give, where does the iterative curve begin, and what reduction factor is that?

About -4% and 0%. The iterative curve has no separate value there: its leftmost dot is the retrained 80% model pruned further, so it starts from that 0% point. Keeping 20% of the weights is a 5x reduction factor.

Recall

Why did iterative pruning lift AlexNet from 5x to 9x with no loss?

After each retraining the surviving weights redistribute (bimodal, wider), so the next magnitude cut removes weights judged small under the new assignment. A greedy search over several rounds finds a smaller network than one aggressive cut.

Look at AlexNet layer by layer, as the paper's Table 4 does. Its first fully connected layer, fc6, holds 38 M weights but costs only 75 M FLOPs, because each weight is used once per image. Its second convolutional layer, conv2, holds 307 K weights but costs 448 M FLOPs, because each weight is reused at every spatial position. Add the layers up and the network splits into two worlds: the three FC layers hold 58.6 M of the 61 M parameters (96.2%, which the paper rounds to 59 M) but only about 117 M of 1.45 G FLOPs (8%), while the five conv layers hold 2.3 M parameters (3.8%) but 1.33 G FLOPs (92%).

That split explains the table on slide 11 before you read it. Pruning fc6 to 9% deletes 34.6 M parameters but only 68 M FLOPs by weight count (73 M once zero activations are skipped as well, which is how Han counts). Pruning conv2 to 38% deletes only 190 K parameters but 278 M FLOPs by weight count (300 M by Han's count). Parameter reduction is a story about FC layers; MAC reduction is a story about conv layers, and the two are pruned to very different depths.

AlexNet's parameters live in FC layers, its MACs live in conv layers. On hover both bars drain to what pruning leaves: 11 percent of the parameters but 30 percent of the MACs.
NetworkParameters beforeAfterParameter reductionMAC reductionFC share of parameters
AlexNet61 M6.7 M9x3x96.2%
VGG-16138 M10.3 M12x5x89.9%
GoogleNet7 M2.0 M3.5x5xabout 14%
ResNet-5026 M7.47 M3.4x6.3xabout 8%
SqueezeNet1 M0.38 M3.2x3.5x0%
Slide 11 with one extra column: how much of each network's parameter count sits in fully connected layers

Why the over-parameterized nets compress more

AlexNet and VGG-16 get 9x and 12x; GoogleNet, ResNet-50 and SqueezeNet get about 3.2x to 3.5x. The extra column is the reason. VGG-16's fc6 alone holds 103 M of its 138 M weights, and the paper prunes fc6 and fc7 to 4% of their size while conv layers keep 22% to 58%. GoogleNet has one FC layer of about 1 M in 7 M, ResNet-50 one of about 2 M in 25.5 M, and SqueezeNet has none at all, ending in global average pooling. Han's thesis says it directly: the pruning ratio of GoogleNet is smaller than AlexNet and VGG-16 "because convolutional layers dominate GoogleNet, and convolutional layers are much more efficient than fully connected layers". The three conv-dominated networks land in the same place, about 30% of parameters nonzero (GoogleNet 29%, SqueezeNet 31%, ResNet 29%), which is the 3.4x in the table. Their FC rows, where Neuron pruning would delete whole rows of a weight matrix, are too small to matter.

Why MAC reduction is not parameter reduction

Two mechanisms separate the two columns. The first is the split above: parameters concentrate in FC layers, which are pruned hardest, and MACs concentrate in conv layers, which are pruned least. That is how AlexNet gets 9x on parameters but 3x on MACs, and VGG-16 12x against 5x. The second is how Han counts. A multiply-accumulate is only counted as saved when it is really skipped, and it is skipped when either the weight or the input activation is zero. ReLU produces plenty of zero activations, so the FLOP column in Table 4 is roughly the weight density times the density of the layer's input activations.

FLOP%Weight%×Act%in\text{FLOP\%} \approx \text{Weight\%} \times \text{Act\%}_{\text{in}}
Han's remaining-compute rule: a MAC survives only if both operands are nonzero

Worked example

Checking the rule against AlexNet's Table 4

  1. conv2

    Weights kept 38%, input activations (the output of conv1) 88% nonzero: 0.38 × 0.88 = 33%. The table says 33%.
  2. fc6

    Weights kept 9%, input activations (the output of conv5) 34% nonzero: 0.09 × 0.34 = 3%. The table says 3%.
  3. ResNet-50, whole network, run backwards

    The thesis reports 29% of weights kept (3.4x) and about 16% of FLOPs remaining (6.25x, rounded to 6.3x on the slide). The rule then implies an average input activation density near 0.16 / 0.29 = 55%, which is a plausible ReLU figure. This step derives the density from the two reported numbers rather than checking a third.
  4. Compute can fall faster than parameters

    For conv-heavy networks the activation zeros from ReLU are a second source of Sparsity, which is why ResNet-50 and GoogleNet cut MACs by more than they cut parameters.

Even where MACs barely fall, the parameter count is worth cutting. A 6.7 M parameter AlexNet fits in on-chip SRAM, and the paper's point from Part 01 stands: at 640 pJ per DRAM access, the energy of fetching weights dominates the energy of multiplying them.

Quick check

AlexNet's parameters fall 9x after pruning but its MACs fall only 3x. Why?

Recall

AlexNet: 9x fewer parameters but only 3x fewer MACs. Give both reasons.

Parameters are 96.2% in FC layers, which are pruned hardest, while 92% of MACs are in conv layers, which are pruned less. And Han's FLOP count only removes a MAC when both the weight and the input activation are nonzero, so activation sparsity shifts the MAC column independently.

Everything so far was an image classifier with a huge fully connected tail. NeuralTalk, Karpathy and Fei-Fei's image captioner, is a different animal: a CNN feature extractor feeding an LSTM that writes a sentence one word at a time. Han froze the CNN, pruned every LSTM weight matrix except the word-embedding table to 10% nonzeros, retrained with the original weight decay and batch size, and measured BLEU-1 to BLEU-4 on Flickr-8K. The thesis reports: "Not until pruning away 90% of the parameters does the BLEU score begin to drop sharply."

The recipe did not change. Train, cut the small weights, retrain the survivors: the same three steps, the same knee near 90%, and the same dependence on Fine-tuning, which the thesis says "plays a very important role" when it compares the retrained curve with the one that skips retraining. Slide 12 shows the qualitative check that a BLEU number cannot: the captions themselves.

ImageBaselinePrunedPruning ratioVerdict
Basketballa basketball player in a white uniform is playing with a balla basketball player in a white uniform is playing with a basketball90%Same meaning, more specific noun
Doga brown dog is running through a grassy fielda brown dog is running through a grassy area90%Synonym
Surfera man is riding a surfboard on a wavea man in a wetsuit is riding a wave on a beach90%Different but valid description
Soccera soccer player in red is running in the fielda man in a red shirt and black and white black shirt is running through a field95%Drift: repeated phrase, lost the word soccer
Captions from the baseline LSTM and the pruned LSTM (slide 12)

At 90% the pruned model "sometimes produces the same caption, sometimes produces a different word to describe the same thing", and sometimes describes the scene differently but still correctly. Replacing "ball" with "basketball" is arguably an improvement. The fourth image is the warning. At 95% pruned, a 20x model, the sentence starts to stutter: "a red shirt and black and white black shirt" repeats a phrase and loses the word "soccer". That is what crossing the knee of the Pruning ratio curve looks like in a language model: not silence, but drift.

Recall

Name a non-CNN case where the prune-and-retrain recipe worked, and give its pruning ratio.

The NeuralTalk LSTM captioner: all LSTM weights except the word embedding pruned to 10% density (90% pruned), with BLEU flat until then and captions nearly identical. At 95% the captions start to repeat phrases.

Take fc6 of AlexNet pruned to 9% and run it with an ordinary dense matrix kernel on a GPU. The kernel does not know the zeros are zeros. It multiplies all 38 M weight-activation pairs, 34.6 M of them by zero, and finishes in exactly the time the dense layer took. Nine times fewer parameters, zero speedup. The reduction table of two concepts ago counted what could be skipped; it did not promise that anything would be. Skipping needs either a custom engine that understands sparse formats or a sparsity pattern that commodity hardware is built for. Slide 13 shows both.

The commodity route: NVIDIA A100 and 2:4

The Ampere whitepaper defines 2:4 sparsity as a structure "that allows two non-zero values in every four-entry vector". Every group of four contiguous weights along a row keeps at most two, so the matrix is exactly half zeros, stored as the nonzero values plus a 2-bit index per survivor. That compression cuts storage and bandwidth "by almost 2x", and the Sparse Tensor Core has a matrix multiply instruction that reads the indices, gathers only the matching activations, and finishes a tile in N/2 cycles instead of N: "a 2x speedup". This is the special case N = 2, M = 4 of N:M sparsity.

A 4 by 8 dense block. On hover two weights in every group of four fade, the survivors slide left into a packed 4 by 4 block, and the 2-bit index strip that tells the Tensor Core where each survivor came from appears below.

How does a model get into that pattern? The whitepaper's recipe is the pipeline of this part with one constraint added: the network is "first trained using dense weights, then fine-grained structured pruning is applied, and finally the remaining non-zero weights are fine-tuned". NVIDIA's developer blog reports BERT-Large keeping its SQuAD F1 of 91.9 dense and sparse. The magnitude criterion, the mask and the retraining are all Han's; the only change is that the two smallest of every four are cut instead of the smallest 50% of the layer.

What the A100 asks for and what it delivers

Pattern required
2 nonzeros in every 4 contiguous weights (50% sparsity)
Storage and bandwidth
almost 2x smaller: half the values plus 2-bit indices
Peak Tensor Core throughput
up to 2x: Sparse MMA finishes a tile in N/2 cycles
Measured, BERT-Large GEMM layers (cuSPARSELt on A100)
1.3x (projection), 1.4x (QKV, FC1), 1.6x (FC2)
Slide's summary
1.5x measured BERT speedup

The gap between 2x and 1.5x is the gap between a peak instruction rate and a whole layer. The whitepaper says "up to 2x". NVIDIA's cuSPARSELt measurements on BERT-Large GEMM layers on an A100 give 1.3x for the projection, 1.4x for QKV and FC1, and 1.6x for FC2 over dense cuBLAS, because memory traffic for activations, the non-GEMM parts of the layer and kernel launch costs do not halve. The slide's "1.5X measured BERT speedup" is Han's summary of those numbers. Treat 1.5x as the realistic middle and 2x as the ceiling.

The custom route: engines built to skip zeros

Before 2:4 existed, the way to profit from unstructured sparsity was to build the hardware yourself. The four papers cited on slide 13 are all from Han and his students, and each makes a different thing sparse. EIE, the Efficient Inference Engine, holds the compressed model in on-chip SRAM, so the 640 pJ DRAM access from Part 01 disappears, and it skips both zero weights and the zero activations that ReLU produces, which its authors say "saves another 3x". ESE moves the same idea onto an FPGA for pruned speech-recognition LSTMs, the same recipe the previous concept applied to NeuralTalk. SpArch accelerates multiplying two sparse matrices, and SpAtten prunes tokens and attention heads at run time instead of weights.

SystemVenueWhat is sparseHeadline
EIEISCA 2016Weights and activations of pruned FC layers, model held in on-chip SRAM189x faster than CPU, 13x faster than GPU, 24000x more energy efficient than CPU
ESEFPGA 2017Pruned LSTM weights for speech recognition43x faster than a Core i7, 3x faster than a Pascal Titan X, 282 GOPS on the compressed model
SpArchHPCA 2020Sparse matrix times sparse matrix (outer product with merge)2.8x fewer DRAM accesses, 4x over OuterSPACE
SpAttenHPCA 2021Tokens and heads of attention, pruned in a cascade10x less DRAM traffic, 162x over a Titan Xp
A100 Sparse Tensor CoreNVIDIA 2020Any weight matrix in the 2:4 patternup to 2x peak, 1.3x to 1.6x measured per BERT-Large layer
Hardware support for sparsity on slide 13, with each system's headline claim from its abstract

Worked example

The same pruned layer on three targets

  1. Dense GPU kernel

    fc6 at 9% density still executes all 38 M MACs (75 M FLOPs). Speedup 1x. Memory footprint is smaller only if you store it sparse and decompress it, which costs time too.
  2. EIE

    Work is proportional to nonzero weight times nonzero activation pairs, roughly 3% of the dense count for fc6, and the weights never leave SRAM. This is where the MAC column of the reduction table becomes real time and real energy.
  3. A100 Sparse Tensor Core

    You must prune exactly half in the 2:4 pattern, no more and no less, and you get at most 2x. The 9% density of fc6 cannot be expressed, so you either settle for 50% or lose the hardware path.
  4. Speed is a property of the pair

    The same sparse matrix is a 1x, a 2x or a 30x win depending on what executes it. Parameter count alone predicts none of those.

Quick check

What must a weight matrix satisfy before A100 sparse Tensor Cores can double its throughput?

Recall

What does the A100 require of a pruned matrix, and what does it deliver?

Two zeros in every four contiguous weights (50%, the 2:4 pattern). It delivers up to 2x Tensor Core throughput and almost 2x less storage and bandwidth; measured BERT-Large layer speedups are 1.3x to 1.6x.

Recap

If you remember nothing else

  • Train, prune below a magnitude threshold, retrain the survivors. The retraining step is critical.
  • Prune-only: free lunch at 50 percent, about -1 percent at 67 percent, about -4 percent at 80 percent pruned.
  • Prune plus retrain: zero loss to about 80 percent, 9x on AlexNet. Weights become bimodal and spread from ±0.015 to ±0.025.
  • Iterative prune and retrain: zero loss to about 90 percent, 5x lifted to 9x, sharp drop only past 10x.
  • Reduction factor = 1 / (1 - pruning ratio): 80 percent is 5x, 90 percent is 10x.
  • AlexNet is 9x smaller but only 3x cheaper: FC layers hold 96.2 percent of parameters, conv layers hold 92 percent of MACs. FLOP% ≈ weight density × input activation density.
  • Fully convolutional nets (GoogleNet, ResNet-50, SqueezeNet) all keep about 30 percent, so about 3.4x.
  • The NeuralTalk LSTM pruned 90 percent keeps BLEU flat and captions nearly identical. 95 percent starts to drift.
  • Sparsity is speed only with hardware support: EIE, ESE, SpArch, SpAtten, or the A100 2:4 pattern (up to 2x peak, about 1.3x to 1.6x measured on BERT-Large layers).

Sources