Skip to content

Commit

Permalink
Merge branch 'openvinotoolkit:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ksilligan authored Sep 24, 2023
2 parents 1de3440 + b95e71c commit 8c7fb94
Show file tree
Hide file tree
Showing 619 changed files with 97,303 additions and 424,422 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/api_changes_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,15 @@ jobs:
repo: context.repo.repo,
labels: ["API"]
})
- name: Add release label
uses: actions/github-script@v6
if: ${{ contains(github.event.pull_request.base.ref, 'release_v') }}
with:
github-token: ${{ secrets.ADD_LABELS_WITH_REST_API }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["release_target"]
})
8 changes: 6 additions & 2 deletions .github/workflows/post_pr_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ jobs:
with:
merge_commit_sha: ${{ github.event.pull_request.merge_commit_sha }}
last_sha_in_pr: ${{ github.event.pull_request.head.sha }}
coverage_artifact_name_in_pr: coverage_xml_common
coverage_artifact_name_in_pr: coverage_common
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
upload-coverage-onnx:
if: github.event.pull_request.merged == true
uses: ./.github/workflows/upload_coverage_for_develop.yml
with:
merge_commit_sha: ${{ github.event.pull_request.merge_commit_sha }}
last_sha_in_pr: ${{ github.event.pull_request.head.sha }}
coverage_artifact_name_in_pr: coverage_xml_onnx
coverage_artifact_name_in_pr: coverage_onnx
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
12 changes: 8 additions & 4 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ jobs:
run: make install-common-test
- name: Run common precommit test scope
run: make test-common
env:
NNCF_COVERAGE: 1
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v3
with:
name: coverage_xml_common
name: coverage_common
path: ./coverage.xml
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-common
name: coverage_common
onnx:
runs-on: ubuntu-20.04
steps:
Expand All @@ -44,14 +46,16 @@ jobs:
run: make install-onnx-test
- name: Run ONNX precommit test scope
run: make test-onnx
env:
NNCF_COVERAGE: 1
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v3
with:
name: coverage_xml_onnx
name: coverage_onnx
path: ./coverage.xml
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-onnx
name: coverage_onnx

11 changes: 7 additions & 4 deletions .github/workflows/upload_coverage_for_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
coverage_artifact_name_in_pr:
required: true
type: string
secrets:
CODECOV_TOKEN:
required: true

jobs:
upload-coverage:
Expand All @@ -20,18 +23,18 @@ jobs:
steps:
- uses: actions/checkout@v3 # codecov uploader demands that the scanned files be present when uploading
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
ref: ${{ inputs.merge_commit_sha }}
- uses: dawidd6/action-download-artifact@v2
with:
workflow: precommit.yml
check_artifacts: true
commit: ${{ github.event.pull_request.head.sha }} # this is the latest commit in the PR
name: coverage_xml
commit: ${{ inputs.last_sha_in_pr }} # this is the latest commit in the PR
name: ${{ inputs.coverage_artifact_name_in_pr }}
- name: Upload coverage report to Codecov
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
# github.event.pull_request.merge_commit_sha is the fresh commit in the develop,
# provided that github.event.pull_request.merged == true
./codecov -f ./coverage.xml -t ${{ secrets.CODECOV_TOKEN }} -C ${{ github.event.pull_request.merge_commit_sha }} -B develop -n "codecov-onnx"
./codecov -f ./coverage.xml -t ${{ secrets.CODECOV_TOKEN }} -C ${{ inputs.merge_commit_sha }} -B develop -n "${{ inputs.coverage_artifact_name_in_pr }}"
30 changes: 21 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
JUNITXML_PATH ?= nncf-tests.xml
COVERAGE ?= --cov=./ --cov-report=xml

ifdef NNCF_COVERAGE
COVERAGE_ARGS ?= --cov=./ --cov-report=xml
else
COVERAGE_ARGS :=
endif

ifdef DATA
DATA_ARG := --data $(DATA)
endif

ifdef WEEKLY_MODELS
WEEKLY_MODELS_ARG := --weekly-models $(WEEKLY_MODELS)
endif

install-pre-commit:
pip install pre-commit==3.2.2

Expand All @@ -26,7 +35,7 @@ install-onnx-dev: install-onnx-test install-pre-commit install-pylint
pip install -r examples/post_training_quantization/onnx/mobilenet_v2/requirements.txt

