[TorchAO] [OVQuantizer] Update Torch AO Dependency and Refactor Executorch Tests#3842
[TorchAO] [OVQuantizer] Update Torch AO Dependency and Refactor Executorch Tests#3842anzr299 wants to merge 78 commits intoopenvinotoolkit:developfrom
Conversation
|
Agreed to merge it after the CF to mitigate any risks with a new dependency. @anzr299 @AlexanderDokuchaev |
| # Pytorch | ||
| torch==2.9.0 | ||
| torchvision==0.24.0 | ||
| torchao==0.14.0 |
There was a problem hiding this comment.
Aamir, as we discussed it with Alexander Suslov, the main idea was to get rid of torch.ao and do not use any external dependencies (like torchao)
The task is to remove torch.ao imports and replace them with code in the nncf codebase, no external dependencies
…he which eats up memory
There was a problem hiding this comment.
Pull request overview
This PR migrates the codebase from using torch.ao to torchao as a dependency, updates the OpenVINOQuantizer to use the executorch implementation, and refactors the test structure for executorch tests. The migration addresses breaking changes in PyTorch's quantization API and aligns with the newer torchao package architecture.
Changes:
- Migration of all
torch.ao.quantizationimports totorchao.quantization.pt2e - Removal of NNCF's internal
OpenVINOQuantizerimplementation in favor of executorch's version - Introduction of
quantizer_paramsalongsidecompression_paramsfor better parameter separation - Update of test reference files to reflect behavior changes in torchao vs torch.ao
- Addition of torchao and executorch dependencies across requirements files
Reviewed changes
Copilot reviewed 58 out of 100 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/torch/requirements.txt | Added torchao dependency |
| tests/torch/fx/test_model_transformer.py | Updated imports from torch.ao to torchao |
| tests/post_training/test_quantize_conformance.py | Added quantizer_params support and printing |
| tests/post_training/requirements.txt | Added torchao and executorch, updated scikit-learn version |
| tests/post_training/pipelines/image_classification_base.py | Updated imports and refactored parameter handling |
| tests/post_training/pipelines/base.py | Added quantizer_params parameter throughout pipeline |
| tests/post_training/model_scope.py | Added add_quantizer_compression_params function |
| tests/executorch/test_quantizer_compression.py | Updated test data directory paths |
| tests/executorch/test_ptq.py | Updated imports and test references |
| tests/executorch/requirements.txt | Updated dependency versions |
| tests/executorch/data/* | Multiple new reference files for test data |
| tests/cross_fw/shared/helpers.py | Added torchao to backend packages |
| src/nncf/torch/quantization/strip.py | Updated observer imports |
| src/nncf/quantization/algorithms/min_max/torch_fx_backend.py | Updated observer imports |
| src/nncf/experimental/torch/fx/transformations.py | Updated imports and comments |
| src/nncf/experimental/torch/fx/quantization/quantizer/torch_ao_adapter.py | Updated imports and documentation |
| src/nncf/experimental/torch/fx/quantization/quantizer/openvino_quantizer.py | File removed |
| src/nncf/experimental/torch/fx/quantization/quantizer/openvino_adapter.py | Updated to use executorch's OpenVINOQuantizer |
| src/nncf/experimental/torch/fx/quantization/quantize_pt2e.py | Updated imports and removed internal quantizer reference |
| src/nncf/experimental/torch/fx/quantization/quantize_model.py | Updated imports |
| src/nncf/experimental/torch/fx/init.py | Removed OpenVINOQuantizer export |
| src/nncf/common/tensor_statistics/collectors.py | Updated comment reference |
| examples/*/requirements.txt | Added torchao dependency |
| constraints.txt | Added torchao==0.14.0 constraint |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TODO: copy _get_edge_or_node_to_group_id from torchao to nncf
…uires this version. For upgrade, need to update python version first
Changes
Include tests for executorch, OVQuantizer
Remove OVQuantizer from NNCF
Move the tests in appropriate directory
Reason for changes
Migrate from torch.ao -> torchao
Notable differences in torch.ao and torchao implementation which affect test references:
torchaoimplementation it keeps the same name as the node being replaced with.https://github.com/pytorch/executorch/tree/main/backends/xnnpack/quantizerwhich now explicitly quantizes the conv_transpose2D operator and its weights.Reference graphs changed due to above:
Related tickets
CVS-176783
Tests
PTQ Conformance - PTQ-789 - Pass
Examples - https://github.com/openvinotoolkit/nncf/actions/runs/21204888584 - Pass
WC conformance - https://github.com/openvinotoolkit/nncf/actions/runs/21204893707 - Pass
pytest tests/executorch results:

All tests in tests/executorch pass