TL;DR
RigL trains a neural network that stays sparse from the first step to the last: most weights are held at zero, so memory and computation scale with the share of weights kept. Every so many steps it swaps some connections, dropping the active weights that are smallest in size and activating new ones where the loss gradient is largest. The authors show it reaches higher accuracy than earlier sparse-training methods at the same training cost, and that it can beat magnitude pruning, which needs a full dense model first.
Builds on: Pruning, Dynamic Sparse Training, Stochastic Gradient Descent · Leads to: none yet in the graph
Why it mattered
Sparse networks are attractive because they are small and cheap to run, but the best sparse models were usually made by training a dense model and then removing weights. That caps the largest sparse model at the size of the largest dense model you can train. RigL removes that cap by training the sparse model directly.
The paper evaluates image classification with ResNet-50 and MobileNets on ImageNet-2012, a CIFAR-10 wide residual network, and a character-level language model on WikiText-103. The authors released a TensorFlow implementation with checkpoints. Its conclusion names three uses: making deployed sparse models more accurate, improving large sparse models that can only be trained for a limited number of steps, and training very large sparse models once sparse hardware exists.
The problem
Three families of methods existed before RigL, and each had a cost.
- Dense-to-sparse methods start from a full network and remove weights, as in Pruning. The dense training is paid first, so the cost and memory are those of a dense model.
- Lottery-ticket methods find a sparse subnetwork and retrain it from its original starting values. The The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks shows this can work, but it is unclear whether such starting points can be found without first training a dense model.
- Sparse-to-sparse methods keep the network sparse throughout. SET drops the smallest-magnitude weights and grows new ones at random; on ResNet-50 it saturates around 75 percent accuracy, which the paper reads as the limit of random growth. SNFS grows connections using momentum, but it needs the gradient for every weight at every step, including the zero ones, so its cost is close to dense training.
RigL needs a method that keeps the sparse budget fixed, grows connections using gradient information, and computes dense gradients only occasionally.
The lineage is long. The paper traces magnitude pruning to Thimm and Fiesler (1995), gradual pruning to 2017 and 2018, and the sparse-to-sparse methods (SET, DeepR, DSR, SNFS, SNIP) to 2018 and 2019. The Lottery Ticket Hypothesis was set out by Frankle and Carbin in 2019. RigL takes the gradient-based growth idea from SNFS and makes it cheap by computing the dense gradient only once every steps (100 by default), not at every step.
How it works
Here is one tiny layer followed through one connectivity update. The layer has six possible connections, three are active, so its sparsity is one half. Pretend the update is due now, the fraction to swap is one third, and the active weights have magnitudes 0.9, 0.1 and 0.5.
- Start with a random mask. Three of the six slots are active. The other three hold zero and take no part in the forward pass. Check: three active, three inactive, sparsity one half.
- Train on the active weights for a while. Each step is an ordinary gradient step, but only active weights change. The gap between updates is called delta T; here it is small so the example stays readable. Check: the active count is still three.
- Work out how many connections to swap. One third of the three active connections is one, so the update swaps one connection. Check: one third of three is one.
- Drop the weakest active connection. The smallest magnitude is 0.1, so that slot goes back to inactive. The remaining active weights are 0.9 and 0.5. Check: two active.
- Grow the connection with the biggest gradient. The paper computes the loss gradient for every inactive slot, even though each of those weights is zero. Say slot four has gradient size 0.7, slot five 0.2 and slot six 0.05. Slot four becomes active with weight exactly zero, so the output does not change at the moment of growth. Check: three active again, so sparsity is still one half.
- Keep training. Slot four now receives a gradient, so its weight moves away from zero on the next step. The connection count is unchanged, but the shape of the network has changed.
The point of the walkthrough is that the swap is cheap enough to do often, because the dense gradient is needed only once every delta T steps, not at every step.
flowchart LR A["Random sparse mask"] --> B["Train for delta T steps on active weights"] B --> C["Drop the smallest-magnitude active weights"] C --> D["Grow inactive weights with the largest gradients, starting at zero"] D --> B
The math
A network has parameters . Layer has possible weights, a sparsity , and an active vector of length . The overall sparsity is , the fraction of all weights that are zero.
Step 1 in symbols: the random mask
Choose the mask once at the start. For the toy layer, and , so the active vector has length . The paper compares three ways to spread sparsity across layers: uniform, Erdős–Rényi, and Erdős–Rényi-Kernel, which also counts kernel dimensions and gives small layers lower sparsity. Each choice changes the FLOPs, which the cost section below depends on.
Step 2 in symbols: how many connections to swap
Let be the step, the last step at which the mask may change, and the largest fraction swapped. The mask is updated only when is a multiple of and . The fraction shrinks with a cosine schedule:
At the fraction is , at the midpoint it is , and at it is zero. The number of connections to swap in layer is .
- alpha = 0.3
- alpha = 0.1
Step 3 in symbols: drop and grow
Drop the active connections with the smallest magnitude:
Grow connections among the inactive slots with the largest gradient magnitudes. Here is the gradient of the loss on the current batch with respect to every weight in the layer, including the inactive ones:
Grown weights are set to zero, so the computed function does not change at the moment of the swap.
Step 4 in symbols: the cost
Let be the forward-pass FLOPs of the sparse model and those of the dense model. Training a step costs about three times the forward pass, counting the backward pass. A step without a mask update costs . A step that refreshes the mask costs : the sparse forward pass and error backpropagation, plus the dense weight gradient needed for growing. Averaged over a window of steps, the RigL cost per sample is
This stays close to the static sparse cost only when is large, which is why the default is 100 steps.
Worked examples
Take and steps, and a layer with 200 active connections.
- At , , so . Swap connections.
- At , , so . Swap .
- At there is no update, because the rule requires .
Interpretation: the mask changes most in the first updates and settles as training goes on, so the last part of training runs on a fixed connectivity.
Use the cost formula with and an 80 percent sparse layer, so . Work in units of .
- Static sparse training costs per sample.
- RigL costs .
- The overhead above static is , about 1.3 percent of the static cost.
- Dense training costs , so RigL is about of dense training.
Interpretation: the dense gradient that makes growth possible is paid once every 101 steps, so almost all the work is sparse work.
Take a layer with 1,000,000 weights kept at 90 percent sparsity, so 100,000 are active. Use the paper's ImageNet setting, , , and .
- The first update at swaps connections, 30 percent of the active set at once.
- Updates happen at , which is update points.
- The swap count falls with the cosine, so later updates touch fewer connections. Try it: at , a multiple of 100 before , how many connections does the layer swap?
Answer: , so , and the swap count is .
Results
The paper's results, with its own numbers:
- ImageNet, ResNet-50, 96.5 percent sparsity. With the Erdős–Rényi-Kernel distribution and five times the original training steps, RigL reaches 72.75 percent top-1 accuracy, which the authors describe as about 3.5 percent higher than the extended magnitude pruning results of Gale et al. (2019).
- ImageNet, sparsity sweep. With uniform sparsity, RigL exceeds iterative magnitude pruning at every sparsity level tested while needing fewer training FLOPs. The one exception the paper flags is the 80 percent sparse RigL-ERK run, which needs more FLOPs than pruning.
- MobileNets. RigL trains 75 percent sparse MobileNets with no loss in performance. A MobileNet-v1 with width multiplier 1.98 at 75 percent sparsity has the same FLOPs and parameter count as the dense baseline, and it improves top-1 accuracy by 4.3 percent absolute.
- CIFAR-10. On a 22-layer wide residual network the dense baseline reaches 94.1 percent. Some 50 percent sparse networks generalise better than that baseline. RigL matches the performance of pruning with only a fraction of the training resources.
- Character-level language modelling on WikiText-103. RigL beats the other sparse-training methods but does not match pruning here, which the authors flag as future work.
- Lottery tickets (Appendix E). Restarting RigL's final topology from the original initialisation gives 73.93 percent. A random start trained with RigL reaches 74.55 percent at 0.23 times the FLOPs, and a fixed topology from the original initialisation gives 70.82 percent. The paper concludes there are no special tickets: with RigL, all tickets seem to win.
The limits the paper names are the language-model gap, the weaker generalisation on CIFAR-10, and the lack of hardware support for unstructured sparsity, which is why the third scenario in its conclusion is not yet tested.
Common mistakes and tradeoffs
It is tempting to think RigL is just pruning run for longer. In fact it never trains a dense model: the network is sparse from the first step, and the dense gradient is computed only to choose which slots to grow, then discarded.
It is tempting to think growth should prefer large weights. In fact dropping uses magnitude and growing uses gradient. A slot that was never active has no weight to look at, but its gradient shows how fast the loss would fall if the slot were turned on. The paper's loss-landscape study (Section 4.4) finds that static sparse networks get stuck in regions that cannot be connected to better solutions, while letting new connections grow lets training move around that barrier.
It is tempting to think a new connection should start from a random value. In fact the paper starts it at zero, so the swap does not change the output at that moment. The gradient, not the starting value, is what makes the connection useful on the next step.
It is tempting to think more swapping is always better. In fact the paper's sweep gives the best results at an update interval of 100 steps with an initial fraction of 0.3 or 0.5, and even updates every 1000 steps keep accuracy above 73.5 percent on ImageNet.
It is tempting to think two networks with the same sparsity cost the same. In fact the Erdős–Rényi-Kernel distribution is more accurate than uniform sparsity at the same parameter count, but the paper reports it needs about twice the inference FLOPs. Compare FLOPs as well as parameters.
Use RigL when you need a sparse model with a fixed training budget and hardware that runs sparse layers efficiently. Do not expect it to replace pruning everywhere. The paper's Table 1 places it among the sparse-training methods:
| Method | Drop rule | Grow rule | Fixed FLOPs chosen up front | Cost proportional to sparsity |
|---|---|---|---|---|
| SNIP | smallest saliency | none | yes | yes |
| DeepR | stochastic | random | yes | yes |
| SET | smallest magnitude | random | yes | yes |
| DSR | smallest magnitude | random | no | yes |
| SNFS | smallest magnitude | momentum | no | no |
| RigL | smallest magnitude | largest gradient | yes | yes |
Reading guide
Read this paper with Pruning and The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks beside you, since RigL answers both. Then go through the sections in order.
- Abstract and Section 1. The motivation: sparse models are capped by dense training, and the lottery-ticket line asks whether good masks can be found without a dense model.
- Section 2, Related Work. The map of earlier methods. SNFS uses Momentum as its growth signal, and SET uses a random growth rule. Keep Dynamic Sparse Training open beside it.
- Section 3, Rigging the Lottery. The method and Algorithm 1. Needs Stochastic Gradient Descent, Gradient Descent and Cosine Annealing for the schedule.
- Section 4.1, ImageNet. The ResNet-50 and MobileNet experiments. Read with Deep Residual Learning for Image Recognition (ResNet) and MobileNets: Efficient Convolutional Neural Networks for Mobile Vision. ERK is named after the random-graph model in Erdős–Rényi Random Graph.
- Sections 4.2 and 4.3. The language model and CIFAR-10 experiments. They need only the general idea of training and evaluating a network.
- Section 4.4 and Appendix A. The sweeps over sparsity distribution and update schedule, and the loss-landscape interpolation. Needs the idea of a loss surface from Gradient Descent.
- Appendix E. The lottery-ticket test. Read it last, after The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks.
- Appendix H. The FLOP accounting used in the math section above.
For the classic dense-to-sparse recipe, read Learning both Weights and Connections for Efficient Neural Networks after this paper.
Check yourself
QuestionWhat does one RigL update do to a layer, and which rule chooses the connections to drop and to grow?Show answer
It drops the active connections with the smallest magnitude and grows the same number of inactive connections with the largest gradient magnitude. The count is the cosine-scheduled fraction times the number of active connections, so the total number of active connections stays fixed.
QuestionA layer has 500 active connections, alpha is 0.2, T_end is 1000, and the update is at step t = 500. How many connections are swapped?Show answer
The fraction is . The swap count is .
QuestionWhy are newly grown connections initialised to zero rather than to a random value?Show answer
A zero weight contributes nothing to the output, so growing a connection does not change the network's function at that moment. The connection was chosen because its gradient is large, so on the next step it receives a real update and moves away from zero.
QuestionA team wants a sparse model for a phone with a fixed training budget and must choose between uniform and Erdős–Rényi-Kernel sparsity at the same parameter count. What trade-off does the paper report?Show answer
The Erdős–Rényi-Kernel distribution gives better accuracy at the same parameter count, because it gives lower sparsity to layers with few parameters. But the paper reports it needs roughly twice as many inference FLOPs as uniform sparsity, so the team must decide whether accuracy or inference cost matters more for its phone.
Sources
- Evci, Gale, Menick, Castro, Elsen (2019). Rigging the Lottery: Making All Tickets Winners. arXiv:1911.11134.
- Official implementation: google-research/rigl.