Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh actions codecov #17

Merged
merged 23 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dc5ded2
Bump `numpy` version upper bound (#2202)
p-wysocki Oct 18, 2023
2878672
Add links to OneFormer and InstructPix2Pix notebooks (#2201)
l-bat Oct 18, 2023
f415d90
Added documentation for NF4 mode (#2194)
ljaljushkin Oct 23, 2023
5336405
[Torch] SE block HW fusing pattern is presented (#2177)
daniil-lyakhov Oct 24, 2023
d879361
[PTQ][Torch][KQV self attention] Align FQ placement between OV and To…
daniil-lyakhov Oct 24, 2023
7fcef07
Added ov_version parameter to the env tests (#2209)
KodiaqQ Oct 24, 2023
5e0837a
Do not test common code in backend-specific test targets (#2212)
vshampor Oct 24, 2023
8c10eea
Enable SmoothQuant only for OV backend (#2208)
andrey-churkin Oct 25, 2023
9cc57c0
[OV] Add caching of OMZ models (#2214)
l-bat Oct 25, 2023
d264494
QuantizationPreset.MIXED for ModelType.TRANSFORMER by default (#2216)
alexsu52 Oct 25, 2023
7412ac0
Updated reference for 2023.2.0-12979-04c766e9f17 (#2219)
ljaljushkin Oct 26, 2023
faf687c
Using ov.save_model(...) in PTQ examples (#2156)
alexsu52 Oct 26, 2023
4f0a6de
[PTQ] Remove insert_null_biases pass (#2217)
KodiaqQ Oct 26, 2023
76bb1f0
Fix index out of range (#2224)
andrey-churkin Oct 26, 2023
218cb6b
Added `keepdims` argument for min,max functions (#2225)
ljaljushkin Oct 27, 2023
729f6cc
[PTQ] Avg pool is added as ignored metatype for TRANSFORMER model_typ…
daniil-lyakhov Oct 27, 2023
da16069
Remove pylint (#2205)
vshampor Oct 27, 2023
d299726
Use torch 2.1 and remove torch 1.13 (#2211)
vshampor Oct 30, 2023
22004dc
[Graph visualization] Reserved dot symbols are replaced for each grap…
daniil-lyakhov Oct 30, 2023
62e73f4
[ONNX][OV] Update SE block pattern (#2229)
kshpv Oct 30, 2023
b7fb574
Fix github actions codecov uploader for ONNX
ksilligan Oct 30, 2023
d28ee0e
Fix github actions codecov uploader for ONNX and COMMON
ksilligan Nov 2, 2023
26d6ed7
Update upload_coverage_for_develop.yml
ksilligan Nov 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/post_pr_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
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_common
coverage_flags: COMMON
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
upload-coverage-onnx:
Expand All @@ -33,5 +34,6 @@ jobs:
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_onnx
coverage_flags: ONNX
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: coverage_common
flags: COMMON
onnx:
runs-on: ubuntu-20.04
steps:
Expand All @@ -58,4 +59,5 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: coverage_onnx
flags: ONNX

5 changes: 4 additions & 1 deletion .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
coverage_flags:
required: true
type: string
secrets:
CODECOV_TOKEN:
required: true
Expand All @@ -37,4 +40,4 @@ jobs:

# 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 ${{ inputs.merge_commit_sha }} -B develop -n "${{ inputs.coverage_artifact_name_in_pr }}"
./codecov -f ./coverage.xml -t ${{ secrets.CODECOV_TOKEN }} -F ${{ inputs.coverage_flags }} -C ${{ inputs.merge_commit_sha }} -B develop -n "${{ inputs.coverage_artifact_name_in_pr }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ ENV/
# snapshots
*.tar

# pylint config is left at dev's discretion, CI uses ruff/isort/black instead
.pylintrc

# VSCode
.vscode/

Expand Down
52 changes: 0 additions & 52 deletions .pylintrc

This file was deleted.

9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ If your testing code is more extensive than unit tests (in terms of test executi

Changes to NNCF Python code should conform to [Python Style Guide](./docs/styleguide/PyGuide.md)

Pylint is used throughout the project to ensure code cleanliness and quality.
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.
The Pylint rules and exceptions for this repository are described in the standard [.pylintrc](./.pylintrc) format - make sure your local linter uses these.
Basic code style and static checks are enforced using a `pre-commit` Github action.
The exact checks that are run are described in the corresponding [config file](./.pre-commit-config.yaml).
The checks can be run locally using `make pre-commit`.
Most of these checks do in-place fixes at the same time they are run using `make pre-commit`.
Static analysis is done via `ruff` which does not do in-place fixes by default - run `ruff --fix` locally to autofix errors for which it is possible to do so.
Developers may use other tools locally (such as `pylint`) as long as no tool-specific control code is introduced and the pre-commit checks pass.

## Binary files

Expand Down
36 changes: 6 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ endif
install-pre-commit:
pip install pre-commit==3.2.2

install-pylint:
pip install pylint==2.13.9
pip install pylintfileheader==0.3.2

###############################################################################
# ONNX backend
Expand All @@ -31,15 +28,12 @@ install-onnx-test:
pip install -r tests/cross_fw/examples/requirements.txt
pip install -r tests/onnx/benchmarking/requirements.txt

install-onnx-dev: install-onnx-test install-pre-commit install-pylint
install-onnx-dev: install-onnx-test install-pre-commit
pip install -r examples/post_training_quantization/onnx/mobilenet_v2/requirements.txt

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

pylint-onnx:
pylint --rcfile .pylintrc \
$(shell python3 tools/collect_pylint_input_files_for_backend.py onnx)

test-install-onnx:
pytest tests/cross_fw/install -s \
Expand All @@ -60,7 +54,7 @@ install-openvino-test:
pip install -r tests/cross_fw/install/requirements.txt
pip install -r tests/cross_fw/examples/requirements.txt

install-openvino-dev: install-openvino-test install-pre-commit install-pylint
install-openvino-dev: install-openvino-test install-pre-commit
pip install -r examples/experimental/openvino/bert/requirements.txt
pip install -r examples/experimental/openvino/yolo_v5/requirements.txt
pip install -r examples/post_training_quantization/openvino/mobilenet_v2/requirements.txt
Expand All @@ -71,10 +65,6 @@ install-openvino-dev: install-openvino-test install-pre-commit install-pylint
test-openvino:
pytest ${COVERAGE_ARGS} tests/openvino $(DATA_ARG) --junitxml ${JUNITXML_PATH}

pylint-openvino:
pylint --rcfile .pylintrc \
$(shell python3 tools/collect_pylint_input_files_for_backend.py openvino)

test-install-openvino:
pytest tests/cross_fw/install -s \
--backend openvino \
Expand All @@ -95,18 +85,14 @@ install-tensorflow-test:
pip install -r tests/cross_fw/examples/requirements.txt
pip install -r examples/tensorflow/requirements.txt

install-tensorflow-dev: install-tensorflow-test install-pre-commit install-pylint
install-tensorflow-dev: install-tensorflow-test install-pre-commit
pip install -r examples/post_training_quantization/tensorflow/mobilenet_v2/requirements.txt

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

pylint-tensorflow:
pylint --rcfile .pylintrc \
$(shell python3 tools/collect_pylint_input_files_for_backend.py tensorflow)

test-install-tensorflow:
pytest tests/cross_fw/install -s --backend tf --junitxml ${JUNITXML_PATH}

Expand All @@ -123,25 +109,19 @@ install-torch-test:
pip install -r tests/cross_fw/examples/requirements.txt
pip install -r examples/torch/requirements.txt --index-url https://download.pytorch.org/whl/cu118 --extra-index-url=https://pypi.org/simple

install-torch-dev: install-torch-test install-pre-commit install-pylint
install-torch-dev: install-torch-test install-pre-commit
pip install -r examples/post_training_quantization/torch/mobilenet_v2/requirements.txt
pip install -r examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt

test-torch:
pytest ${COVERAGE_ARGS} tests/common tests/torch -m "not weekly and not nightly" --junitxml ${JUNITXML_PATH} $(DATA_ARG)
pytest ${COVERAGE_ARGS} 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:
pylint --rcfile .pylintrc \
$(COMMON_PYFILES) \
$(shell python3 tools/collect_pylint_input_files_for_backend.py torch)

test-install-torch-cpu:
pytest tests/cross_fw/install -s \
--backend torch \
Expand All @@ -167,10 +147,6 @@ install-common-test:
pip install -r tests/cross_fw/install/requirements.txt
pip install -r tests/cross_fw/examples/requirements.txt

pylint-common:
pylint --rcfile .pylintrc \
$(COMMON_PYFILES)

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

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ A collection of ready-to-run Jupyter* notebooks are available to demonstrate how
- [NNCF Post-Training Optimization of BLIP Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/233-blip-visual-language-processing)
- [NNCF Post-Training Optimization of DeepFloyd IF Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/238-deepfloyd-if)
- [NNCF Post-Training Optimization of Grammatical Error Correction Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/214-grammar-correction)
- [NNCF Post-Training Optimization of Dolly 2.0 Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/240-dolly-2-instruction-following)
- [NNCF Post-Training Optimization of Massively Multilingual Speech Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/255-mms-massively-multilingual-speech)
- [NNCF Post-Training Optimization of OneFormer Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/249-oneformer-segmentation)
- [NNCF Post-Training Optimization of InstructPix2Pix Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/231-instruct-pix2pix-image-editing)
- [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)
Expand Down Expand Up @@ -375,7 +379,7 @@ You may also use one of the Dockerfiles in the [docker](./docker) directory to b
- 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.8) and TensorFlow* 2.12.1 (NVidia CUDA\* Toolkit 11.8).
This repository is tested on Python* 3.8.10, PyTorch* 2.1.0 (NVidia CUDA\* Toolkit 11.8) and TensorFlow* 2.12.1 (NVidia CUDA\* Toolkit 11.8).

## NNCF Compressed Model Zoo

Expand Down
11 changes: 6 additions & 5 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ Use one of the Dockerfiles in the [docker](../docker) directory to build an imag
The following table lists the recommended corresponding versions of backend packages
as well as the supported versions of Python:

| NNCF | OpenVINO | PyTorch | ONNX | TensorFlow | Python |
| ------- | ---------- | -------- | -------- | ---------- | ------- |
| `2.6.0` | `2023.1.0` | `2.0.1` | `1.13.1` | `2.12.0` | `3.8` |
| `2.5.0` | `2023.0.0` | `1.13.1` | `1.13.1` | `2.11.1` | `3.8` |
| `2.4.0` | `2022.1.0` | `1.12.1` | `1.12.0` | `2.8.2` | `3.8` |
| NNCF | OpenVINO | PyTorch | ONNX | TensorFlow | Python |
|-----------|------------|----------|----------|------------|--------|
| `develop` | `2023.1.0` | `2.1` | `1.13.1` | `2.12.0` | `3.8` |
| `2.6.0` | `2023.1.0` | `2.0.1` | `1.13.1` | `2.12.0` | `3.8` |
| `2.5.0` | `2023.0.0` | `1.13.1` | `1.13.1` | `2.11.1` | `3.8` |
| `2.4.0` | `2022.1.0` | `1.12.1` | `1.12.0` | `2.8.2` | `3.8` |
7 changes: 3 additions & 4 deletions docs/api/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def __init__(self):
self.canonical_name_vs_fqn: Dict[str, str] = {}


# pylint: disable=too-many-branches
def collect_api_entities() -> APIInfo:
"""
Collects the fully qualified names of symbols in NNCF package that contain a special attribute (set via
Expand All @@ -73,21 +72,21 @@ def collect_api_entities() -> APIInfo:
for _, modname, _ in pkgutil.walk_packages(path=nncf.__path__, prefix=nncf.__name__ + ".", onerror=lambda x: None):
try:
modules[modname] = importlib.import_module(modname)
except Exception as e: # pylint: disable=broad-except
except Exception as e:
skipped_modules[modname] = str(e)

from nncf.common.utils.api_marker import api

canonical_imports_seen = set()
# pylint: disable=too-many-nested-blocks

for modname, module in modules.items():
print(f"{modname}")
for obj_name, obj in inspect.getmembers(module):
objects_module = getattr(obj, "__module__", None)
if objects_module == modname:
if inspect.isclass(obj) or inspect.isfunction(obj):
if hasattr(obj, api.API_MARKER_ATTR):
marked_object_name = obj._nncf_api_marker # pylint: disable=protected-access
marked_object_name = obj._nncf_api_marker
# Check the actual name of the originally marked object
# so that the classes derived from base API classes don't
# all automatically end up in API
Expand Down
29 changes: 28 additions & 1 deletion docs/compression_algorithms/CompressWeights.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,44 @@

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.

##### INT8 and NF4 modes

By default, weights are compressed to 8-bit integer data type - "INT8" mode.
OpenVINO backend has also an experimental support for "NF4" mode - compression to [nf4](https://arxiv.org/pdf/2305.14314v1.pdf) data type.
It goes with a grouped quantization, when small group of weights (e.g. 128) in the channel dimension share quantization parameters (scale).
First embedding and last linear layers are always compressed to 8-bit integer data type in the "NF4" mode.
Percent of the rest layers compressed to NF4 can be configured by "ratio" parameter.
E.g. ratio=0.9 means 90% of layers compressed to nf4 and the rest to 8-bit integer data type.

#### User guide

- Compress weights of linear layers and embeddings to int8
- Compress weights to 8-bit integer data type.

```python
from nncf import compress_weights
compressed_model = compress_weights(model)
```

- Compress weights to nf4 data type with group size = 128, except first embedding and last linear layers - they are compressed to 8-bit integer data type.

```python
from nncf import compress_weights
from nncf import CompressWeightsMode
compressed_model = compress_weights(model, mode=CompressWeightsMode.NF4)
```

- Compress weights of 90% of layers to nf4 with the group size 64, and the rest of layers to 8-bit integer data type.

```python
from nncf import compress_weights
from nncf import CompressWeightsMode
compressed_model = compress_weights(model, mode=CompressWeightsMode.NF4, group_size=64, ratio=0.9)
```

##### Limitations

- The algorithm is supported for OpenVINO and PyTorch models.
- The compression applies in-place.
- The compressed model is not trainable.
- NF4 mode, grouped quantization and mixed nf4-int8 precision selection is available for OpenVINO backend only.
- NF4 support is experimental - models quantized to nf4 should not be faster models quantized to 8-bit integer.
Loading
Loading