test-onnx:
pytest ${COVERAGE} tests/onnx $(DATA_ARG) --junitxml ${JUNITXML_PATH}
pytest ${COVERAGE_ARGS} tests/onnx $(DATA_ARG) --junitxml ${JUNITXML_PATH}

pylint-onnx:
pylint --rcfile .pylintrc \
Expand Down Expand Up @@ -60,8 +69,7 @@ install-openvino-dev: install-openvino-test install-pre-commit install-pylint
pip install -r examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt

test-openvino:
# omitting ${COVERAGE} for internal runs since they seem to introduce a major slowdown
pytest tests/openvino $(DATA_ARG) --junitxml ${JUNITXML_PATH}
pytest ${COVERAGE_ARGS} tests/openvino $(DATA_ARG) --junitxml ${JUNITXML_PATH}

pylint-openvino:
pylint --rcfile .pylintrc \
Expand Down Expand Up @@ -91,8 +99,7 @@ install-tensorflow-dev: install-tensorflow-test install-pre-commit install-pylin
pip install -r examples/post_training_quantization/tensorflow/mobilenet_v2/requirements.txt

test-tensorflow:
# omitting ${COVERAGE} for internal runs since they seem to introduce a major slowdown
pytest tests/common tests/tensorflow \
pytest ${COVERAGE_ARGS} tests/common tests/tensorflow \
--junitxml ${JUNITXML_PATH} \
$(DATA_ARG)

Expand Down Expand Up @@ -121,8 +128,13 @@ install-torch-dev: install-torch-test install-pre-commit install-pylint
pip install -r examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt

test-torch:
# omitting ${COVERAGE} for internal runs since they seem to introduce a major slowdown
pytest tests/common tests/torch --junitxml ${JUNITXML_PATH} $(DATA_ARG)
pytest ${COVERAGE_ARGS} tests/common tests/torch -m "not weekly and not nightly" --junitxml ${JUNITXML_PATH} $(DATA_ARG)

test-torch-nightly:
pytest ${COVERAGE_ARGS} tests/torch -m nightly --junitxml ${JUNITXML_PATH} $(DATA_ARG)

test-torch-weekly:
pytest ${COVERAGE_ARGS} tests/torch -m weekly --junitxml ${JUNITXML_PATH} $(DATA_ARG) ${WEEKLY_MODELS_ARG}

COMMON_PYFILES := $(shell python3 tools/collect_pylint_input_files_for_backend.py common)
pylint-torch:
Expand Down Expand Up @@ -160,7 +172,7 @@ pylint-common:
$(COMMON_PYFILES)

test-common:
pytest ${COVERAGE} tests/common $(DATA_ARG) --junitxml ${JUNITXML_PATH}
pytest ${COVERAGE_ARGS} tests/common $(DATA_ARG) --junitxml ${JUNITXML_PATH}

test-examples:
pytest tests/cross_fw/examples -s --junitxml ${JUNITXML_PATH}
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ learning frameworks.
| Compression algorithm |OpenVINO|PyTorch| TensorFlow | ONNX |
|:----------------------------------------------------------------------------| :---: | :---: |:--------:|:------------------:|
| [Post-Training Quantization](./docs/compression_algorithms/post_training/Quantization.md) | Supported | Supported |Supported| Supported |
| [Weights Compression](./docs/compression_algorithms/CompressWeights.md) | Not supported | Supported |Not supported| Not supported |
| [Weights Compression](./docs/compression_algorithms/CompressWeights.md) | Supported | Supported |Not supported| Not supported |

### Training-Time Compression Algorithms

