Skip to content

Commit 359dd72

Browse files
committed
Release v1.7.0 of NNCF to master
1 parent 20f691f commit 359dd72

File tree

828 files changed

+140570
-35519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

828 files changed

+140570
-35519
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ If your testing code is more extensive than unit tests (in terms of test executi
3131

3232

3333
## Code style
34+
Changes to NNCF Python code should conform to [Python Style Guide](./docs/styleguide/PyGuide.md)
35+
3436
Pylint is used throughout the project to ensure code cleanliness and quality.
3537
A Pylint run is also done as part of the pre-commit scope - the pre-commit `pytest` scope will not be run if your code fails the Pylint checks.
3638
The Pylint rules and exceptions for this repository are described in the standard [.pylintrc](./.pylintrc) format - make sure your local linter uses these.

README.md

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,16 @@ See [third_party_integration](./third_party_integration) for examples of code mo
7777
## System requirements
7878
- Ubuntu\* 18.04 or later (64-bit)
7979
- Python\* 3.7 or later
80-
- NVidia CUDA\* Toolkit 10.2
81-
- PyTorch\* 1.7 or later.
80+
- NVidia CUDA\* Toolkit 10.2 or later^
81+
- PyTorch\* 1.5 or later (1.8.0 not supported, 1.8.1 supported)
82+
83+
*NOTE:* The best known PyTorch version for the current NNCF is 1.8.1, and it is highly recommended to use it.
84+
85+
^ If a torch package built for specific CUDA version is already present in the environment into which NNCF is being installed,
86+
and if it has a matching base version, then the CUDA version for which the present torch package is targeted will be used.
87+
88+
Otherwise NNCF will install the latest available torch version from pip, which is targeted to the CUDA version of PyTorch packaging strategy's choosing.
89+
For PyTorch 1.8.1, the default CUDA is 10.2.
8290

8391
## Installation
8492
We suggest to install or use the package in the [Python virtual environment](https://docs.python.org/3/tutorial/venv.html).
@@ -91,10 +99,8 @@ We suggest to install or use the package in the [Python virtual environment](htt
9199

92100
2) Install the package and its dependencies by running the following in the repository root directory:
93101

94-
- For CPU & GPU-powered execution:
95102
`python setup.py install`
96-
- For CPU-only installation
97-
`python setup.py install --cpu-only`
103+
98104

99105
_NB_: For launching example scripts in this repository, we recommend replacing the `install` option above with `develop` and setting the `PYTHONPATH` variable to the root of the checked-out repository.
100106

@@ -110,7 +116,7 @@ Use one of the Dockerfiles in the [docker](./docker) directory to build an image
110116

111117
**NOTE**: If you want to use sample training scripts provided in the NNCF repository under `examples`, you should install the corresponding Python package dependencies:
112118
```
113-
pip install examples/requirements.txt
119+
pip install -r examples/requirements.txt
114120
```
115121

116122
## Contributing
@@ -139,46 +145,49 @@ Quick jump to sample type:
139145

140146
|Model|Compression algorithm|Dataset|PyTorch FP32 baseline|PyTorch compressed accuracy|
141147
| :---: | :---: | :---: | :---: | :---: |
142-
|ResNet-50|INT8|ImageNet|76.04|75.97|
143-
|ResNet-50|Mixed, 44.8% INT8 / 55.2% INT4|ImageNet|76.04|76.31|
144-
|ResNet-50|INT8 + Sparsity 61% (RB)|ImageNet|76.04|75.21|
145-
|ResNet-50|INT8 + Sparsity 50% (RB)|ImageNet|76.04|75.73|
146-
|ResNet-50|Filter pruning, 40%, geometric median criterion|ImageNet|76.04|75.57|
147-
|Inception V3|INT8|ImageNet|77.31|76.97|
148-
|Inception V3|INT8 + Sparsity 61% (RB)|ImageNet|77.31|76.95|
149-
|MobileNet V2|INT8|ImageNet|71.75|71.32|
150-
|MobileNet V2|Mixed, 46.6% INT8 / 53.4% INT4|ImageNet|71.75|71.03|
151-
|MobileNet V2|INT8 + Sparsity 52% (RB)|ImageNet|71.75|70.94|
152-
|SqueezeNet V1.1|INT8|ImageNet|58.24|58.04|
153-
|SqueezeNet V1.1|Mixed, 54.7% INT8 / 45.3% INT4|ImageNet|58.24|58.77|
154-
|ResNet-18|XNOR (weights), scale/threshold (activations)|ImageNet|69.68|61.57|
155-
|ResNet-18|DoReFa (weights), scale/threshold (activations)|ImageNet|69.68|61.65|
156-
|ResNet-18|Filter pruning, 40%, magnitude criterion|ImageNet|69.68|69.19|
157-
|ResNet-18|Filter pruning, 40%, geometric median criterion|ImageNet|69.68|69.29|
158-
|ResNet-34|Filter pruning, 40%, geometric median criterion|ImageNet|73.26|72.72|
159-
|GoogLeNet|Filter pruning, 40%, geometric median criterion|ImageNet|69.72|68.89|
148+
|ResNet-50|INT8|ImageNet|76.16|76.42|
149+
|ResNet-50|INT8 (per-tensor only)|ImageNet|76.16|76.37|
150+
|ResNet-50|Mixed, 44.8% INT8 / 55.2% INT4|ImageNet|76.16|76.2|
151+
|ResNet-50|INT8 + Sparsity 61% (RB)|ImageNet|76.16|75.43|
152+
|ResNet-50|INT8 + Sparsity 50% (RB)|ImageNet|76.16|75.55|
153+
|ResNet-50|Filter pruning, 40%, geometric median criterion|ImageNet|76.16|75.62|
154+
|Inception V3|INT8|ImageNet|77.34|78.25|
155+
|Inception V3|INT8 + Sparsity 61% (RB)|ImageNet|77.34|77.58|
156+
|MobileNet V2|INT8|ImageNet|71.93|71.35|
157+
|MobileNet V2|INT8 (per-tensor only)|ImageNet|71.93|71.3|
158+
|MobileNet V2|Mixed, 46.6% INT8 / 53.4% INT4|ImageNet|71.93|70.92|
159+
|MobileNet V2|INT8 + Sparsity 52% (RB)|ImageNet|71.93|71.11|
160+
|SqueezeNet V1.1|INT8|ImageNet|58.24|58.28|
161+
|SqueezeNet V1.1|INT8 (per-tensor only)|ImageNet|58.24|58.26|
162+
|SqueezeNet V1.1|Mixed, 54.7% INT8 / 45.3% INT4|ImageNet|58.24|58.9|
163+
|ResNet-18|XNOR (weights), scale/threshold (activations)|ImageNet|69.8|61.63|
164+
|ResNet-18|DoReFa (weights), scale/threshold (activations)|ImageNet|69.8|61.61|
165+
|ResNet-18|Filter pruning, 40%, magnitude criterion|ImageNet|69.8|69.26|
166+
|ResNet-18|Filter pruning, 40%, geometric median criterion|ImageNet|69.8|69.32|
167+
|ResNet-34|Filter pruning, 40%, geometric median criterion|ImageNet|73.3|72.73|
168+
|GoogLeNet|Filter pruning, 40%, geometric median criterion|ImageNet|69.75|68.82|
160169

161170
#### Object detection
162171

163172
|Model|Compression algorithm|Dataset|PyTorch FP32 baseline|PyTorch compressed accuracy|
164173
| :---: | :---: | :---: | :---: | :---: |
165-
|SSD300-MobileNet|INT8 + Sparsity 70% (Magnitude)|VOC12+07 train, VOC12 eval|86.02|85.82|
166-
|SSD300-BN|INT8|VOC12+07 train, VOC12 eval|96.53|96.5|
167-
|SSD300-BN|INT8 + Sparsity 70% (Magnitude)|VOC12+07 train, VOC12 eval|96.53|95.4|
168-
|SSD300-BN|Filter pruning, 40%, geometric median criterion|VOC12+07 train, VOC12 eval|96.53|91.98|
169-
|SSD512-BN|INT8|VOC12+07 train, VOC12 eval|97.59|97.37|
170-
|SSD512-BN|INT8 + Sparsity 70% (Magnitude)|VOC12+07 train, VOC12 eval|97.59|96.66|
174+
|SSD300-MobileNet|INT8 + Sparsity 70% (Magnitude)|VOC12+07 train, VOC07 eval|62.23|62.94|
175+
|SSD300-VGG-BN|INT8|VOC12+07 train, VOC07 eval|78.28|77.96|
176+
|SSD300-VGG-BN|INT8 + Sparsity 70% (Magnitude)|VOC12+07 train, VOC07 eval|78.28|77.59|
177+
|SSD300-VGG-BN|Filter pruning, 40%, geometric median criterion|VOC12+07 train, VOC07 eval|78.28|77.72|
178+
|SSD512-VGG-BN|INT8|VOC12+07 train, VOC07 eval|80.26|80.12|
179+
|SSD512-VGG-BN|INT8 + Sparsity 70% (Magnitude)|VOC12+07 train, VOC07 eval|80.26|79.67|
171180

172181
#### Semantic segmentation
173182

174183
|Model|Compression algorithm|Dataset|PyTorch FP32 baseline|PyTorch compressed accuracy|
175184
| :---: | :---: | :---: | :---: | :---: |
176-
|UNet|INT8|CamVid|71.95|71.66|
177-
|UNet|INT8 + Sparsity 60% (Magnitude)|CamVid|71.95|71.72|
178-
|ICNet|INT8|CamVid|67.89|67.78|
179-
|ICNet|INT8 + Sparsity 60% (Magnitude)|CamVid|67.89|67.16|
180-
|UNet|INT8|Mapillary|56.23|56.1|
181-
|UNet|INT8 + Sparsity 60% (Magnitude)|Mapillary|56.23|56.01|
185+
|UNet|INT8|CamVid|71.95|71.8|
186+
|UNet|INT8 + Sparsity 60% (Magnitude)|CamVid|71.95|72.03|
187+
|ICNet|INT8|CamVid|67.89|67.86|
188+
|ICNet|INT8 + Sparsity 60% (Magnitude)|CamVid|67.89|67.18|
189+
|UNet|INT8|Mapillary|56.23|55.87|
190+
|UNet|INT8 + Sparsity 60% (Magnitude)|Mapillary|56.23|55.65|
182191
|UNet|Filter pruning, 25%, geometric median criterion|Mapillary|56.23|55.62|
183192

184193

ReleaseNotes.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ samples distributed with the code. The samples demonstrate the usage of compres
77
public models and datasets for three different use cases: Image Classification, Object Detection,
88
and Semantic Segmentation.
99

10+
## New in Release 1.7:
11+
- Adjust Padding feature to support accurate execution of U4 on VPU - when setting "target_device" to "VPU", the training-time padding values for quantized convolutions will be adjusted to better reflect VPU inference process.
12+
- Weighted layers that are "frozen" (i.e. have requires_grad set to False at compressed model creation time) are no longer considered for compression, to better handle transfer learning cases.
13+
- Quantization algorithm now sets up quantizers without giving an option for requantization, which guarantees best performance, although at some cost to quantizer configuration flexibility.
14+
- Pruning models with FCOS detection heads and instance normalization operations now supported
15+
- Added a mean percentile initializer for the quantization algorithm
16+
- Now possible to additionally quantize model outputs (separate control for each output quantization is supported)
17+
- Models quantized for CPU now use effective 7-bit quantization for weights - the ONNX-exported model is still configured to use 8 bits for quantization, but only the middle 128 quanta of the total possible 256 are actually used, which allows for better OpenVINO inference accuracy alignment with PyTorch on non-VNNI CPUs
18+
- Bumped target PyTorch version to 1.8.1 and relaxed package requirements constraints to allow installation into environments with PyTorch >=1.5.0
19+
20+
Notable bugfixes:
21+
- Fixed bias pruning in depthwise convolution
22+
- Made per-tensor quantization available for all operations that support per-channel quantization
23+
- Fixed progressive training performance degradation when an output tensor of an NNCF-compressed model is reused as its input.
24+
- `pip install .` path of installing NNCF from a checked-out repository is now supported.
25+
- Nested `with no_nncf_trace()` blocks now function as expected.
26+
- NNCF compression API now formally abstract to guard against virtual function calls
27+
- Now possible to load AutoQ and HAWQ-produced checkpoints to evaluate them or export to ONNX
28+
29+
Removed features:
30+
- Pattern-based quantizer setup mode for quantization algorithm - due to its logic, it did not guarantee that all required operation inputs are ultimately quantized.
31+
1032

1133
## New in Release 1.6:
1234
- Added AutoQ - an AutoML-based mixed-precision initialization mode for quantization, which utilizes the power of reinforcement learning to select the best quantizer configuration for any model in terms of quality metric for a given HW architecture type.

beta/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ Quick jump to the samples:
9090
|ResNet50|INT8 w:sym,per-tensor a:sym,per-tensor|ImageNet|75.04|75.04|
9191
|ResNet50|Sparsity 50% (Magnitude)|ImageNet|75.04|75|
9292
|ResNet50|INT8 w:sym,per-tensor a:sym,per-tensor + Sparsity 50% (Magnitude)|ImageNet|75.04|74.46|
93-
|TensorFlow Hub MobileNet V2|Sparsity 35% (Magnitude)|ImageNet|71.84|71.73|
93+
|ResNet50|Filter Pruning 40%|ImageNet|75.04|74.98|
94+
|TensorFlow Hub MobileNet V2|Sparsity 35% (Magnitude)|ImageNet|71.84|71.90|
9495

9596
#### Object detection
9697

9798
|**Model**|**Compression algorithm**|**Dataset**|**TensorFlow FP32 baseline mAP**|**TensorFlow compressed mAP**|
9899
| :---: | :---: | :---: | :---: | :---: |
99100
|RetinaNet|INT8 w:sym,per-tensor a:sym,per-tensor |COCO2017|33.44|33.3|
100101
|RetinaNet|Sparsity 50% (Magnitude)|COCO2017|33.44|33.13|
102+
|RetinaNet|Filter Pruning 40%|COCO2017|33.44|32.7|
101103

102104
#### Instance Segmentation
103105

beta/examples/tensorflow/classification/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@ To export a model to the OpenVINO IR and run it using the Intel® Deep Learning
111111
|ResNet50|INT8 w:sym,per-tensor a:sym,per-tensor|ImageNet|75.04|[resnet50_imagenet_int8.json](configs/quantization/resnet50_imagenet_int8.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/resnet50_int8_w_sym_t_a_sym_t.tar.gz)|
112112
|ResNet50|Sparsity 50% (Magnitude)|ImageNet|75|[resnet50_imagenet_magnitude_sparsity.json](configs/sparsity/resnet50_imagenet_magnitude_sparsity.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/resnet50_sparsity_50.tar.gz)|
113113
|ResNet50|INT8 w:sym,per-tensor a:sym,per-tensor + Sparsity 50% (Magnitude)|ImageNet|74.46|[resnet50_imagenet_magnitude_sparsity_int8.json](configs/sparsity_quantization/resnet50_imagenet_magnitude_sparsity_int8.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/resnet50_int8_w_sym_t_a_sym_t_sparsity_50.tar.gz)|
114-
|TensorFlow Hub MobileNet V2|Sparsity 35% (Magnitude)|ImageNet|71.73|[mobilenet_v2_hub_imagenet_magnitude_sparsity.json](configs/sparsity/mobilenet_v2_hub_imagenet_magnitude_sparsity.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/tf1_mobilenet_v2_1.0_224_s0.35.tar.gz)|
114+
|ResNet50|Filter Pruning 40%|ImageNet|74.98|[resnet50_imagenet_pruning_geometric_median.json](configs/pruning/resnet50_imagenet_pruning_geometric_median.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/resnet50_pruning_40.tar.gz)|
115+
|TensorFlow Hub MobileNet V2|Sparsity 35% (Magnitude)|ImageNet|71.90|[mobilenet_v2_hub_imagenet_magnitude_sparsity.json](configs/sparsity/mobilenet_v2_hub_imagenet_magnitude_sparsity.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/tf1_mobilenet_v2_1.0_224_s0.35.tar.gz)|
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"model": "ResNet50",
3+
"pretrained": true,
4+
"input_info": {
5+
"sample_size": [1, 224, 224, 3]
6+
},
7+
"batch_size": 320,
8+
"epochs": 65,
9+
"optimizer": {
10+
"type": "sgd",
11+
"schedule_type": "multistep",
12+
"schedule_params": {
13+
"base_lr": 0.1,
14+
"steps": [20, 40, 60],
15+
"gamma": 0.1
16+
},
17+
"optimizer_params": {
18+
"momentum": 0.9,
19+
"nesterov": true
20+
}
21+
},
22+
"dataset": "imagenet2012",
23+
"dataset_type": "tfds",
24+
25+
"compression": {
26+
"algorithm": "filter_pruning",
27+
"pruning_init": 0.1,
28+
"params": {
29+
"schedule": "exponential",
30+
"pruning_target": 0.4,
31+
"pruning_steps": 15,
32+
"weight_importance": "geometric_median"
33+
}
34+
}
35+
}

beta/examples/tensorflow/classification/configs/quantization/inception_v3_imagenet_int8.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"epochs": 10,
1010

1111
"optimizer": {
12-
"type": "adam",
12+
"type": "Adam",
1313
"schedule_type": "piecewise_constant",
1414
"schedule_params": {
1515
"boundaries": [5],

beta/examples/tensorflow/classification/configs/quantization/mobilenet_v2_imagenet_int8.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"epochs": 15,
1010

1111
"optimizer": {
12-
"type": "adam",
12+
"type": "Adam",
1313
"schedule_type": "piecewise_constant",
1414
"schedule_params": {
1515
"boundaries": [5, 10],

beta/examples/tensorflow/classification/configs/quantization/resnet50_imagenet_int8.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"batch_size": 128,
88
"epochs": 4,
99
"optimizer": {
10-
"type": "adam",
10+
"type": "Adam",
1111
"schedule_type": "piecewise_constant",
1212
"schedule_params": {
1313
"boundaries": [2],

beta/examples/tensorflow/classification/configs/sparsity/inception_v3_imagenet_magnitude_sparsity.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"epochs": 40,
1010

1111
"optimizer": {
12-
"type": "adam",
12+
"type": "Adam",
1313
"schedule_type": "piecewise_constant",
1414
"schedule_params": {
1515
"boundaries": [20, 25, 30],

0 commit comments

Comments
 (0)