Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN016 · Training method
Magnitude pruning and structured pruning
Removes weights or larger computational units to reduce storage or inference cost.
In CodeSplash
A CodeSplash method covers part of this entry; some options or variants aren't built yet.
- Convolutional neural network (CNN) Experimental
- FT-Transformer Experimental
- TabM (parameter-efficient MLP ensemble) Experimental
- Deep neural network (torch MLP) Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Partly runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through learn.cnn, learn.ft_transformer, learn.tabm, learn.torch_mlp. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Removes weights or larger computational units to reduce storage or inference cost.
Question / hypotheses
Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.
Architecture / computational structure
Unstructured pruning masks individual weights; structured pruning removes channels, heads, blocks, or other hardware-visible units and may require graph surgery.
Assumptions
A useful importance proxy and deployment support for the resulting sparsity are needed. Weight magnitude alone is sensitive to parameter scaling and architecture.
Formula / computational definition
Parameters and notation
Learned: retained weights during recovery training. Hyperparameters: sparsity, layer allocation, pruning schedule, criterion, structured unit, recovery learning rate.
Fitting, fine-tuning, and adaptation
Prune gradually or in a documented one-shot procedure, then fine-tune surviving parameters. Save the mask and ensure the exported model realizes the intended sparse/compact computation.
How to use and calibrate
Measure actual hardware latency and quality, not only zero count. Example: reduce a vision backbone for a constrained device.
Example application
reduce a vision backbone for a constrained device.
Interpretation / pitfalls
Watch out
Unstructured zeros may not accelerate dense kernels. Aggressive pruning can disproportionately harm rare tasks; compare robustness and retained capabilities.
Python and R code examples
Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — numerical mechanism demonstration. · needs numpy
import numpy as np
W=np.array([[.01,.8],[-.2,.03]]); mask=np.abs(W)>.1
print(W*mask,"sparsity",1-mask.mean())
Component demo, not a trained model — numerical mechanism demonstration.
W <- rbind(c(.01,.8),c(-.2,.03)); mask <- abs(W)>.1
print(W*mask); print(1-mean(mask))
Sources
- Primary/official source 1arxiv.org
- Primary/official source 2docs.pytorch.org
From the CodeSplash reference, entry TRN016.