Intel® Low Precision Optimization Tool (Intel® LPOT) is an open-source Python library that delivers a unified low-precision inference interface across multiple Intel-optimized DL frameworks on both CPUs and GPUs. It supports automatic accuracy-driven tuning strategies, along with additional objectives such as optimizing for performance, model size, and memory footprint. It also provides easy extension capability for new backends, tuning strategies, metrics, and objectives.
Note
GPU support is under development.
Infrastructure | Workflow |
Supported Intel optimized DL frameworks are:
- TensorFlow*, including 1.15.0 UP2, 1.15.0 UP1, 2.1.0, 2.2.0, 2.3.0
- PyTorch*, including 1.5.0+cpu, 1.6.0+cpu
- Apache* MXNet, including 1.6.0, 1.7.0
- ONNX* Runtime, including 1.6.0
# install from pip
pip install lpot
# install from conda
conda install lpot -c conda-forge -c intel
git clone https://github.com/intel/lpot.git
cd lpot
python setup.py install
# install from pip
pip install lpot
# install from conda
conda install lpot -c conda-forge -c intel
The following prerequisites and requirements must be satisfied in order to install successfully:
-
Python version: 3.6 or 3.7 or 3.8
-
Download and install anaconda: anaconda
-
Create a virtual environment named lpot in anaconda:
# Here we install python 3.7 for instance. You can also choose python 3.6 & 3.8. conda create -n lpot python=3.7 conda activate lpot
git clone https://github.com/intel/lpot.git
cd lpot
pip install -r requirements.txt
python setup.py install
- Introduction explains Intel® Low Precision Optimization Tool's API.
- Tutorial provides comprehensive instructions on how to utilize Intel® Low Precision Optimization Tool's features with examples.
- Examples are provided to demonstrate the usage of Intel® Low Precision Optimization Tool in different frameworks: TensorFlow, PyTorch, MXNet and ONNX Runtime.
- Quantization is the processes that enable inference and training by performing computations at low precision data type, such as fixed point integers. LPOT supports Post-Training Quantization and Quantization-Aware Training
- Pruning provides a common method for introducing sparsity in weights and activations.
- Benchmarking introduces how to utilize the benchmark interface of LPOT.
- Mixed precision introduces how to enable mixed precision, including BFP16 and int8 and FP32, on Intel platforms during tuning.
- Transform introduces how to utilize LPOT buildin data processing and how to develop a custom data processing method.
- Dataset introudces how to utilize LPOT buildin dataset and how to develop a custom dataset.
- Metric introduces how to utilize LPOT buildin metrics and how to develop a custom metric.
- TensorBoard provides tensor histogram and execution graph for tuning debugging purpose.
- PyTorch Deploy introduces how LPOT saves and loads quantized PyTorch model.
- Adaptor is the interface between LPOT and framework. The method to develop adaptor extension is introduced with ONNX Runtime as example.
- Strategy can automatically optimized low-precision recipes for deep learning models to achieve optimal product objectives like inference performance and memory usage with expected accuracy criteria. The method to develop a new strategy is introduced.
Intel® Low Precision Optimization Tool supports systems based on Intel 64 architecture or compatible processors, specially optimized for the following CPUs:
- Intel Xeon Scalable processor (formerly Skylake, Cascade Lake, and Cooper Lake)
- future Intel Xeon Scalable processor (code name Sapphire Rapids)
Intel® Low Precision Optimization Tool requires installing the pertinent Intel-optimized framework version for TensorFlow, PyTorch, and MXNet.
Platform | OS | Python | Framework | Version |
---|---|---|---|---|
Cascade Lake Cooper Lake Skylake |
CentOS 7.8 Ubuntu 18.04 |
3.6 3.7 |
TensorFlow | 2.2.0 |
1.15.0 UP1 | ||||
1.15.0 UP2 | ||||
2.3.0 | ||||
2.1.0 | ||||
1.15.2 | ||||
PyTorch | 1.5.0+cpu | |||
MXNet | 1.7.0 | |||
1.6.0 | ||||
ONNX Runtime | 1.6.0 |
Intel® Low Precision Optimization Tool provides numerous examples to show promising accuracy loss with the best performance gain.
Framework | Version | Model | Dataset | TOP-1 Accuracy | Performance Speedup | ||
---|---|---|---|---|---|---|---|
INT8 Tuning Accuracy | FP32 Accuracy Baseline | Acc Ratio[(INT8-FP32)/FP32] | Real-time Latency Ratio[FP32/INT8] | ||||
TensorFlow | 2.2.0 | resnet50v1.0 | ImageNet | 73.80% | 74.30% | -0.67% | 2.25x |
TensorFlow | resnet50v1.5 | ImageNet | 76.80% | 76.50% | 0.39% | 2.32x | |
TensorFlow | resnet101 | ImageNet | 77.20% | 76.40% | 1.05% | 2.75x | |
TensorFlow | inception_v1 | ImageNet | 70.10% | 69.70% | 0.57% | 1.56x | |
TensorFlow | inception_v2 | ImageNet | 74.00% | 74.00% | 0.00% | 1.68x | |
TensorFlow | inception_v3 | ImageNet | 77.20% | 76.70% | 0.65% | 2.05x | |
TensorFlow | inception_v4 | ImageNet | 80.00% | 80.30% | -0.37% | 2.52x | |
TensorFlow | inception_resnet_v2 | ImageNet | 80.20% | 80.40% | -0.25% | 1.75x | |
TensorFlow | mobilenetv1 | ImageNet | 71.10% | 71.00% | 0.14% | 1.88x | |
TensorFlow | ssd_resnet50_v1 | Coco | 37.72% | 38.01% | -0.76% | 2.88x | |
TensorFlow | mask_rcnn_inception_v2 | Coco | 28.75% | 29.13% | -1.30% | 4.14x | |
TensorFlow | wide_deep_large_ds | criteo-kaggle | 77.61% | 77.67% | -0.08% | 1.41x | |
TensorFlow | vgg16 | ImageNet | 72.10% | 70.90% | 1.69% | 3.71x | |
TensorFlow | vgg19 | ImageNet | 72.30% | 71.00% | 1.83% | 3.78x | |
TensorFlow | resnetv2_50 | ImageNet | 70.20% | 69.60% | 0.86% | 1.52x | |
TensorFlow | resnetv2_101 | ImageNet | 72.50% | 71.90% | 0.83% | 1.59x | |
TensorFlow | resnetv2_152 | ImageNet | 72.70% | 72.40% | 0.41% | 1.62x | |
TensorFlow | densenet121 | ImageNet | 72.60% | 72.90% | -0.41% | 1.84x | |
TensorFlow | densenet161 | ImageNet | 76.10% | 76.30% | -0.26% | 1.44x | |
TensorFlow | densenet169 | ImageNet | 74.40% | 74.60% | -0.27% | 1.22x |
Framework | Version | Model | Dataset | TOP-1 Accuracy | Performance Speedup | ||
---|---|---|---|---|---|---|---|
INT8 Tuning Accuracy | FP32 Accuracy Baseline | Acc Ratio[(INT8-FP32)/FP32] | Real-time Latency Ratio[FP32/INT8] | ||||
MXNet | 1.7.0 | resnet50v1 | ImageNet | 76.03% | 76.33% | -0.39% | 3.18x |
MXNet | inceptionv3 | ImageNet | 77.80% | 77.64% | 0.21% | 2.65x | |
MXNet | mobilenet1.0 | ImageNet | 71.72% | 72.22% | -0.69% | 2.62x | |
MXNet | mobilenetv2_1.0 | ImageNet | 70.77% | 70.87% | -0.14% | 2.89x | |
MXNet | resnet18_v1 | ImageNet | 69.99% | 70.14% | -0.21% | 3.08x | |
MXNet | squeezenet1.0 | ImageNet | 56.88% | 56.96% | -0.14% | 2.55x | |
MXNet | ssd-resnet50_v1 | VOC | 80.21% | 80.23% | -0.02% | 4.16x | |
MXNet | ssd-mobilenet1.0 | VOC | 74.94% | 75.54% | -0.79% | 3.31x | |
MXNet | resnet152_v1 | ImageNet | 78.32% | 78.54% | -0.28% | 3.16x |
The MSE tuning strategy does not work with the PyTorch adaptor layer. This strategy requires a comparison between the FP32 and INT8 tensors to decide which op impacts the final quantization accuracy. The PyTorch adaptor layer does not implement this inspect tensor interface. Therefore, do not choose the MSE tuning strategy for PyTorch models.
Submit your questions, feature requests, and bug reports to the GitHub issues page. You may also reach out to lpot.maintainers@intel.com.
We welcome community contributions to Intel® Low Precision Optimization Tool. If you have an idea on how to improve the library, refer to the following:
- For changes impacting the public API, submit an RFC pull request.
- Ensure that the changes are consistent with the code contribution guidelines and coding style.
- Ensure that you can run all the examples with your patch.
- Submit a pull request.
For additional details, see contribution guidelines.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Intel® Low Precision Optimization Tool is licensed under Apache License Version 2.0. This software includes components that have separate copyright notices and licensing terms. Your use of the source code for these components is subject to the terms and conditions of the following licenses.
Apache License Version 2.0:
MIT License:
See the accompanying LICENSE file for full license text and copyright notices.
View Legal Information.
If you use Intel® Low Precision Optimization Tool in your research or you wish to refer to the tuning results published in the Model Zoo, use the following BibTeX entry.
@misc{Intel® Low Precision Optimization Tool,
author = {Feng Tian, Chuanqi Wang, Guoming Zhang, Penghui Cheng, Pengxin Yuan, Haihao Shen, and Jiong Gong},
title = {Intel® Low Precision Optimization Tool},
howpublished = {\url{https://github.com/intel/lpot}},
year = {2020}
}