依赖 PyTorch >= 1.10 与 Python >= 3.9,版本过低会装不上;README 提到 PyTorch 更新频繁、自动化测试无法覆盖所有情况,遇到问题需查 FAQ 或加钉钉群;部分剪枝算法 README 称将逐步开放,未必当前都可用。
TinyNeuralNetwork
alibabaMIT更新放缓一个高效易用的深度学习模型压缩框架,支持剪枝、训练后量化和量化感知训练,能把 PyTorch 模型转换部署到端侧。
TinyNeuralNetwork is an efficient and easy-to-use deep learning model compression framework.
git clone https://github.com/alibaba/TinyNeuralNetwork.git
cd TinyNeuralNetwork
python setup.py installREADME 未说明具体显存或 GPU 型号要求,仅要求 Python >= 3.9、PyTorch >= 1.10,并提供基于 CUDA 11.1 的 Docker 构建方式。
阿里开源的深度学习模型压缩框架,集剪枝、量化与模型转换于一体,面向端侧部署
一个高效易用的深度学习模型压缩框架,支持剪枝、训练后量化和量化感知训练,能把 PyTorch 模型转换部署到端侧。
核心能力
- 用 Graph Tracer 捕获 PyTorch 算子连接关系
- 自动解析并修复子图间的算子依赖不匹配
- 内置 OneShot、ADMM、NetAdapt 等多种剪枝算法
- 以 PyTorch QAT 为后端做量化感知训练并自动融合算子
- 将浮点与量化 PyTorch 模型转换为 TFLite 部署
容易踩的坑
- llm_0.0.1Annoucing easyquant for speeding up LLM inference via quantization最新正式版2023-05-31 · 2023-05-31 09:41 UTC
With the help of quantization, we could achieve LLM inference efficiently with lower resource usage. Please install the package below and try out the examples here. We look forward to your feedback.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
TinyNeuralNetwork
TinyNeuralNetwork is an efficient and easy-to-use deep learning model compression framework, which contains features like neural architecture search, pruning, quantization, model conversion and etc. It has been utilized for the deployment on devices such as Tmall Genie, Haier TV, Youku video, face recognition check-in machine, and etc, which equips over 10 million IoT devices with AI capability.
Installation
Python >= 3.9, PyTorch >= 1.10
# Install the TinyNeuralNetwork framework
git clone https://github.com/alibaba/TinyNeuralNetwork.git
cd TinyNeuralNetwork
python setup.py install
# Alternatively, you may try the one-liner
pip install git+https://github.com/alibaba/TinyNeuralNetwork.git
Or you could build with docker
sudo docker build -t tinynn:pytorch1.9.0-cuda11.1 .
Contributing
We appreciate your help for improving our framework. More details are listed here.
Basic modules
- Computational graph capture: The Graph Tracer in TinyNeuralNetwork captures connectivity of PyTorch operators, which automates pruning and model quantization. It also supports code generation from PyTorch models to equivalent model description files (e.g. models.py).
- Dependency resolving: Modifying an operator often causes mismatch in subgraph, i.e. mismatch with other dependent operators. The Graph Modifier in TinyNeuralNetwork handles the mismatchs automatically within and between subgraphs to automate the computational graph modification.
- Pruner: OneShot (L1, L2, FPGM), ADMM, NetAdapt, Gradual, End2End and other pruning algorithms have been implemented and will be opened gradually.
- Quantization-aware training: TinyNeuralNetwork uses PyTorch's QAT as the backend (we also support simulated bfloat16 training) and optimizes its usability with automating the fusion of operators and quantization of computational graphs (the official implementation requires manual implementation by the user, which is a huge workload).
- Model conversion: TinyNeuralNetwork supports conversion of floating-point and quantized PyTorch models to TFLite models for end-to-end deployment.

Project architecture
- examples: Provides examples of each module
- models: Provides pre-trained models for getting quickstart
- tests: Unit tests
- tinynn: Code for model compression
RoadMap
- Nov. 2021: A new pruner with adaptive sparsity
- Dec. 2021: Model compression for Transformers
Citation
If you find this project useful in your research, please consider cite:
@misc{tinynn,
title={TinyNeuralNetwork: An efficient deep learning model compression framework},
author={Ding, Huanghao and Pu, Jiachen and Hu, Conggang},
howpublished = {\url{https://github.com/alibaba/TinyNeuralNetwork}},
year={2021}
}
Frequently Asked Questions
Because of the high complexity and frequent updates of PyTorch, we cannot ensure that all cases are covered through automated testing. When you encounter problems You can check out the FAQ, or join the Q&A group in DingTalk via the QR Code below.