Expand Down Expand Up @@ -280,13 +280,15 @@ A collection of ready-to-run Jupyter* notebooks are available to demonstrate how
- [NNCF Post-Training Optimization of Segment Anything Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/237-segment-anything)
- [NNCF Post-Training Optimization of CLIP Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/228-clip-zero-shot-image-classification)
- [NNCF Post-Training Optimization of ImageBind Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/239-image-bind)
- [NNCF Post-Training Optimization of Whisper Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/227-whisper-subtitles-generation)
- [Quantize a Segmentation Model and Show Live Inference](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/110-ct-segmentation-quantize)
- [Training to Deployment with TensorFlow and OpenVINO](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/301-tensorflow-training-openvino)
- [Migrate quantization from POT API to NNCF API](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/111-yolov5-quantization-migration)
- [Post-Training Quantization of Pytorch model with NNCF](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/112-pytorch-post-training-quantization-nncf)
- [Optimizing PyTorch models with NNCF of OpenVINO by 8-bit quantization](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/302-pytorch-quantization-aware-training)
- [Optimizing TensorFlow models with NNCF of OpenVINO by 8-bit quantization](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/305-tensorflow-quantization-aware-training)
- [Accelerate Inference of Sparse Transformer Models with OpenVINO and 4th Gen Intel Xeon Scalable Processors](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/116-sparsity-optimization)
- [Quantization with accuracy control using NNCF](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/122-quantizing-model-with-accuracy-control)

### Post-Training Quantization Samples

Expand Down Expand Up @@ -366,11 +368,11 @@ You may also use one of the Dockerfiles in the [docker](./docker) directory to b
- Python\* 3.7 or later
- Supported frameworks:
- PyTorch\* >=1.13.0, <2.1
- TensorFlow\* >=2.4.0, <=2.12.0
- TensorFlow\* >=2.8.4, <=2.12.1
- ONNX\* ~=1.13.1
- OpenVINO\* >=2022.3.0

This repository is tested on Python* 3.8.10, PyTorch* 2.0.1 (NVidia CUDA\* Toolkit 11.7) and TensorFlow* 2.12.0 (NVidia CUDA\* Toolkit 11.8).
This repository is tested on Python* 3.8.10, PyTorch* 2.0.1 (NVidia CUDA\* Toolkit 11.7) and TensorFlow* 2.12.1 (NVidia CUDA\* Toolkit 11.8).

## NNCF Compressed Model Zoo

Expand Down
60 changes: 60 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
# Release Notes

## New in Release 2.6.0

Post-training Quantization:

