Pruning / Sparsity
Aditya Desai
Many thanks to all the resources listed in References on the main website. Almost all figures are taken from these resources; some were generated with Gemini. Some images are taken from Google Images and still need proper citation (in progress).
| Device Class | Approximate RAM Range |
|---|---|
| Tiny IoT devices | KB to MB |
| Wearables | 0.5–8 GB |
| Phones & Glasses | 4–16 GB |
| Laptops | 8–64 GB |
| Drones | 2–32 GB |
| Cars | 16–512 GB |
| Edge Servers | 64 GB–4 TB |
We can apply the techniques we will discuss as part of model compression to activations, gradients, optimizer states, etc.
1) Rank-one update — add outer product $uv^\top$ to $A$:
If you do a one-rank update to A, then it provides a relation between inverse
of A and the inverse of the updated matrix.
O(n2) update instead of O(n3) for inverse of (A+uv^\top)
If you have inverse of a larger matrix, then you can use this to find the inverse of matrix
with one row and column removed.
O(n2) update instead of O(n3) for inverse of B
Computational graph view: we remove some of the connections in the model.
Note Link: notes/pruning_a_neuron.html
x, w \in R^d, y \in Rd × O(d3)
d — number of sub problemsO(d3) — inverse of the HessianO(k d4)
Note Link: notes/pruning_a_model.html
All that one needs to know for pruning.
H−1.q that gives the smallest saliency
Lq = wq2 / (2 [H−1]qq).
If this candidate error increase is much smaller than E,
delete the q-th weight and go to step 4; otherwise go to step 5.
q from step 3 to update all weights
(δw). Go to step 2.
E.
(At this point it may be desirable to retrain the network.)
O(N3), where N is the number of parameters.O(nN2) where n is the number of samples and N is the number of parameters.O(k(N3 + nN2))
Hint: Use Linear Algebra identities we introduced. (Exercise : We will look at it next class)
q that gives the smallest saliency
Lq = ½ Hqq wq2.
Delete few low saliency weights
δw).Hint: Can be done in single forward / backward pass. (Exercise : We will look at it next class)
magnitude (equivalent to assuming H_{kk} is same for all k)
and rely on training to correct the errors|wi|.
Learning both Weights and Connections for Efficient Neural Networks" by Han et al. 2015