|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +Intel® Neural Compressor |
| 4 | +=========================== |
| 5 | +<h3> An open-source Python library supporting popular model compression techniques on all mainstream deep learning frameworks (TensorFlow, PyTorch, ONNX Runtime, and MXNet)</h3> |
| 6 | + |
| 7 | +[](https://github.com/intel/neural-compressor) |
| 8 | +[](https://github.com/intel/neural-compressor/releases) |
| 9 | +[](https://github.com/intel/neural-compressor/blob/master/LICENSE) |
| 10 | +[](https://github.com/intel/neural-compressor) |
| 11 | +[](https://pepy.tech/project/neural-compressor) |
| 12 | +</div> |
| 13 | + |
| 14 | +--- |
| 15 | +<div align="left"> |
| 16 | + |
| 17 | +Intel® Neural Compressor, formerly known as Intel® Low Precision Optimization Tool, is an open-source Python library that runs on Intel CPUs and GPUs, which delivers unified interfaces across multiple deep-learning frameworks for popular network compression technologies such as quantization, pruning, and knowledge distillation. This tool supports automatic accuracy-driven tuning strategies to help the user quickly find out the best quantized model. It also implements different weight-pruning algorithms to generate a pruned model with predefined sparsity goal. It also supports knowledge distillation to distill the knowledge from the teacher model to the student model. |
| 18 | +Intel® Neural Compressor is a critical AI software component in the [Intel® oneAPI AI Analytics Toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/ai-analytics-toolkit.html). |
| 19 | + |
| 20 | + |
| 21 | +**Visit the Intel® Neural Compressor online document website at: <https://intel.github.io/neural-compressor>.** |
| 22 | + |
| 23 | +## Installation |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +Python version: 3.7, 3.8, 3.9, 3.10 |
| 28 | + |
| 29 | +### Install on Linux |
| 30 | +- Release binary install |
| 31 | + ```Shell |
| 32 | + # install stable basic version from pip |
| 33 | + pip install neural-compressor |
| 34 | + # Or install stable full version from pip (including GUI) |
| 35 | + pip install neural-compressor-full |
| 36 | + ``` |
| 37 | +- Nightly binary install |
| 38 | + ```Shell |
| 39 | + git clone https://github.com/intel/neural-compressor.git |
| 40 | + cd neural-compressor |
| 41 | + pip install -r requirements.txt |
| 42 | + # install nightly basic version from pip |
| 43 | + pip install -i https://test.pypi.org/simple/ neural-compressor |
| 44 | + # Or install nightly full version from pip (including GUI) |
| 45 | + pip install -i https://test.pypi.org/simple/ neural-compressor-full |
| 46 | + ``` |
| 47 | +More installation methods can be found at [Installation Guide](./installation_guide.html). Please check out our [FAQ](./faq.html) for more details. |
| 48 | + |
| 49 | +## Getting Started |
| 50 | +### Quantization with Python API |
| 51 | + |
| 52 | +```shell |
| 53 | +# A TensorFlow Example |
| 54 | +pip install tensorflow |
| 55 | +# Prepare fp32 model |
| 56 | +wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_6/mobilenet_v1_1.0_224_frozen.pb |
| 57 | +``` |
| 58 | +```python |
| 59 | +import tensorflow as tf |
| 60 | +from neural_compressor.experimental import Quantization, common |
| 61 | +quantizer = Quantization() |
| 62 | +quantizer.model = './mobilenet_v1_1.0_224_frozen.pb' |
| 63 | +dataset = quantizer.dataset('dummy', shape=(1, 224, 224, 3)) |
| 64 | +quantizer.calib_dataloader = common.DataLoader(dataset) |
| 65 | +quantizer.fit() |
| 66 | +``` |
| 67 | +### Quantization with [JupyterLab Extension](./neural_coder/extensions/neural_compressor_ext_lab/README.html) |
| 68 | +Search for ```jupyter-lab-neural-compressor``` in the Extension Manager in JupyterLab and install with one click: |
| 69 | + |
| 70 | +<a target="_blank" href="imgs/extmanager.png"> |
| 71 | + <img src="imgs/extmanager.png" alt="Extension" width="35%" height="35%"> |
| 72 | +</a> |
| 73 | + |
| 74 | +### Quantization with [GUI](./bench.html) |
| 75 | +```shell |
| 76 | +# An ONNX Example |
| 77 | +pip install onnx==1.12.0 onnxruntime==1.12.1 onnxruntime-extensions |
| 78 | +# Prepare fp32 model |
| 79 | +wget https://github.com/onnx/models/raw/main/vision/classification/resnet/model/resnet50-v1-12.onnx |
| 80 | +# Start GUI |
| 81 | +inc_bench |
| 82 | +``` |
| 83 | +<a target="_blank" href="./_static/imgs/INC_GUI.gif"> |
| 84 | + <img src="./_static/imgs/INC_GUI.gif" alt="Architecture"> |
| 85 | +</a> |
| 86 | + |
| 87 | +## System Requirements |
| 88 | + |
| 89 | +### Validated Hardware Environment |
| 90 | +#### Intel® Neural Compressor supports CPUs based on [Intel 64 architecture or compatible processors](https://en.wikipedia.org/wiki/X86-64): |
| 91 | + |
| 92 | +* Intel Xeon Scalable processor (formerly Skylake, Cascade Lake, Cooper Lake, and Icelake) |
| 93 | +* Future Intel Xeon Scalable processor (code name Sapphire Rapids) |
| 94 | + |
| 95 | +#### Intel® Neural Compressor supports GPUs built on Intel's Xe architecture: |
| 96 | + |
| 97 | +* [Intel® Data Center GPU Flex Series](https://www.intel.com/content/www/us/en/products/docs/discrete-gpus/data-center-gpu/flex-series/overview.html) |
| 98 | + |
| 99 | +#### Intel® Neural Compressor quantized ONNX models support multiple hardware vendors through ONNX Runtime: |
| 100 | + |
| 101 | +* Intel CPU, AMD/ARM CPU, and NVidia GPU. Please refer to the validated model [list](./validated_model_list.html#Validated-ONNX-QDQ-INT8-models-on-multiple-hardware-through-ONNX-Runtime). |
| 102 | + |
| 103 | +### Validated Software Environment |
| 104 | + |
| 105 | +* OS version: CentOS 8.4, Ubuntu 20.04 |
| 106 | +* Python version: 3.7, 3.8, 3.9, 3.10 |
| 107 | + |
| 108 | +<table class="docutils"> |
| 109 | +<thead> |
| 110 | + <tr> |
| 111 | + <th>Framework</th> |
| 112 | + <th>TensorFlow</th> |
| 113 | + <th>Intel TensorFlow</th> |
| 114 | + <th>PyTorch</th> |
| 115 | + <th>Intel® Extension for PyTorch*</th> |
| 116 | + <th>ONNX Runtime</th> |
| 117 | + <th>MXNet</th> |
| 118 | + </tr> |
| 119 | +</thead> |
| 120 | +<tbody> |
| 121 | + <tr align="center"> |
| 122 | + <th>Version</th> |
| 123 | + <td class="tg-7zrl"><a href=https://github.com/tensorflow/tensorflow/tree/v2.10.0>2.10.0</a><br> |
| 124 | + <a href=https://github.com/tensorflow/tensorflow/tree/v2.9.1>2.9.1</a><br> |
| 125 | + <a href=https://github.com/tensorflow/tensorflow/tree/v2.8.2>2.8.2</a><br> |
| 126 | + <td class="tg-7zrl"><a href=https://github.com/Intel-tensorflow/tensorflow/tree/v2.10.0>2.10.0</a><br> |
| 127 | + <a href=https://github.com/Intel-tensorflow/tensorflow/tree/v2.9.1>2.9.1</a><br> |
| 128 | + <a href=https://github.com/Intel-tensorflow/tensorflow/tree/v2.8.0>2.8.0</a><br> |
| 129 | + <td class="tg-7zrl"><a href=https://download.pytorch.org/whl/torch_stable.html>1.12.1+cpu</a><br> |
| 130 | + <a href=https://download.pytorch.org/whl/torch_stable.html>1.11.0+cpu</a><br> |
| 131 | + <a href=https://download.pytorch.org/whl/torch_stable.html>1.10.0+cpu</a></td> |
| 132 | + <td class="tg-7zrl"><a href=https://github.com/intel/intel-extension-for-pytorch/tree/v1.12.0>1.12.0</a><br> |
| 133 | + <a href=https://github.com/intel/intel-extension-for-pytorch/tree/1.11.0>1.11.0</a><br> |
| 134 | + <a href=https://github.com/intel/intel-extension-for-pytorch/tree/v1.10.0>1.10.0</a></td> |
| 135 | + <td class="tg-7zrl"><a href=https://github.com/microsoft/onnxruntime/tree/v1.12.1>1.12.1</a><br> |
| 136 | + <a href=https://github.com/microsoft/onnxruntime/tree/v1.11.0>1.11.0</a><br> |
| 137 | + <a href=https://github.com/microsoft/onnxruntime/tree/v1.10.0>1.10.0</a></td> |
| 138 | + <td class="tg-7zrl"><a href=https://github.com/apache/incubator-mxnet/tree/1.8.0>1.8.0</a><br> |
| 139 | + <a href=https://github.com/apache/incubator-mxnet/tree/1.7.0>1.7.0</a><br> |
| 140 | + <a href=https://github.com/apache/incubator-mxnet/tree/1.6.0>1.6.0</a></td> |
| 141 | + </tr> |
| 142 | +</tbody> |
| 143 | +</table> |
| 144 | + |
| 145 | +> **Note:** |
| 146 | +> Set the environment variable ``TF_ENABLE_ONEDNN_OPTS=1`` to enable oneDNN optimizations if you are using TensorFlow v2.6 to v2.8. oneDNN is the default for TensorFlow v2.9. |
| 147 | +
|
| 148 | +### Validated Models |
| 149 | +Intel® Neural Compressor validated 420+ [examples](./examples) for quantization with a performance speedup geomean of 2.2x and up to 4.2x on VNNI while minimizing accuracy loss. Over 30 pruning and knowledge distillation samples are also available. More details for validated models are available [here](./validated_model_list.html). |
| 150 | + |
| 151 | +<div style = "width: 77%; margin-bottom: 2%;"> |
| 152 | + <a target="_blank" href="./_static/imgs/release_data.png"> |
| 153 | + <img src="./_static/imgs/release_data.png" alt="Architecture" width=800 height=500> |
| 154 | + </a> |
| 155 | +</div> |
| 156 | + |
| 157 | +## Documentation |
| 158 | + |
| 159 | +<table class="docutils"> |
| 160 | + <thead> |
| 161 | + <tr> |
| 162 | + <th colspan="9">Overview</th> |
| 163 | + </tr> |
| 164 | + </thead> |
| 165 | + <tbody> |
| 166 | + <tr> |
| 167 | + <td colspan="3" align="center"><a href="./design.html">Architecture</a></td> |
| 168 | + <td colspan="2" align="center"><a href="https://github.com/intel/neural-compressor/tree/master/examples">Examples</a></td> |
| 169 | + <td colspan="2" align="center"><a href="./bench.html">GUI</a></td> |
| 170 | + <td colspan="2" align="center"><a href="https://intel.github.io/neural-compressor/api-documentation/apis.html">APIs</a></td> |
| 171 | + </tr> |
| 172 | + <tr> |
| 173 | + <td colspan="5" align="center"><a href="https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-ai-linux/top.html">Intel oneAPI AI Analytics Toolkit</a></td> |
| 174 | + <td colspan="4" align="center"><a href="https://github.com/oneapi-src/oneAPI-samples/tree/master/AI-and-Analytics">AI and Analytics Samples</a></td> |
| 175 | + </tr> |
| 176 | + </tbody> |
| 177 | + <thead> |
| 178 | + <tr> |
| 179 | + <th colspan="9">Basic API</th> |
| 180 | + </tr> |
| 181 | + </thead> |
| 182 | + <tbody> |
| 183 | + <tr> |
| 184 | + <td colspan="2" align="center"><a href="./transform.html">Transform</a></td> |
| 185 | + <td colspan="2" align="center"><a href="./dataset.html">Dataset</a></td> |
| 186 | + <td colspan="2" align="center"><a href="./metric.html">Metric</a></td> |
| 187 | + <td colspan="3" align="center"><a href="./objective.html">Objective</a></td> |
| 188 | + </tr> |
| 189 | + </tbody> |
| 190 | + <thead> |
| 191 | + <tr> |
| 192 | + <th colspan="9">Deep Dive</th> |
| 193 | + </tr> |
| 194 | + </thead> |
| 195 | + <tbody> |
| 196 | + <tr> |
| 197 | + <td colspan="2" align="center"><a href="./quantization.html">Quantization</a></td> |
| 198 | + <td colspan="1" align="center"><a href="./pruning.html">Pruning(Sparsity)</a></td> |
| 199 | + <td colspan="2" align="center"><a href="./distillation.html">Knowledge Distillation</a></td> |
| 200 | + <td colspan="2" align="center"><a href="./mixed_precision.html">Mixed Precision</a></td> |
| 201 | + <td colspan="2" align="center"><a href="./orchestration.html">Orchestration</a></td> |
| 202 | + </tr> |
| 203 | + <tr> |
| 204 | + <td colspan="2" align="center"><a href="./benchmark.html">Benchmarking</a></td> |
| 205 | + <td colspan="3" align="center"><a href="./distributed.html">Distributed Training</a></td> |
| 206 | + <td colspan="2" align="center"><a href="./model_conversion.html">Model Conversion</a></td> |
| 207 | + <td colspan="2" align="center"><a href="./tensorboard.html">TensorBoard</a></td> |
| 208 | + </tr> |
| 209 | + <tr> |
| 210 | + <td colspan="4" align="center"><a href="./distillation_quantization.html">Distillation for Quantization</a></td> |
| 211 | + <td colspan="5" align="center"><a href="https://github.com/intel/neural-compressor/tree/master/neural_coder">Neural Coder</a></td> |
| 212 | + </tr> |
| 213 | + |
| 214 | + </tbody> |
| 215 | + <thead> |
| 216 | + <tr> |
| 217 | + <th colspan="9">Advanced Topics</th> |
| 218 | + </tr> |
| 219 | + </thead> |
| 220 | + <tbody> |
| 221 | + <tr> |
| 222 | + <td colspan="6" align="center"><a href="./adaptor.html">Adaptor</a></td> |
| 223 | + <td colspan="6" align="center"><a href="./tuning_strategies.html">Strategy</a></td> |
| 224 | + </tr> |
| 225 | + </tbody> |
| 226 | +</table> |
| 227 | + |
| 228 | +## Selected Publications/Events |
| 229 | +* [Neural Compressor: an open-source Python library for network compression](https://cloud.tencent.com/developer/article/2165895) (Nov 2022) |
| 230 | +* [Running Fast Transformers on CPUs: Intel Approach Achieves Significant Speed Ups and SOTA Performance](https://medium.com/syncedreview/running-fast-transformers-on-cpus-intel-approach-achieves-significant-speed-ups-and-sota-448521704c5e) (Nov 2022) |
| 231 | +* [Personalized Stable Diffusion with Few-Shot Fine-Tuning](https://medium.com/intel-analytics-software/personalized-stable-diffusion-with-few-shot-fine-tuning-on-a-single-cpu-f01a3316b13) (Nov 2022) |
| 232 | +* [Meet the Innovation of Intel AI Software: Intel® Extension for TensorFlow*](https://www.intel.com/content/www/us/en/developer/articles/technical/innovation-of-ai-software-extension-tensorflow.html) (Oct 2022) |
| 233 | +* [PyTorch* Inference Acceleration with Intel® Neural Compressor](https://www.intel.com/content/www/us/en/developer/articles/technical/pytorch-inference-with-intel-neural-compressor.html#gs.gnq0cj) (Oct 2022) |
| 234 | +* Neural Coder, a new plug-in for Intel Neural Compressor was covered by [Twitter](https://twitter.com/IntelDevTools/status/1583629213697212416), [LinkedIn](https://www.linkedin.com/posts/intel-software_oneapi-ai-deeplearning-activity-6989377309917007872-Dbzg?utm_source=share&utm_medium=member_desktop), and [Intel Developer Zone](https://mp.weixin.qq.com/s/LL-4eD-R0YagFgODM23oQA) from Intel, and [Twitter](https://twitter.com/IntelDevTools/status/1583629213697212416/retweets) and [LinkedIn](https://www.linkedin.com/feed/update/urn:li:share:6990377841435574272/) from Hugging Face. (Oct 2022) |
| 235 | +* Intel Neural Compressor successfully landed on [GCP](https://console.cloud.google.com/marketplace/product/bitnami-launchpad/inc-tensorflow-intel?project=verdant-sensor-286207), [AWS](https://aws.amazon.com/marketplace/pp/prodview-yjyh2xmggbmga#pdp-support), and [Azure](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/bitnami.inc-tensorflow-intel) marketplace. (Oct 2022) |
| 236 | + |
| 237 | +> View our [full publication list](./publication_list.html). |
| 238 | +
|
| 239 | +## Additional Content |
| 240 | + |
| 241 | +* [Release Information](./releases_info.html) |
| 242 | +* [Contribution Guidelines](./contributions.html) |
| 243 | +* [Legal Information](./legal_information.html) |
| 244 | +* [Security Policy](SECURITY.html) |
| 245 | +* [Intel® Neural Compressor Website](https://intel.github.io/neural-compressor) |
| 246 | + |
| 247 | +## Hiring |
| 248 | + |
| 249 | +We are actively hiring. Send your resume to [email protected] if you are interested in model compression techniques. |
0 commit comments