- Features:
- Added `CPU_SPR` device type support.
- Added quantizers scales unification.
- Added quantization scheme for ReduceSum operation.
- Added new types (ReduceL2, ReduceSum, Maximum) to the ignored scope for `ModelType.Transformer`.
- (OpenVINO) Added SmoothQuant algorithm.
- (OpenVINO) Added ChannelAlignment algorithm.
- (OpenVINO) Added HyperparameterTuner algorithm.
- (PyTorch) Added FastBiasCorrection algorithm support.
- (OpenVINO, ONNX) Added embedding weights quantization.
- (OpenVINO, PyTorch) Added new `compress_weights` method that provides data-free [INT8 weights compression](docs/compression_algorithms/CompressWeights.md).
- Fixes:
- Fixed detection of decomposed post-processing in models.
- Multiple fixes (new patterns, bugfixes, etc.) to solve [#1936](https://github.com/openvinotoolkit/nncf/issues/1936) issue.
- Fixed model reshaping while quantization to keep original model shape.
- (OpenVINO) Added support for sequential models quanitzation.
- (OpenVINO) Fixed in-place statistics cast to support empty dimensions.
- (OpenVINO, ONNX) Fixed quantization of the MatMul operation with weights rank > 2.
- (OpenVINO, ONNX) Fixed BiasCorrection algorithm to enable [CLIP model quantization](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/228-clip-zero-shot-image-classification).
- Improvements:
- Optimized `quantize(…)` pipeline (up to 4.3x speed up in total).
- Optimized `quantize_with_accuracy_control(…)` pipelilne (up to 8x speed up for [122-quantizing-model-with-accuracy-control](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/122-quantizing-model-with-accuracy-control) notebook).
- Optimized general statistics collection (up to 1.2x speed up for ONNX backend).
- Ignored patterns separated from Fused patterns scheme (with multiple patterns addition).
- Tutorials:
- [Post-Training Optimization of Segment Anything Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/237-segment-anything).
- [Post-Training Optimization of CLIP Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/228-clip-zero-shot-image-classification).
- [Post-Training Optimization of ImageBind Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/239-image-bind).
- [Post-Training Optimization of Whisper Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/227-whisper-subtitles-generation).
- [Post-Training Optimization with accuracy control](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/122-quantizing-model-with-accuracy-control).

Compression-aware training:

- Features:
- Added shape pruning processor for BootstrapNAS algorithm.
- Added KD loss for BootstrapNAS algorithm.
- Added `validate_scopes` parameter for NNCF configuration.
- (PyTorch) Added PyTorch 2.0 support.
- (PyTorch) Added `.strip()` option to API.
- (PyTorch) Enabled bfloat data type for quantization kernels.
- (PyTorch) Quantized models can now be `torch.jit.trace`d without calling `.strip()`.
- (PyTorch) Added support for overridden `forward` instance attribute on model objects passed into `create_compressed_model`.
- (Tensorflow) Added Tensorflow 2.12 support.
- Fixes:
- (PyTorch) Fixed padding adjustment issue in the elastic kernel to work with the different active kernel sizes.
- (PyTorch) Fixed the torch graph tracing in the case the tensors belonging to parallel edges are interleaved in the order of the tensor argument.
- (PyTorch) Fixed recurrent nodes matching (LSTM, GRU cells) condition with the strict rule to avoid adding not necessary nodes to the ignored scope.
- (PyTorch) Fixed `torch.jit.script` wrapper so that user-side handling exceptions during `torch.jit.script` invocation do not cause NNCF to be permanently disabled.
- (PyTorch, Tensorflow) Adjusted quantizer propagation algorithm to check if quantizer propagation will result in output quantization.
- (PyTorch) Added redefined `__class__` method for ProxyModule that avoids causing error while calling `.super()` in forward method.
- Deprecations/Removals:
- (PyTorch) Removed deprecated `NNCFNetwork.__getattr__`, `NNCFNetwork.get_nncf_wrapped_model` methods.
- Requirements:
- Updated PyTorch version (2.0.1).
- Updated Tensorflow version (2.12.0).

## New in Release 2.5.0

Post-training Quantization:
Expand Down
12 changes: 7 additions & 5 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ ignore:
- "tests"
- "tools"

#codecov:
# notify:
# after_n_builds: 4
# wait_for_ci: yes
codecov:
notify:
after_n_builds: 2
wait_for_ci: no
max_report_age: off

coverage:
status:
Expand All @@ -25,7 +26,8 @@ coverage:
informational: true
only_pulls: true
paths:
- "nncf/onnx" # extend this once we collect coverage reports for more than just onnx part of precommit
- "nncf/onnx"
- "nncf/common" # extend this once we collect coverage reports for more than just onnx and common part of precommit

comment:
layout: "diff, flags, files"
Expand Down
13 changes: 4 additions & 9 deletions docs/compression_algorithms/CompressWeights.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
### Weights Compression

[OpenVINO](https://github.com/openvinotoolkit/openvino) is the preferred backend to run Weights Compression with, and PyTorch is also supported.

#### The algorithm description

The Weights Compression algorithm is aimed at compressing the weights of the models and can be used to optimize the model footprint and performance of large models where the size of weights is relatively larger than the size of activations, for example, Large Language Models (LLM). The algorithm compresses weights only for Linear and Embedding layers. It is also possible to keep the precision of the original weights and insert FakeQuantize operations by setting `use_fake_quantize` parameter to `True`.
The Weights Compression algorithm is aimed at compressing the weights of the models and can be used to optimize the model footprint and performance of large models where the size of weights is relatively larger than the size of activations, for example, Large Language Models (LLM). The algorithm compresses weights only for Linear and Embedding layers.

#### User guide

Expand All @@ -13,15 +15,8 @@ from nncf import compress_weights
compressed_model = compress_weights(model)
```

- Insert FakeQuantize layers for weights of linear layers and embeddings

```python
from nncf import compress_weights
model_with_fake_quantize = compress_weights(model, use_fake_quantize=True)
```

##### Limitations

- The algorithm is supported for PyTorch only.
- The algorithm is supported for OpenVINO and PyTorch models.
- The compression applies in-place.
- The compressed model is not trainable.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ scikit-learn
fastdownload
onnx~=1.13.1
onnxruntime~=1.14.1
openvino-dev==2023.0.1
openvino-dev==2023.1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
anomalib==0.6.0
openvino-dev==2023.0.1
openvino-dev==2023.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ torchvision
tqdm
scikit-learn
fastdownload
openvino-dev==2023.0.1
openvino-dev==2023.1
Loading

0 comments on commit 8c7fb94

Please sign in to comment.