OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Update NNCF docs (#33801)
Alexander Dokuchaev02bfeb11c7c1
diff --git a/README.md b/README.mdindex 0088d5630ec..974d1d80136 100644--- a/README.md+++ b/README.md@@ -114,7 +114,7 @@ Learn how to run LLMs and GenAI with [Samples](https://github.com/openvinotoolki### OpenVINO Tools-- [Neural Network Compression Framework (NNCF)](https://github.com/openvinotoolkit/nncf) - advanced model optimization techniques including quantization, filter pruning, binarization, and sparsity.+- [Neural Network Compression Framework (NNCF)](https://github.com/openvinotoolkit/nncf) - advanced model optimization techniques including quantization, and sparsity.- [GenAI Repository](https://github.com/openvinotoolkit/openvino.genai) and [OpenVINO Tokenizers](https://github.com/openvinotoolkit/openvino_tokenizers) - resources and tools for developing and optimizing Generative AI applications.- [OpenVINO™ Model Server (OVMS)](https://github.com/openvinotoolkit/model_server) - a scalable, high-performance solution for serving models optimized for Intel architectures.- [Intel® Geti™](https://geti.intel.com/) - an interactive video and image annotation tool for computer vision use cases.diff --git a/docs/articles_en/about-openvino/openvino-ecosystem/openvino-project.rst b/docs/articles_en/about-openvino/openvino-ecosystem/openvino-project.rstindex f073abb7f70..5b28470fb52 100644--- a/docs/articles_en/about-openvino/openvino-ecosystem/openvino-project.rst+++ b/docs/articles_en/about-openvino/openvino-ecosystem/openvino-project.rst@@ -27,8 +27,7 @@ models. Check the LLM-powered Chatbot Jupyter notebook to see how GenAI works.:bdg-link-success:`User Guide <https://docs.openvino.ai/2025/openvino-workflow/model-optimization.html>`A suite of advanced algorithms for Neural Network inference optimization with minimal accuracy-drop. NNCF applies quantization, filter pruning, binarization, and sparsity algorithms to PyTorch-and TensorFlow models during training.+drop. NNCF applies quantization and sparsity algorithms to PyTorch models during training.|hr|| **OpenVINO Model Server**diff --git a/docs/articles_en/documentation/openvino-ir-format/intermediate-representation-int8-inference.rst b/docs/articles_en/documentation/openvino-ir-format/intermediate-representation-int8-inference.rstindex ac35537fa54..3f18e760388 100644--- a/docs/articles_en/documentation/openvino-ir-format/intermediate-representation-int8-inference.rst+++ b/docs/articles_en/documentation/openvino-ir-format/intermediate-representation-int8-inference.rst@@ -15,12 +15,6 @@ For more details, refer to the :doc:`Model Optimization Guide <../../openvino-woIntermediate Representation should be specifically formed to be suitable for low precision inference.-Such a model is called a Low Precision IR and can be generated in two ways:--* By :doc:`quantizing regular IR with the Neural Network Compression Framework (NNCF) <../../openvino-workflow/model-optimization>`-* Using model conversion of a model pre-trained for Low Precision inference: TensorFlow models (``.pb`` model file with ``FakeQuantize`` operations), quantized TensorFlow Lite models and ONNX quantized models.- TensorFlow and ONNX quantized models can be prepared by `Neural Network Compression Framework <https://github.com/openvinotoolkit/nncf/blob/develop/README.md>`__.-For an operation to be executed in INT8, it must have `FakeQuantize` operations as inputs.For more details, see the :doc:`specification of FakeQuantize operation <operation-sets/operation-specs/quantization/fake-quantize-1>`.diff --git a/docs/articles_en/get-started.rst b/docs/articles_en/get-started.rstindex db28d6aa697..994a49e63de 100644--- a/docs/articles_en/get-started.rst+++ b/docs/articles_en/get-started.rst@@ -104,7 +104,6 @@ Model Compression and QuantizationUse OpenVINO’s model compression tools to reduce your model’s latency and memory footprint while maintaining good accuracy.-* Tutorial - `Quantization-Aware Training in TensorFlow with OpenVINO NNCF <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/tensorflow-quantization-aware-training>`__* Tutorial - `Quantization-Aware Training in PyTorch with NNCF <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/pytorch-quantization-aware-training>`__* :doc:`Model Optimization Guide <openvino-workflow/model-optimization>`diff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rstindex 395320487d6..e2abf72d7f5 100644--- a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst+++ b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst@@ -7,7 +7,6 @@ Training-time Optimization:hidden:compressing-models-during-training/quantization-aware-training- compressing-models-during-training/filter-pruningTraining-time optimization offered by NNCF is based on model compression algorithms executed@@ -16,13 +15,13 @@ accuracy and higher performance, and better results than post-training quantizatenables you to set the minimum acceptable accuracy value for your optimized model, determiningthe optimization efficiency.-With a few lines of code, you can apply NNCF compression to a PyTorch or TensorFlow training+With a few lines of code, you can apply NNCF compression to a PyTorch trainingscript. Once the model is optimized, you may convert it to the:doc:`OpenVINO IR format <../../documentation/openvino-ir-format>`, getting even betterinference results with OpenVINO Runtime. To optimize your model, you will need:-* A PyTorch or TensorFlow floating-point model.-* A training pipeline set up in the original framework (PyTorch or TensorFlow).+* A PyTorch floating-point model.+* A training pipeline set up in the PyTorch framework.* Training and validation datasets.* A `JSON configuration file <https://github.com/openvinotoolkit/nncf/blob/develop/docs/ConfigFile.md>`__specifying which compression methods to use.@@ -45,22 +44,8 @@ quantization errors part of the overall training loss and tries to minimize theiTo learn more, see:-* guide on quantization for :doc:`PyTorch and TensorFlow <./compressing-models-during-training/quantization-aware-training>`.+* guide on quantization for :doc:`PyTorch <./compressing-models-during-training/quantization-aware-training>`.* Jupyter notebook on `Quantization Aware Training with NNCF and PyTorch <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/pytorch-quantization-aware-training>`__.-* Jupyter notebook on `Quantization Aware Training with NNCF and TensorFlow <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/tensorflow-quantization-aware-training>`__.---Filter pruning-+++++++++++++++++++++++++--During fine-tuning, the importance criterion is used to search for redundant convolutional layer-filters that don't significantly contribute to the model's output. After fine-tuning, these-filters are removed from the model.--For more information, see:--* How to use :doc:`Filter Pruning <../model-optimization-guide/compressing-models-during-training/filter-pruning>`.-* Technical details of `Filter Pruning <https://github.com/openvinotoolkit/nncf/blob/develop/docs/usage/training_time_compression/other_algorithms/Pruning.md>`__.Experimental methodsdiff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/filter-pruning.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/filter-pruning.rstdeleted file mode 100644index b372e11a807..00000000000--- a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/filter-pruning.rst+++ /dev/null@@ -1,249 +0,0 @@-Filter Pruning of Convolutional Models-======================================---Introduction-####################--Filter pruning is an advanced optimization method that allows reducing the computational complexity of the model by removing-redundant or unimportant filters from the convolutional operations of the model. This removal is done in two steps:--1. Unimportant filters are zeroed out by the NNCF optimization with fine-tuning.--2. Zero filters are removed from the model during the export to OpenVINO Intermediate Representation (IR).---Filter Pruning method from the NNCF can be used stand-alone but we usually recommend stacking it with 8-bit quantization for-two reasons. First, 8-bit quantization is the best method in terms of achieving the highest accuracy-performance trade-offs so-stacking it with filter pruning can give even better performance results. Second, applying quantization along with filter-pruning does not hurt accuracy a lot since filter pruning removes noisy filters from the model which narrows down values-ranges of weights and activations and helps to reduce overall quantization error.--.. note::- Filter Pruning usually requires a long fine-tuning or retraining of the model which can be comparable to training the- model from scratch. Otherwise, a large accuracy degradation can be caused. Therefore, the training schedule should be- adjusted accordingly when applying this method.---Below, we provide the steps that are required to apply Filter Pruning + QAT to the model:--Applying Filter Pruning with fine-tuning-########################################--Here, we show the basic steps to modify the training script for the model and use it to zero out unimportant filters:--1. Import NNCF API-++++++++++++++++++--In this step, NNCF-related imports are added in the beginning of the training script:--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [imports]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [imports]--2. Create NNCF configuration-++++++++++++++++++++++++++++--Here, you should define NNCF configuration which consists of model-related parameters (`"input_info"` section) and parameters-of optimization methods (`"compression"` section).--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [nncf_congig]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [nncf_congig]--Here is a brief description of the required parameters of the Filter Pruning method. For a full description refer to the-`GitHub <https://github.com/openvinotoolkit/nncf/blob/develop/docs/usage/training_time_compression/other_algorithms/Pruning.md>`__ page.--* ``pruning_init`` - initial pruning rate target. For example, value ``0.1`` means that at the begging of training, convolutions that can be pruned will have 10% of their filters set to zero.--* ``pruning_target`` - pruning rate target at the end of the schedule. For example, the value ``0.5`` means that at the epoch with the number of ``num_init_steps + pruning_steps``, convolutions that can be pruned will have 50% of their filters set to zero.--* ``pruning_steps` - the number of epochs during which the pruning rate target is increased from ``pruning_init` to ``pruning_target`` value. We recommend keeping the highest learning rate during this period.---3. Apply optimization methods-+++++++++++++++++++++++++++++--In the next step, the original model is wrapped by the NNCF object using the ``create_compressed_model()`` API using the-configuration defined in the previous step. This method returns a so-called compression controller and the wrapped model-that can be used the same way as the original model. It is worth noting that optimization methods are applied at this step-so that the model undergoes a set of corresponding transformations and can contain additional operations required for the-optimization.--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [wrap_model]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [wrap_model]--4. Fine-tune the model-++++++++++++++++++++++--This step assumes that you will apply fine-tuning to the model the same way as it is done for the baseline model. In the case-of Filter Pruning method we recommend using the training schedule and learning rate similar to what was used for the training-of the original model.--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [tune_model]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [tune_model]---5. Multi-GPU distributed training-+++++++++++++++++++++++++++++++++--In the case of distributed multi-GPU training (not DataParallel), you should call ``compression_ctrl.distributed()`` before the-fine-tuning that will inform optimization methods to do some adjustments to function in the distributed mode.--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [distributed]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [distributed]--6. Export quantized model-+++++++++++++++++++++++++--When fine-tuning finishes, the quantized model can be exported to the corresponding format for further inference: ONNX in-the case of PyTorch and frozen graph - for TensorFlow 2.--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [export]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [export]---These were the basic steps to applying the QAT method from the NNCF. However, it is required in some cases to save/load model-checkpoints during the training. Since NNCF wraps the original model with its own object it provides an API for these needs.---7. (Optional) Save checkpoint-+++++++++++++++++++++++++++++--To save model checkpoint use the following API:--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [save_checkpoint]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [save_checkpoint]---8. (Optional) Restore from checkpoint-+++++++++++++++++++++++++++++++++++++--To restore the model from checkpoint you should use the following API:--.. tab-set::-- .. tab-item:: PyTorch- :sync: pytorch-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_torch.py- :language: python- :fragment: [load_checkpoint]-- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/pruning_tf.py- :language: python- :fragment: [load_checkpoint]--For more details, see the following `documentation <https://github.com/openvinotoolkit/nncf/blob/develop/docs/usage/training_time_compression/other_algorithms/Pruning.md>`__.--Deploying pruned model-######################--The pruned model requires an extra step that should be done to get performance improvement. This step involves removal of the-zero filters from the model. This is done at the model conversion step using :doc:`model conversion API <../../model-preparation>` tool when model is converted from the framework representation (ONNX, TensorFlow, etc.) to OpenVINO Intermediate Representation.--* To remove zero filters from the pruned model add the following parameter to the model conversion command: ``transform=Pruning``--After that, the model can be deployed with OpenVINO in the same way as the baseline model.-For more details about model deployment with OpenVINO, see the corresponding :doc:`documentation <../../running-inference>`.---Examples-####################--* `PyTorch Image Classification example <https://github.com/openvinotoolkit/nncf/blob/develop/examples/torch/classification>`__--* `TensorFlow Image Classification example <https://github.com/openvinotoolkit/nncf/tree/develop/examples/tensorflow/classification>`__-diff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/quantization-aware-training.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/quantization-aware-training.rstindex a0610d7fdd5..9272246de3c 100644--- a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/quantization-aware-training.rst+++ b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training/quantization-aware-training.rst@@ -12,11 +12,6 @@ knowledgeable in Python programming and familiar with the training code for theSteps required to apply QAT to the model:-.. note::- Currently, NNCF for TensorFlow supports the optimization of models created using the Keras- `Sequential API <https://www.tensorflow.org/guide/keras/sequential_model>`__ or- `Functional API <https://www.tensorflow.org/guide/keras/functional>`__.-1. Apply Post Training Quantization to the Model#################################################@@ -31,13 +26,6 @@ Quantize the model using the :doc:`Post-Training Quantization <../quantizing-mod:language: python:fragment: [quantize]- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/qat_tf.py- :language: python- :fragment: [quantize]-2. Fine-tune the Model#######################@@ -56,13 +44,6 @@ forward and backward passes.:language: python:fragment: [tune_model]- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/qat_tf.py- :language: python- :fragment: [tune_model]-.. note::The precision of weight transitions to INT8 only after converting the model to OpenVINOIntermediate Representation. You can expect a reduction in the model footprint only for@@ -85,13 +66,6 @@ To save a model checkpoint, use the following API::language: python:fragment: [save_checkpoint]- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/qat_tf.py- :language: python- :fragment: [save_checkpoint]-4. (Optional) Restore from Checkpoint######################################@@ -106,13 +80,6 @@ To restore the model from checkpoint, use the following API::language: python:fragment: [load_checkpoint]- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/code/qat_tf.py- :language: python- :fragment: [load_checkpoint]-Deploying the Quantized Model##############################@@ -128,12 +95,6 @@ any additional steps.:language: python:fragment: [inference]- .. tab-item:: TensorFlow 2- :sync: tensorflow-2-- .. doxygensnippet:: docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.py- :language: python- :fragment: [inference]For more details, see the corresponding :doc:`documentation <../../running-inference>`.@@ -142,4 +103,3 @@ Examples* `Quantization-aware Training of Resnet18 PyTorch Model <https://github.com/openvinotoolkit/nncf/tree/develop/examples/quantization_aware_training/torch/resnet18>`__* `Quantization-aware Training of STFPM PyTorch Model <https://github.com/openvinotoolkit/nncf/tree/develop/examples/quantization_aware_training/torch/anomalib>`__-* `Quantization-aware Training of MobileNet v2 TensorFlow Model <https://github.com/openvinotoolkit/nncf/tree/develop/examples/quantization_aware_training/tensorflow/mobilenet_v2>`__diff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rstindex aec99cc6f29..cb8bc6c52f3 100644--- a/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst+++ b/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst@@ -25,7 +25,7 @@ flows:.. note- NNCF offers a Python API, for compressing PyTorch, TensorFlow 2.x, ONNX, and OpenVINO IR+ NNCF offers a Python API, for compressing PyTorch, ONNX, and OpenVINO IRmodel formats. OpenVINO IR offers the most comprehensive support.diff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training/basic-quantization-flow.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training/basic-quantization-flow.rstindex 75b94741339..0dff58d601e 100644--- a/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training/basic-quantization-flow.rst+++ b/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training/basic-quantization-flow.rst@@ -5,7 +5,7 @@ Basic Quantization FlowIntroduction####################-The basic quantization flow is the simplest way to apply 8-bit quantization to the model. It is available for models in the following frameworks: OpenVINO, PyTorch, TensorFlow 2.x, and ONNX. The basic quantization flow is based on the following steps:+The basic quantization flow is the simplest way to apply 8-bit quantization to the model. It is available for models in the following frameworks: OpenVINO, PyTorch, and ONNX. The basic quantization flow is based on the following steps:* Set up an environment and install dependencies.* Prepare a representative **calibration dataset** that is used to estimate quantization parameters of the activations within the model, for example, of 300 samples.@@ -56,13 +56,6 @@ The transformation function is a function that takes a sample from the dataset a:language: python:fragment: [dataset]- .. tab-item:: TensorFlow- :sync: tensorflow-- .. doxygensnippet:: docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.py- :language: python- :fragment: [dataset]-.. tab-item:: TorchFX:sync: torch_fx@@ -102,13 +95,6 @@ See the `example section <#examples-of-how-to-apply-nncf-post-training-quantizat:language: python:fragment: [quantization]- .. tab-item:: TensorFlow- :sync: tensorflow-- .. doxygensnippet:: docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.py- :language: python- :fragment: [quantization]-.. tab-item:: TorchFX:sync: torch_fx@@ -142,13 +128,6 @@ If you have not already installed OpenVINO developer tools, install it with ``pi:language: python:fragment: [inference]- .. tab-item:: TensorFlow- :sync: tensorflow-- .. doxygensnippet:: docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.py- :language: python- :fragment: [inference]-TorchFX models can utilize OpenVINO optimizations using `torch.compile(..., backend="openvino") <https://docs.openvino.ai/2025/openvino-workflow/torch-compile.html>`__ functionality:.. tab-set::@@ -242,5 +221,4 @@ Examples of how to apply NNCF post-training quantization:* `Post-Training Quantization of MobileNet v2 PyTorch Model <https://github.com/openvinotoolkit/nncf/blob/develop/examples/post_training_quantization/torch/mobilenet_v2>`__* `Post-Training Quantization of SSD PyTorch Model <https://github.com/openvinotoolkit/nncf/blob/develop/examples/post_training_quantization/torch/ssd300_vgg16>`__* `Post-Training Quantization of MobileNet v2 ONNX Model <https://github.com/openvinotoolkit/nncf/blob/develop/examples/post_training_quantization/onnx/mobilenet_v2>`__-* `Post-Training Quantization of MobileNet v2 TensorFlow Model <https://github.com/openvinotoolkit/nncf/blob/develop/examples/post_training_quantization/tensorflow/mobilenet_v2>`__diff --git a/docs/articles_en/openvino-workflow/model-optimization.rst b/docs/articles_en/openvino-workflow/model-optimization.rstindex e44cf556329..4e905e146fc 100644--- a/docs/articles_en/openvino-workflow/model-optimization.rst+++ b/docs/articles_en/openvino-workflow/model-optimization.rst@@ -21,7 +21,7 @@ In OpenVINO, the default optimization tool is NNCF (Neural Network Compression FIt is a `set of compression algorithms <https://github.com/openvinotoolkit/nncf/blob/develop/README.md>`__,organized as a Python package, that make your models smaller and faster. Note that NNCFis **not part of the OpenVINO package**, so it needs to be installed separately. It supports-models in **OpenVINO IR**, **PyTorch**, **ONNX**, and **TensorFlow** formats, offering+models in **OpenVINO IR**, **PyTorch** and **ONNX** formats, offeringthe following main optimizations:.. image:: ../assets/images/WHAT_TO_USE.svg@@ -38,9 +38,8 @@ the following main optimizations:acceptable, Training-time Optimization may be a better option.| :doc:`Training-time Optimization <model-optimization-guide/compressing-models-during-training>`:-| Involves a suite of advanced methods such as Structured or Unstructured Pruning, as well- as Quantization-aware Training. This kind of optimization requires the use of the model's- original framework, for NNCF, it is either PyTorch or TensorFlow.+| Involves a suite of advanced methods such as Sparsity, as well+ as Quantization-aware Training. This kind of optimization requires the use of the PyTorch framework.@@ -50,8 +49,7 @@ Recommended workflows* A common approach for most cases is to:1. Perform post-training quantization first, as it is the easiest option.- 2. For even better results, combine post-training quantization with filter pruning.- 3. If the accuracy drop is unacceptable, use quantization-aware training instead. It will give+ 2. If the accuracy drop is unacceptable, use quantization-aware training instead. It will giveyou the same level of performance boost, with a smaller impact on accuracy.* **Weight compression** works with **LLMs**, **VLMs** and other Transformer-based models.@@ -113,7 +111,7 @@ both `the NNCF repository <https://github.com/openvinotoolkit/nncf?tab=readme-ovno additional changes to the inference code are required.This is true for models optimized using NNCF, as well as those pre-optimized in their source- frameworks, such as PyTorch, TensorFlow, and ONNX (in Q/DQ; Quantize/DeQuantize format).+ frameworks, such as PyTorch, and ONNX (in Q/DQ; Quantize/DeQuantize format).The latter may be easily converted to the:doc:`OpenVINO Intermediate Representation format (IR) <../../documentation/openvino-ir-format>`right away.@@ -132,4 +130,4 @@ Additional Resources* `NNCF Architecture <https://github.com/openvinotoolkit/nncf/blob/develop/docs/NNCFArchitecture.md>`__* `NNCF Tutorials <https://github.com/openvinotoolkit/nncf?tab=readme-ov-file#demos-tutorials-and-samples>`__* `NNCF Compressed Model Zoo <https://github.com/openvinotoolkit/nncf/blob/develop/docs/ModelZoo.md>`__-* :doc:`Deployment optimization <running-inference/optimize-inference>`\ No newline at end of file+* :doc:`Deployment optimization <running-inference/optimize-inference>`diff --git a/docs/optimization_guide/nncf/code/pruning_tf.py b/docs/optimization_guide/nncf/code/pruning_tf.pydeleted file mode 100644index c1e646387e9..00000000000--- a/docs/optimization_guide/nncf/code/pruning_tf.py+++ /dev/null@@ -1,82 +0,0 @@-# Copyright (C) 2018-2026 Intel Corporation-# SPDX-License-Identifier: Apache-2.0--#! [imports]-import tensorflow as tf--from nncf import NNCFConfig-from nncf.tensorflow import create_compressed_model, create_compression_callbacks, \- register_default_init_args-#! [imports]--#! [nncf_congig]-nncf_config_dict = {- "input_info": {"sample_size": [1, 3, 224, 224]}, # input shape required for model tracing- "compression": [- {- "algorithm": "filter_pruning",- "pruning_init": 0.1,- "params": {- "pruning_target": 0.4,- "pruning_steps": 15- }- },- {- "algorithm": "quantization", # 8-bit quantization with default settings- },- ]-}-nncf_config = NNCFConfig.from_dict(nncf_config_dict)-nncf_config = register_default_init_args(nncf_config, train_dataset, batch_size=1) # train_dataset is an instance of tf.data.Dataset-#! [nncf_congig]--#! [wrap_model]-model = KerasModel() # instance of the tensorflow.keras.Model-compression_ctrl, model = create_compressed_model(model, nncf_config)-#! [wrap_model]--#! [distributed]-compression_ctrl.distributed() # call it before the training-#! [distributed]--#! [tune_model]-... # fine-tuning preparations, e.g. dataset, loss, optimization setup, etc.--# create compression callbacks to control pruning parameters and dump compression statistics-# all the setting are being taked from compression_ctrl, i.e. from NNCF config-compression_callbacks = create_compression_callbacks(compression_ctrl, log_dir="./compression_log")--# tune quantized model for 50 epochs as the baseline-model.fit(train_dataset, epochs=50, callbacks=compression_callbacks)-#! [tune_model]--#! [export]-compression_ctrl.export_model("compressed_model.pb") #export to Frozen Graph-#! [export]--#! [save_checkpoint]-from nncf.tensorflow.utils.state import TFCompressionState-from nncf.tensorflow.callbacks.checkpoint_callback import CheckpointManagerCallback--checkpoint = tf.train.Checkpoint(model=model,- compression_state=TFCompressionState(compression_ctrl),- ... # the rest of the user-defined objects to save- )-callbacks = []-callbacks.append(CheckpointManagerCallback(checkpoint, path_to_checkpoint))-...-model.fit(..., callbacks=callbacks)-#! [save_checkpoint]--#! [load_checkpoint]-from nncf.tensorflow.utils.state import TFCompressionStateLoader--checkpoint = tf.train.Checkpoint(compression_state=TFCompressionStateLoader())-checkpoint.restore(path_to_checkpoint)-compression_state = checkpoint.compression_state.state--compression_ctrl, model = create_compressed_model(model, nncf_config, compression_state)-checkpoint = tf.train.Checkpoint(model=model,- ...)-checkpoint.restore(path_to_checkpoint)-#! [load_checkpoint]diff --git a/docs/optimization_guide/nncf/code/pruning_torch.py b/docs/optimization_guide/nncf/code/pruning_torch.pydeleted file mode 100644index 7cca6990bee..00000000000--- a/docs/optimization_guide/nncf/code/pruning_torch.py+++ /dev/null@@ -1,72 +0,0 @@-# Copyright (C) 2018-2026 Intel Corporation-# SPDX-License-Identifier: Apache-2.0--#! [imports]-import torch-import nncf # Important - should be imported right after torch-from nncf import NNCFConfig-from nncf.torch import create_compressed_model, register_default_init_args-#! [imports]--#! [nncf_congig]-nncf_config_dict = {- "input_info": {"sample_size": [1, 3, 224, 224]}, # input shape required for model tracing- "compression": [- {- "algorithm": "filter_pruning",- "pruning_init": 0.1,- "params": {- "pruning_target": 0.4,- "pruning_steps": 15- }- },- {- "algorithm": "quantization", # 8-bit quantization with default settings- },- ]-}-nncf_config = NNCFConfig.from_dict(nncf_config_dict)-nncf_config = register_default_init_args(nncf_config, train_loader) # train_loader is an instance of torch.utils.data.DataLoader-#! [nncf_congig]--#! [wrap_model]-model = TorchModel() # instance of torch.nn.Module-compression_ctrl, model = create_compressed_model(model, nncf_config)-#! [wrap_model]--#! [distributed]-compression_ctrl.distributed() # call it before the training loop-#! [distributed]--#! [tune_model]-... # fine-tuning preparations, e.g. dataset, loss, optimization setup, etc.--# tune quantized model for 50 epochs as the baseline-for epoch in range(0, 50):- compression_ctrl.scheduler.epoch_step() # Epoch control API-- for i, data in enumerate(train_loader):- compression_ctrl.scheduler.step() # Training iteration control API- ... # training loop body-#! [tune_model]--#! [export]-compression_ctrl.export_model("compressed_model.onnx")-#! [export]--#! [save_checkpoint]-checkpoint = {- 'state_dict': model.state_dict(),- 'compression_state': compression_ctrl.get_compression_state(),- ... # the rest of the user-defined objects to save-}-torch.save(checkpoint, path_to_checkpoint)-#! [save_checkpoint]--#! [load_checkpoint]-resuming_checkpoint = torch.load(path_to_checkpoint)-compression_state = resuming_checkpoint['compression_state']-compression_ctrl, model = create_compressed_model(model, nncf_config, compression_state=compression_state)-state_dict = resuming_checkpoint['state_dict']-model.load_state_dict(state_dict)-#! [load_checkpoint]diff --git a/docs/optimization_guide/nncf/code/qat_tf.py b/docs/optimization_guide/nncf/code/qat_tf.pydeleted file mode 100644index a233501673a..00000000000--- a/docs/optimization_guide/nncf/code/qat_tf.py+++ /dev/null@@ -1,45 +0,0 @@-# Copyright (C) 2018-2026 Intel Corporation-# SPDX-License-Identifier: Apache-2.0--#! [quantize]-model = KerasModel() # instance of the tensorflow.keras.Model-quantized_model = nncf.quantize(model, ...)-#! [quantize]--#! [tune_model]-... # fine-tuning preparations, e.g. dataset, loss, optimization setup, etc.--# tune quantized model for 5 epochs the same way as the baseline-quantized_model.fit(train_dataset, epochs=5)-#! [tune_model]--#! [save_checkpoint]-from nncf.tensorflow import ConfigState-from nncf.tensorflow import get_config-from nncf.tensorflow.callbacks.checkpoint_callback import CheckpointManagerCallback--nncf_config = get_config(quantized_model)-checkpoint = tf.train.Checkpoint(model=quantized_model,- nncf_config_state=ConfigState(nncf_config),- ... # the rest of the user-defined objects to save- )-callbacks = []-callbacks.append(CheckpointManagerCallback(checkpoint, path_to_checkpoint))-...-quantized_model.fit(..., callbacks=callbacks)-#! [save_checkpoint]--#! [load_checkpoint]-from nncf.tensorflow import ConfigState-from nncf.tensorflow import load_from_config--checkpoint = tf.train.Checkpoint(nncf_config_state=ConfigState())-checkpoint.restore(path_to_checkpoint)--quantized_model = load_from_config(model, checkpoint.nncf_config_state.config)--checkpoint = tf.train.Checkpoint(model=quantized_model- ... # the rest of the user-defined objects to load- )-checkpoint.restore(path_to_checkpoint)-#! [load_checkpoint]diff --git a/docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.py b/docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.pydeleted file mode 100644index 75f1f396897..00000000000--- a/docs/optimization_guide/nncf/ptq/code/ptq_tensorflow.py+++ /dev/null@@ -1,38 +0,0 @@-# Copyright (C) 2018-2026 Intel Corporation-# SPDX-License-Identifier: Apache-2.0--#! [dataset]-import nncf-import tensorflow_datasets as tfds--calibration_loader = tfds.load(...)--def transform_fn(data_item):- images, _ = data_item- return images--calibration_dataset = nncf.Dataset(calibration_loader, transform_fn)-#! [dataset]--#! [quantization]-import tensorflow as tf-model = tf.saved_model.load("model_path")--quantized_model = nncf.quantize(model, calibration_dataset)-#! [quantization]--#! [inference]-import openvino as ov--# convert TensorFlow model to OpenVINO model-ov_quantized_model = ov.convert_model(quantized_model)--# compile the model to transform quantized operations to int8-model_int8 = ov.compile_model(ov_quantized_model)--input_fp32 = ... # FP32 model input-res = model_int8(input_fp32)--# save the model-ov.save_model(ov_quantized_model, "quantized_model.xml")-#! [inference]