Model Shrinker
Shrink a trained PyTorch model into a smaller, faster copy while keeping as much accuracy as possible. Supports pruning, quantization, distillation and decomposition.
Overview
Model Shrinker takes a PyTorch model you have already trained and returns a smaller, faster copy of it, without changing your original. It works with MLPs, CNNs and everything runs on your own machine.
The workflow has four steps:
- compress():creates a smaller copy using the method you choose, such as l1_pruning.
- compare():prints size, speed and accuracy side by side. Latency is measured by actually running the model.
- finetune():trains the small model a little to win back lost accuracy.
- Save the small model and use it.
Contributing
Explore the repository to understand the codebase, then browse open issues to find one that matches your skills. Submit a pull request following the project's contribution guidelines, and a mentor will review it and work with you until it's ready to merge.
Recent Activity
- Add `shrinker.export_onnx` with an output-parity check
bandiarham07-bot · closed · last week
- Add Tucker / SVD low-rank decomposition
bandiarham07-bot · closed · last week
- Add HRank filter pruning
bandiarham07-bot · closed · last week
- Quantized DFQ and QAT models cannot be saved and reloaded
bandiarham07-bot · closed · last week
- Replace deprecated torch.ao quantization APIs before PyTorch 2.10 removal
bandiarham07-bot · closed · last week