Skip to content

Commit

Permalink
Add markdownlint to pre-commit (#1996)
Browse files Browse the repository at this point in the history
### Changes

Add [markdownlint](https://github.com/DavidAnson/markdownlint) check to
pre-commit

Fixed: 

- Incorrect links
- Ordered lists
- Blank lines before and after headers and code blocks
- Types for code blocks
- Trailing spaces
- Spellcheck
- Removed module-timm_custom_modules from api doc
  • Loading branch information
AlexanderDokuchaev authored Jul 26, 2023
1 parent 76727f2 commit aac4d77
Show file tree
Hide file tree
Showing 51 changed files with 1,109 additions and 821 deletions.
9 changes: 9 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Default state for all rules
default: true

MD013: false # Line length
MD033: false # Inline HTML
MD034: false # Bare URL used
MD036: false # Emphasis used instead of a heading
MD037: false # Spaces inside emphasis markers
MD041: false # First line
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ repos:
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
hooks:
- id: markdownlint
args: [--config=.markdownlint.yaml]
40 changes: 11 additions & 29 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
# Contributing to NNCF

Contributions are accepted in the form of:

* Submitting issues against the current code to report bugs or request features
* Extending NNCF functionality with important features (e.g. to address community requests, improve usability, implement a recently published compression algorithm, etc.)
* Adding example scripts to showcase NNCF usage in real training pipelines and provide the means to reproduce the reported compression results
* Providing recipes (specific NNCF configurations and training hyperparameters) to obtain state-of-the-art compression using NNCF for existing models
* Adding well-defined patches that integrate NNCF into third-party repositories
* Reducing performance overhead of NNCF compression by writing specialized CUDA kernels for compression operations or improving existing ones.
* Reducing performance overhead of NNCF compression by writing specialized CUDA kernels for compression operations or improving existing ones.

The latter forms are accepted as pull requests from your own forks of the NNCF repository.

Any contributions must not violate the repository's [LICENSE](./LICENSE) requirements.

## Installation
### (Experimental) ONNXRuntime-OpenVINO
Install the package and its dependencies by running the following in the repository root directory:
```bash
make install-onnx-dev
```

## Testing

After your pull request is submitted, the maintainer will launch a scope of CI tests against it.
Expand All @@ -28,42 +22,30 @@ The pre-commit scope may be run locally by executing the `pytest` command (witho
Please run the pre-commit testing scope locally before submitting your PR and ensure that it passes to conserve your own time and that of the reviewing maintainer.

New feature pull requests should include all the necessary testing code.
Testing is done using the `pytest` framework.
Testing is done using the `pytest` framework.
The test files should be located inside the [tests](./tests) directory and start with `test_` so that the `pytest` is able to discover them.
Any additional data that is required for tests (configuration files, mock datasets, etc.) must be stored within the [tests/data](./tests/data) folder.
The test files themselves may be grouped in arbitrary directories according to their testing purpose and common sense.

Any additional tests in the [tests](./tests) directory will be automatically added into the pre-commit CI scope.
Any additional tests in the [tests](./tests) directory will be automatically added into the pre-commit CI scope.
If your testing code is more extensive than unit tests (in terms of test execution time), or would be more suited to be executed on a nightly/weekly basis instead of for each future commit, please inform the maintainers in your PR discussion thread so that our internal testing pipelines could be adjusted accordingly.

### Preset command for testing
You can launch appropriate tests against the framework by running the following command:

- (Experimental) ONNXRuntime-OpenVINO
```bash
test-onnx
```

## Code style

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.
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.

### Preset command for linting
You can launch appropriate linting against the framework by running the following command:

- (Experimental) ONNXRuntime-OpenVINO
```bash
pylint-onnx
```

## Binary files
Please refrain from adding huge binary files into the repository. If binary files have to be added, mark these to use Git LFS via the [.gitattributes](./.gitattributes) file.

Please refrain from adding huge binary files into the repository. If binary files have to be added, mark these to use Git LFS via the [.gitattributes](./.gitattributes) file.

## Model identifiers

When adding model configs and checkpoints to be showcased in NNCF's sample script, follow the format for naming these files:

1. The base name must be the same for the NNCF config file, AC config file, checkpoint file (PT/ONNX/OV) or checkpoint folder (TF), and other associated artifacts.
2. This name should be composed with the following format: `{model_name}_{dataset_name}` for FP32 models, `{topology_name}_{dataset_name}_{compression_algorithms_applied}`. The format may be extended if there are multiple models with the same topology, dataset and compression algos applied, which only differ in something else such as exact value of achieved sparsity. Align the naming of the new checkpoints with the existing ones.
3. Additional human-readable information on the model such as expected metrics and compression algorithm specifics (e.g. level of pruning/sparsity, per-tensor/per-channel quantizer configuration etc.) should be stored in a registry file (`tests/torch/sota_checkpoints_eval.json` for PT, `tests/tensorflow/sota_checkpoints_eval.json` for TF)
3. Additional human-readable information on the model such as expected metrics and compression algorithm specifics (e.g. level of pruning/sparsity, per-tensor/per-channel quantizer configuration etc.) should be stored in a registry file (`tests/torch/sota_checkpoints_eval.json` for PT, `tests/tensorflow/sota_checkpoints_eval.json` for TF)
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Neural Network Compression Framework (NNCF)

[Key Features](#key-features)
[Installation](#Installation-guide)
[Installation](#installation-guide)
[Documentation](#documentation)
[Usage](#usage)
[Tutorials and Samples](#Model-compression-tutorials-and-samples)
[Third-party integration](#Third-party-repository-integration)
[Tutorials and Samples](#model-compression-tutorials-and-samples)
[Third-party integration](#third-party-repository-integration)
[Model Zoo](./docs/ModelZoo.md)

[![GitHub Release](https://img.shields.io/github/v/release/openvinotoolkit/nncf?color=green)](https://github.com/openvinotoolkit/nncf/releases)
Expand All @@ -21,13 +21,14 @@ Neural Network Compression Framework (NNCF) provides a suite of post-training an

NNCF is designed to work with models from [PyTorch](https://pytorch.org/), [TensorFlow](https://www.tensorflow.org/), [ONNX](https://onnx.ai/) and [OpenVINO™](https://docs.openvino.ai/latest/home.html).

NNCF provides [samples](#Model-compression-tutorials-and-samples) that demonstrate the usage of compression algorithms for different use cases and models. See compression results achievable with the NNCF-powered samples at [Model Zoo page](./docs/ModelZoo.md).
NNCF provides [samples](#model-compression-tutorials-and-samples) that demonstrate the usage of compression algorithms for different use cases and models. See compression results achievable with the NNCF-powered samples at [Model Zoo page](./docs/ModelZoo.md).

The framework is organized as a Python\* package that can be built and used in a standalone mode. The framework
architecture is unified to make it easy to add different compression algorithms for both PyTorch and TensorFlow deep
learning frameworks.

## Key Features

### Post-Training Compression Algorithms

| Compression algorithm |OpenVINO|PyTorch| TensorFlow | ONNX |
Expand Down Expand Up @@ -184,7 +185,6 @@ quantized_model = nncf.quantize(onnx_model, calibration_dataset)

</details>


[//]: # (NNCF provides full [samples]&#40;#post-training-quantization-samples&#41;, which demonstrate Post-Training Quantization usage for PyTorch, TensorFlow, ONNX, OpenVINO.)

### Training-Time Compression
Expand Down Expand Up @@ -272,7 +272,8 @@ For a quicker start with NNCF-powered compression, try sample notebooks and scri
### Model Compression Tutorials

A collection of ready-to-run Jupyter* notebooks are available to demonstrate how to use NNCF compression algorithms to optimize models for inference with the OpenVINO Toolkit:
- [Accelerate Inference of NLP models with Post-Training Qunatization API of NNCF](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/105-language-quantize-bert)

- [Accelerate Inference of NLP models with Post-Training Quantization API of NNCF](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/105-language-quantize-bert)
- [Convert and Optimize YOLOv8 with OpenVINO](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/230-yolov8-optimization)
- [Convert and Optimize YOLOv7 with OpenVINO](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/226-yolov7-optimization)
- [NNCF Post-Training Optimization of Segment Anything Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/237-segment-anything)
Expand All @@ -287,7 +288,9 @@ A collection of ready-to-run Jupyter* notebooks are available to demonstrate how
- [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)

### Post-Training Quantization Samples

Compact scripts demonstrating quantization and corresponding inference speed boost:

- [Post-Training Quantization of MobileNet v2 OpenVINO Model](examples/post_training_quantization/openvino/mobilenet_v2/README.md)
- [Post-Training Quantization of YOLOv8 OpenVINO Model](examples/post_training_quantization/openvino/yolov8/README.md)
- [Post-Training Quantization of Anomaly Classification OpenVINO model with control of accuracy metric](examples/post_training_quantization/openvino/quantize_with_accuracy_control/README.md)
Expand All @@ -298,7 +301,9 @@ Compact scripts demonstrating quantization and corresponding inference speed boo
- [Post-Training Quantization of MobileNet v2 TensorFlow Model](examples/post_training_quantization/tensorflow/mobilenet_v2/README.md)

### Training-Time Compression Samples

These examples provide full pipelines including compression, training and inference for classification, object detection and segmentation tasks.

- PyTorch samples:
- [Image Classification sample](examples/torch/classification/README.md)
- [Object Detection sample](examples/torch/object_detection/README.md)
Expand All @@ -309,6 +314,7 @@ These examples provide full pipelines including compression, training and infere
- [Instance Segmentation sample](examples/tensorflow/segmentation/README.md)

## Third-party repository integration

NNCF may be straightforwardly integrated into training/evaluation pipelines of third-party repositories.

### Used by
Expand All @@ -322,30 +328,39 @@ NNCF may be straightforwardly integrated into training/evaluation pipelines of t
NNCF is used as a compression backend within the renowned `transformers` repository in HuggingFace Optimum Intel.

### Git patches for third-party repository

See [third_party_integration](./third_party_integration) for examples of code modifications (Git patches and base commit IDs are provided) that are necessary to integrate NNCF into the following repositories:
- [huggingface-transformers](third_party_integration/huggingface_transformers/README.md)

- [huggingface-transformers](third_party_integration/huggingface_transformers/README.md)

## Installation Guide

For detailed installation instructions please refer to the [Installation](./docs/Installation.md) page.

NNCF can be installed as a regular PyPI package via pip:
```

```bash
pip install nncf
```

If you want to install both NNCF and the supported PyTorch version in one line, you can do this by simply running:
```

```bash
pip install nncf[torch]
```

Other viable options besides `[torch]` are `[tf]`, `[onnx]` and `[openvino]`.

NNCF is also available via [conda](https://anaconda.org/conda-forge/nncf):
```

```bash
conda install -c conda-forge nncf
```

You may also use one of the Dockerfiles in the [docker](./docker) directory to build an image with an environment already set up and ready for running NNCF [sample scripts](#Model-compression-tutorials-and-samples).
You may also use one of the Dockerfiles in the [docker](./docker) directory to build an image with an environment already set up and ready for running NNCF [sample scripts](#model-compression-tutorials-and-samples).

### System requirements

- Ubuntu\* 18.04 or later (64-bit)
- Python\* 3.7 or later
- Supported frameworks:
Expand All @@ -362,7 +377,7 @@ List of models and compression results for them can be found at our [Model Zoo p

## Citing

```
```bi
@article{kozlov2020neural,
title = {Neural network compression framework for fast model inference},
author = {Kozlov, Alexander and Lazarevich, Ivan and Shamporov, Vasily and Lyalyushkin, Nikolay and Gorbachev, Yury},
Expand All @@ -372,13 +387,15 @@ List of models and compression results for them can be found at our [Model Zoo p
```

## Contributing Guide

Refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidelines on contributions to the NNCF repository.

## Useful links

- [Documentation](./docs)
- Example scripts (model objects available through links in respective README.md files):
- [PyTorch](./examples/torch)
- [TensorFlow](./examples/tensorflow)
- [PyTorch](./examples/torch)
- [TensorFlow](./examples/tensorflow)
- [FAQ](./docs/FAQ.md)
- [Notebooks](https://github.com/openvinotoolkit/openvino_notebooks#-model-training)
- [HuggingFace Optimum Intel](https://huggingface.co/docs/optimum/intel/optimization_ov)
Expand Down
Loading

0 comments on commit aac4d77

Please sign in to comment.