diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index ca599dcb832..e9d56f40cc8 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -3,3 +3,5 @@ self-hosted-runner: - windows-2025-8-core - windows-2025-16-core - aks-linux-6-cores-55gb-gpu-a10 + - Linux + - NNCF diff --git a/.github/workflows/call_precommit.yml b/.github/workflows/call_precommit.yml index acea16b1670..2c5787819b2 100644 --- a/.github/workflows/call_precommit.yml +++ b/.github/workflows/call_precommit.yml @@ -19,158 +19,37 @@ on: required: false jobs: - common: - timeout-minutes: 40 - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - lfs: true - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: ${{ inputs.python_version }} - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: uv pip install --system . -r tests/common/requirements.txt - - name: Print installed modules - run: pip list - - name: Run common precommit test scope - run: make test-common - env: - NUM_WORKERS: 2 - - onnx: - timeout-minutes: 40 - runs-on: ubuntu-latest-8-cores - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - lfs: true - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: ${{ inputs.python_version }} - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: uv pip install --system . -r tests/onnx/requirements.txt - - name: Print installed modules - run: pip list - - name: Run ONNX precommit test scope - run: make test-onnx - env: - NUM_WORKERS: 4 - - openvino: - timeout-minutes: 40 - runs-on: ubuntu-latest-8-cores - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - lfs: true - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: ${{ inputs.python_version }} - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: uv pip install --system . -r tests/openvino/requirements.txt - - name: Print installed modules - run: pip list - - name: Run OV precommit test scope - run: make test-openvino - env: - NUM_WORKERS: 4 - - tools: - timeout-minutes: 40 - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - lfs: true - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: ${{ inputs.python_version }} - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - - name: Install test requirements - run: uv pip install --system . -r tests/tools/requirements.txt - - name: Print installed modules - run: pip list - - name: Run tools precommit test scope - run: pytest -ra tests/tools - - pytorch-cpu: - timeout-minutes: 40 - runs-on: ubuntu-latest - # TODO(AlexanderDokuchaev): Enable with torchao=0.18.0 release - if: ${{ inputs.python_version != '3.14' }} - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - lfs: true - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: ${{ inputs.python_version }} - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: uv pip install --system . -r tests/torch/requirements.txt - - name: Print installed modules - run: pip list - - name: Run torch precommit test scope - run: pytest -ra -n2 --durations=30 tests/torch -m "not cuda" - pytorch-cuda: timeout-minutes: 40 - runs-on: aks-linux-6-cores-55gb-gpu-a10 + runs-on: + group: Nvidia-GPU + labels: [Linux, NNCF] if: ${{ inputs.gpu_enabled == true }} + container: + image: ubuntu:24.04 + options: --gpus all --ipc=host + volumes: + - /usr/local/share/ca-certificates:/usr/local/share/ca-certificates:ro defaults: run: shell: bash env: DEBIAN_FRONTEND: noninteractive + NODE_EXTRA_CA_CERTS: /usr/local/share/ca-certificates/IntelProxyRootCA-Base64.crt + GIT_SSL_CAINFO: /usr/local/share/ca-certificates/IntelProxyRootCA-Base64.crt + PIP_CERT: /usr/local/share/ca-certificates/IntelProxyRootCA-Base64.crt + REQUESTS_CA_BUNDLE: /usr/local/share/ca-certificates/IntelProxyRootCA-Base64.crt + SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt steps: - name: Install dependencies run : | - sudo apt-get update - sudo apt-get --assume-yes install build-essential ninja-build libgl1-mesa-dev libglib2.0-0 wget make + apt-get update + apt-get --assume-yes install git git-lfs ca-certificates build-essential ninja-build libgl1-mesa-dev libglib2.0-0 wget make + update-ca-certificates - name: Download CUDA run: | - wget -q https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run - sudo sh cuda_12.6.3_560.35.05_linux.run --toolkit --silent + wget -q https://developer.download.nvidia.com/compute/cuda/13.2.1/local_installers/cuda_13.2.1_595.58.03_linux.run + sh cuda_13.2.1_595.58.03_linux.run --toolkit --silent - name: Runner info continue-on-error: true run: | @@ -182,14 +61,16 @@ jobs: - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: ${{ inputs.python_version }} - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 + # - name: Install uv + # uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - name: Override constraints if: ${{ inputs.override_requirements != '' }} run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" shell: bash + - name: Print installed modules + run: pip list - name: Install NNCF and test requirements - run: uv pip install --system . -r tests/torch/requirements.txt + run: pip install . -r tests/torch/requirements.txt - name: Print installed modules run: pip list - name: Check CUDA diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index ee7a6ae5143..957320698b2 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -110,8 +110,8 @@ jobs: sudo apt-get --assume-yes install build-essential ninja-build libgl1-mesa-dev libglib2.0-0 wget make - name: Download CUDA run: | - wget -q https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run - sudo sh cuda_12.6.3_560.35.05_linux.run --toolkit --silent + wget -q https://developer.download.nvidia.com/compute/cuda/13.2.1/local_installers/cuda_13.2.1_595.58.03_linux.run + sudo sh cuda_13.2.1_595.58.03_linux.run --toolkit --silent - name: Runner info continue-on-error: true run: | diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 9d84c476651..487a341e839 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -59,8 +59,8 @@ jobs: sudo apt-get --assume-yes install build-essential ninja-build libgl1-mesa-dev libglib2.0-0 wget make virtualenv - name: Download CUDA run: | - wget -q https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run - sudo sh cuda_12.6.3_560.35.05_linux.run --toolkit --silent + wget -q https://developer.download.nvidia.com/compute/cuda/13.2.1/local_installers/cuda_13.2.1_595.58.03_linux.run + sudo sh cuda_13.2.1_595.58.03_linux.run --toolkit --silent - name: Runner info continue-on-error: true run: | diff --git a/README.md b/README.md index 517ce94efee..3c6f22d7623 100644 --- a/README.md +++ b/README.md @@ -163,8 +163,8 @@ def transform_fn(data_item): calibration_dataset = nncf.Dataset(dataset_loader, transform_fn) # Step 3: Export model to TorchFX -input_shape = (1, 3, 224, 224) -fx_model = torch.export.export_for_training(model, args=(ex_input,)).module() +ex_input = torch.randn(1, 3, 224, 224) +fx_model = torch.export.export(model, args=(ex_input,)).module() # or # fx_model = torch.export.export(model, args=(ex_input,)).module() diff --git a/constraints.txt b/constraints.txt index b3d401117f5..5eba49ebf90 100644 --- a/constraints.txt +++ b/constraints.txt @@ -2,16 +2,16 @@ openvino==2026.2.1 # Pytorch -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 torchao==0.17.0 # ONNX onnx==1.22.0 -onnx-ir==0.1.15 +onnx-ir==0.2.1 onnxruntime==1.23.2; python_version < '3.11' onnxruntime==1.24.3; python_version >= '3.11' -onnxscript==0.6.2 +onnxscript==0.7.0 # Tests and examples pytest==9.0.3 diff --git a/docs/Installation.md b/docs/Installation.md index 8cb6e08f2d1..66e425fc156 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -48,7 +48,7 @@ as well as the supported versions of Python: | NNCF | OpenVINO | PyTorch | ONNX | TensorFlow | Python | |-----------|------------|----------|----------|------------|--------| -| `develop` | `2026.2.1` | `2.10.0` | `1.22.0` | | `3.12` | +| `develop` | `2026.2.1` | `2.11.0` | `1.22.0` | | `3.12` | | `3.2.0` | `2026.2.0` | `2.10.0` | `1.21.0` | | `3.12` | | `3.1.0` | `2026.1.0` | `2.10.0` | `1.21.0` | | `3.10` | | `3.0.0` | `2026.0.0` | `2.9.0` | `1.17.0` | | `3.10` | @@ -73,4 +73,4 @@ as well as the supported versions of Python: > (*) Python 3.9 or higher is required for TensorFlow 2.15.1 -This repository is tested on Python* 3.12, PyTorch* 2.10.0 (NVidia CUDA\* Toolkit 12.6). +This repository is tested on Python* 3.12, PyTorch* 2.11.0 (NVidia CUDA\* Toolkit 13.2). diff --git a/examples/llm_compression/onnx/tiny_llama/requirements.txt b/examples/llm_compression/onnx/tiny_llama/requirements.txt index 5b078595120..91b972c7885 100644 --- a/examples/llm_compression/onnx/tiny_llama/requirements.txt +++ b/examples/llm_compression/onnx/tiny_llama/requirements.txt @@ -6,4 +6,4 @@ optimum-onnx @ git+https://github.com/AlexanderDokuchaev/optimum-onnx.git@b57739 onnx==1.22.0 onnxruntime==1.23.2; python_version < '3.11' onnxruntime==1.24.3; python_version >= '3.11' -torch==2.10.0 +torch==2.11.0 diff --git a/examples/llm_compression/onnx/tiny_llama_scale_estimation/requirements.txt b/examples/llm_compression/onnx/tiny_llama_scale_estimation/requirements.txt index 9c2d010b29e..89bf1eb23ae 100644 --- a/examples/llm_compression/onnx/tiny_llama_scale_estimation/requirements.txt +++ b/examples/llm_compression/onnx/tiny_llama_scale_estimation/requirements.txt @@ -1,4 +1,4 @@ -torch==2.10.0 +torch==2.11.0 transformers==5.0.0 openvino==2026.2.1 optimum-intel[openvino]==2.0.0 diff --git a/examples/llm_compression/openvino/smollm2_360m_adaptive_codebook/requirements.txt b/examples/llm_compression/openvino/smollm2_360m_adaptive_codebook/requirements.txt index 89c81a4412f..c0b2c66fcf0 100644 --- a/examples/llm_compression/openvino/smollm2_360m_adaptive_codebook/requirements.txt +++ b/examples/llm_compression/openvino/smollm2_360m_adaptive_codebook/requirements.txt @@ -4,5 +4,5 @@ optimum-intel[openvino]==2.0.0 optimum==2.2.0 transformers==5.0.0 onnx==1.22.0 -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 diff --git a/examples/llm_compression/openvino/smollm2_360m_codebook/requirements.txt b/examples/llm_compression/openvino/smollm2_360m_codebook/requirements.txt index de2619dc081..9df341c1426 100644 --- a/examples/llm_compression/openvino/smollm2_360m_codebook/requirements.txt +++ b/examples/llm_compression/openvino/smollm2_360m_codebook/requirements.txt @@ -3,5 +3,5 @@ optimum-intel[openvino]==2.0.0 optimum==2.2.0 transformers==5.0.0 onnx==1.22.0 -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 diff --git a/examples/llm_compression/openvino/smollm2_360m_fp8/requirements.txt b/examples/llm_compression/openvino/smollm2_360m_fp8/requirements.txt index 7e594ef1ee2..f3468d06ec9 100644 --- a/examples/llm_compression/openvino/smollm2_360m_fp8/requirements.txt +++ b/examples/llm_compression/openvino/smollm2_360m_fp8/requirements.txt @@ -4,4 +4,4 @@ optimum-intel[openvino]==2.0.0 optimum==2.2.0 transformers==5.0.0 onnx==1.22.0 -torch==2.10.0 +torch==2.11.0 diff --git a/examples/llm_compression/openvino/tiny_llama/requirements.txt b/examples/llm_compression/openvino/tiny_llama/requirements.txt index 509e795236e..7f494f11c17 100644 --- a/examples/llm_compression/openvino/tiny_llama/requirements.txt +++ b/examples/llm_compression/openvino/tiny_llama/requirements.txt @@ -3,5 +3,5 @@ onnx==1.22.0 openvino==2026.2.1 optimum-intel[openvino]==2.0.0 optimum==2.2.0 -torch==2.10.0 +torch==2.11.0 transformers==5.0.0 diff --git a/examples/llm_compression/openvino/tiny_llama_find_hyperparams/requirements.txt b/examples/llm_compression/openvino/tiny_llama_find_hyperparams/requirements.txt index 69e59bd5b98..23a6caeef41 100644 --- a/examples/llm_compression/openvino/tiny_llama_find_hyperparams/requirements.txt +++ b/examples/llm_compression/openvino/tiny_llama_find_hyperparams/requirements.txt @@ -5,4 +5,4 @@ optimum-intel==2.0.0 optimum==2.2.0 transformers==5.0.0 onnx==1.22.0 -torch==2.10.0 +torch==2.11.0 diff --git a/examples/llm_compression/openvino/tiny_llama_synthetic_data/requirements.txt b/examples/llm_compression/openvino/tiny_llama_synthetic_data/requirements.txt index 90a653476ce..55dbb118eb3 100644 --- a/examples/llm_compression/openvino/tiny_llama_synthetic_data/requirements.txt +++ b/examples/llm_compression/openvino/tiny_llama_synthetic_data/requirements.txt @@ -1,4 +1,4 @@ -torch==2.10.0 +torch==2.11.0 datasets==5.0.0 numpy>=1.23.5,<2 openvino==2026.2.1 diff --git a/examples/llm_compression/torch/distillation_qat_with_lora/requirements.txt b/examples/llm_compression/torch/distillation_qat_with_lora/requirements.txt index d1294416579..1feadbe82d3 100644 --- a/examples/llm_compression/torch/distillation_qat_with_lora/requirements.txt +++ b/examples/llm_compression/torch/distillation_qat_with_lora/requirements.txt @@ -1,5 +1,5 @@ tensorboard==2.20.0 -torch==2.10.0 +torch==2.11.0 torchao==0.17.0 numpy>=1.23.5,<2 openvino==2026.2.1 diff --git a/examples/llm_compression/torch/downstream_qat_with_nls/requirements.txt b/examples/llm_compression/torch/downstream_qat_with_nls/requirements.txt index b8fde577db6..8273383b855 100644 --- a/examples/llm_compression/torch/downstream_qat_with_nls/requirements.txt +++ b/examples/llm_compression/torch/downstream_qat_with_nls/requirements.txt @@ -1,5 +1,5 @@ tensorboard==2.20.0 -torch==2.10.0 +torch==2.11.0 numpy>=1.23.5,<2 openvino==2026.2.1 optimum-intel==2.0.0 diff --git a/examples/llm_compression/torch_fx/tiny_llama/modelling.py b/examples/llm_compression/torch_fx/tiny_llama/modelling.py index d5cfeeb1e76..e03496d83ef 100644 --- a/examples/llm_compression/torch_fx/tiny_llama/modelling.py +++ b/examples/llm_compression/torch_fx/tiny_llama/modelling.py @@ -106,7 +106,7 @@ def convert_and_export_with_cache(model: PreTrainedModel) -> tuple[ExportedProgr dynamic_shapes = {"input_ids": {1: torch.export.Dim.DYNAMIC}, "cache_position": {0: torch.export.Dim.DYNAMIC}} - exported_program = torch.export.export_for_training( + exported_program = torch.export.export( model, args=( example_input_ids, diff --git a/examples/llm_compression/torch_fx/tiny_llama/requirements.txt b/examples/llm_compression/torch_fx/tiny_llama/requirements.txt index 973dafc1c83..1171c19f5ff 100644 --- a/examples/llm_compression/torch_fx/tiny_llama/requirements.txt +++ b/examples/llm_compression/torch_fx/tiny_llama/requirements.txt @@ -2,6 +2,6 @@ transformers==5.0.0 datasets==5.0.0 openvino==2026.2.1 optimum==2.2.0 -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 torchao==0.17.0 diff --git a/examples/post_training_quantization/onnx/mobilenet_v2/requirements.txt b/examples/post_training_quantization/onnx/mobilenet_v2/requirements.txt index 9dac86a4bbf..9443b033cf2 100644 --- a/examples/post_training_quantization/onnx/mobilenet_v2/requirements.txt +++ b/examples/post_training_quantization/onnx/mobilenet_v2/requirements.txt @@ -1,5 +1,5 @@ -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 fastdownload==0.0.7 fastprogress==1.0.5 fastcore==1.11.5 diff --git a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt index 0a2e51dd2aa..d61e2ef1301 100644 --- a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt +++ b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt @@ -3,4 +3,4 @@ onnx==1.22.0 onnxruntime==1.23.2; python_version < '3.11' onnxruntime==1.24.3; python_version >= '3.11' openvino==2026.2.1 -torch==2.10.0 +torch==2.11.0 diff --git a/examples/post_training_quantization/openvino/yolo26/requirements.txt b/examples/post_training_quantization/openvino/yolo26/requirements.txt index 6db9e7d0f5d..9e21c3078bc 100644 --- a/examples/post_training_quantization/openvino/yolo26/requirements.txt +++ b/examples/post_training_quantization/openvino/yolo26/requirements.txt @@ -1,4 +1,4 @@ ultralytics==8.4.21 onnx==1.22.0 openvino==2026.2.1 -torch==2.10.0 +torch==2.11.0 diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt index 80be7d7c5bd..34ae08537b3 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt @@ -1,4 +1,4 @@ ultralytics==8.3.221 onnx==1.22.0 openvino==2026.2.1 -torch==2.10.0 +torch==2.11.0 diff --git a/examples/post_training_quantization/torch/mobilenet_v2/requirements.txt b/examples/post_training_quantization/torch/mobilenet_v2/requirements.txt index e8a2959d2e8..2c9a4422f27 100644 --- a/examples/post_training_quantization/torch/mobilenet_v2/requirements.txt +++ b/examples/post_training_quantization/torch/mobilenet_v2/requirements.txt @@ -3,5 +3,5 @@ fastprogress==1.0.5 fastcore==1.11.5 openvino==2026.2.1 scikit-learn -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 diff --git a/examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt b/examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt index 5a9dcfce168..c888ebd914c 100644 --- a/examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt +++ b/examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt @@ -4,7 +4,7 @@ fastcore==1.11.5 onnx==1.22.0 openvino==2026.2.1 pycocotools==2.0.7 -torch==2.10.0 +torch==2.11.0 torchmetrics==1.0.1 -torchvision==0.25.0 +torchvision==0.26.0 numpy<2 diff --git a/examples/post_training_quantization/torch_fx/resnet18/requirements.txt b/examples/post_training_quantization/torch_fx/resnet18/requirements.txt index e80334f4ce8..9ce280028e6 100644 --- a/examples/post_training_quantization/torch_fx/resnet18/requirements.txt +++ b/examples/post_training_quantization/torch_fx/resnet18/requirements.txt @@ -2,6 +2,6 @@ fastdownload==0.0.7 fastprogress==1.0.5 fastcore==1.11.5 openvino==2026.2.1 -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 torchao==0.17.0 diff --git a/examples/pruning/torch/resnet18/requirements.txt b/examples/pruning/torch/resnet18/requirements.txt index 891f3000246..adfc542602b 100644 --- a/examples/pruning/torch/resnet18/requirements.txt +++ b/examples/pruning/torch/resnet18/requirements.txt @@ -2,5 +2,5 @@ fastdownload==0.0.7 fastprogress==1.0.5 fastcore==1.11.5 openvino==2026.2.1 -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 diff --git a/examples/quantization_aware_training/torch/anomalib/requirements.txt b/examples/quantization_aware_training/torch/anomalib/requirements.txt index 190f37056ba..8ec559dc405 100644 --- a/examples/quantization_aware_training/torch/anomalib/requirements.txt +++ b/examples/quantization_aware_training/torch/anomalib/requirements.txt @@ -1,5 +1,5 @@ anomalib==2.2.0 -torch==2.10.0 +torch==2.11.0 openvino==2025.3.0 requests==2.33.0 matplotlib==3.10.7 diff --git a/examples/quantization_aware_training/torch/resnet18/requirements.txt b/examples/quantization_aware_training/torch/resnet18/requirements.txt index 891f3000246..adfc542602b 100644 --- a/examples/quantization_aware_training/torch/resnet18/requirements.txt +++ b/examples/quantization_aware_training/torch/resnet18/requirements.txt @@ -2,5 +2,5 @@ fastdownload==0.0.7 fastprogress==1.0.5 fastcore==1.11.5 openvino==2026.2.1 -torch==2.10.0 -torchvision==0.25.0 +torch==2.11.0 +torchvision==0.26.0 diff --git a/src/nncf/torch/function_hook/handle_inner_functions.py b/src/nncf/torch/function_hook/handle_inner_functions.py index 33541ccc960..fe38d73a1d9 100644 --- a/src/nncf/torch/function_hook/handle_inner_functions.py +++ b/src/nncf/torch/function_hook/handle_inner_functions.py @@ -21,6 +21,7 @@ import torch from torch.nn.functional import _canonical_mask +from torch.nn.functional import _check_key_padding_mask # type:ignore[attr-defined] from torch.nn.functional import _in_projection # type:ignore[attr-defined] from torch.nn.functional import _in_projection_packed # type:ignore[attr-defined] from torch.nn.functional import _mha_shape_check # type:ignore[attr-defined] @@ -62,8 +63,10 @@ def multi_head_attention_forward( average_attn_weights: bool = True, is_causal: bool = False, ) -> Tuple[Tensor, Optional[Tensor]]: + is_batched = _mha_shape_check( + query, key, value, key_padding_mask, attn_mask, num_heads + ) - is_batched = _mha_shape_check(query, key, value, key_padding_mask, attn_mask, num_heads) if not is_batched: query = query.unsqueeze(1) key = key.unsqueeze(1) @@ -104,28 +107,48 @@ def multi_head_attention_forward( if key_padding_mask is not None: is_causal = False - assert ( - embed_dim == embed_dim_to_check - ), f"was expecting embedding dimension of {embed_dim_to_check}, but got {embed_dim}" + if embed_dim != embed_dim_to_check: + raise AssertionError( + f"was expecting embedding dimension of {embed_dim_to_check}, but got {embed_dim}" + ) if isinstance(embed_dim, torch.Tensor): head_dim = embed_dim.div(num_heads, rounding_mode="trunc") else: head_dim = embed_dim // num_heads - assert head_dim * num_heads == embed_dim, f"embed_dim {embed_dim} not divisible by num_heads {num_heads}" + if head_dim * num_heads != embed_dim: + raise AssertionError( + f"embed_dim {embed_dim} not divisible by num_heads {num_heads}" + ) if use_separate_proj_weight: - assert ( - key.shape[:2] == value.shape[:2] - ), f"key's sequence and batch dims {key.shape[:2]} do not match value's {value.shape[:2]}" + if key.shape[:2] != value.shape[:2]: + raise AssertionError( + f"key's sequence and batch dims {key.shape[:2]} do not match value's {value.shape[:2]}" + ) else: - assert key.shape == value.shape, f"key shape {key.shape} does not match value shape {value.shape}" + if key.shape != value.shape: + raise AssertionError( + f"key shape {key.shape} does not match value shape {value.shape}" + ) if not use_separate_proj_weight: - assert in_proj_weight is not None, "use_separate_proj_weight is False but in_proj_weight is None" + if in_proj_weight is None: + raise AssertionError( + "use_separate_proj_weight is False but in_proj_weight is None" + ) q, k, v = _in_projection_packed(query, key, value, in_proj_weight, in_proj_bias) else: - assert q_proj_weight is not None, "use_separate_proj_weight is True but q_proj_weight is None" - assert k_proj_weight is not None, "use_separate_proj_weight is True but k_proj_weight is None" - assert v_proj_weight is not None, "use_separate_proj_weight is True but v_proj_weight is None" + if q_proj_weight is None: + raise AssertionError( + "use_separate_proj_weight is True but q_proj_weight is None" + ) + if k_proj_weight is None: + raise AssertionError( + "use_separate_proj_weight is True but k_proj_weight is None" + ) + if v_proj_weight is None: + raise AssertionError( + "use_separate_proj_weight is True but v_proj_weight is None" + ) if in_proj_bias is None: b_q = b_k = b_v = None else: @@ -157,11 +180,15 @@ def multi_head_attention_forward( f"The shape of the 3D attn_mask is {attn_mask.shape}, but should be {correct_3d_size}." ) else: - raise RuntimeError(f"attn_mask's dimension {attn_mask.dim()} is not supported") + raise RuntimeError( + f"attn_mask's dimension {attn_mask.dim()} is not supported" + ) if bias_k is not None and bias_v is not None: - assert static_k is None, "bias cannot be added to static key." - assert static_v is None, "bias cannot be added to static value." + if static_k is not None: + raise AssertionError("bias cannot be added to static key.") + if static_v is not None: + raise AssertionError("bias cannot be added to static value.") k = torch.cat([k, bias_k.repeat(1, bsz, 1)]) v = torch.cat([v, bias_v.repeat(1, bsz, 1)]) if attn_mask is not None: @@ -169,31 +196,47 @@ def multi_head_attention_forward( if key_padding_mask is not None: key_padding_mask = pad(key_padding_mask, (0, 1)) else: - assert bias_k is None - assert bias_v is None + if bias_k is not None: + raise AssertionError("bias_k is set but bias_v is None") + if bias_v is not None: + raise AssertionError("bias_v is set but bias_k is None") q = q.view(tgt_len, bsz * num_heads, head_dim).transpose(0, 1) if static_k is None: k = k.view(k.shape[0], bsz * num_heads, head_dim).transpose(0, 1) else: - assert ( - static_k.size(0) == bsz * num_heads - ), f"expecting static_k.size(0) of {bsz * num_heads}, but got {static_k.size(0)}" - assert static_k.size(2) == head_dim, f"expecting static_k.size(2) of {head_dim}, but got {static_k.size(2)}" + if static_k.size(0) != bsz * num_heads: + raise AssertionError( + f"expecting static_k.size(0) of {bsz * num_heads}, but got {static_k.size(0)}" + ) + if static_k.size(2) != head_dim: + raise AssertionError( + f"expecting static_k.size(2) of {head_dim}, but got {static_k.size(2)}" + ) k = static_k if static_v is None: v = v.view(v.shape[0], bsz * num_heads, head_dim).transpose(0, 1) else: - assert ( - static_v.size(0) == bsz * num_heads - ), f"expecting static_v.size(0) of {bsz * num_heads}, but got {static_v.size(0)}" - assert static_v.size(2) == head_dim, f"expecting static_v.size(2) of {head_dim}, but got {static_v.size(2)}" + if static_v.size(0) != bsz * num_heads: + raise AssertionError( + f"expecting static_v.size(0) of {bsz * num_heads}, but got {static_v.size(0)}" + ) + if static_v.size(2) != head_dim: + raise AssertionError( + f"expecting static_v.size(2) of {head_dim}, but got {static_v.size(2)}" + ) v = static_v if add_zero_attn: zero_attn_shape = (bsz * num_heads, 1, head_dim) - k = torch.cat([k, torch.zeros(zero_attn_shape, dtype=k.dtype, device=k.device)], dim=1) - v = torch.cat([v, torch.zeros(zero_attn_shape, dtype=v.dtype, device=v.device)], dim=1) + k = torch.cat( + [k, torch.zeros(zero_attn_shape, dtype=k.dtype, device=k.device)], + dim=1, + ) + v = torch.cat( + [v, torch.zeros(zero_attn_shape, dtype=v.dtype, device=v.device)], + dim=1, + ) if attn_mask is not None: attn_mask = pad(attn_mask, (0, 1)) if key_padding_mask is not None: @@ -203,10 +246,12 @@ def multi_head_attention_forward( if key_padding_mask is not None: if not torch.jit.is_scripting() and not torch.jit.is_tracing(): # type: ignore - _check_key_padding_mask(key_padding_mask, src_len, bsz) # type: ignore + _check_key_padding_mask(key_padding_mask, src_len, bsz) key_padding_mask = ( - key_padding_mask.view(bsz, 1, 1, src_len).expand(-1, num_heads, -1, -1).reshape(bsz * num_heads, 1, src_len) + key_padding_mask.view(bsz, 1, 1, src_len) + .expand(-1, num_heads, -1, -1) + .reshape(bsz * num_heads, 1, src_len) ) if attn_mask is None: attn_mask = key_padding_mask @@ -217,13 +262,16 @@ def multi_head_attention_forward( dropout_p = 0.0 if need_weights: - _B, _Nt, E = q.shape # noqa: F841 + _B, _Nt, E = q.shape q_scaled = q * math.sqrt(1.0 / float(E)) - assert not (is_causal and attn_mask is None), "FIXME: is_causal not implemented for need_weights" + if is_causal and attn_mask is None: + raise AssertionError("FIXME: is_causal not implemented for need_weights") if attn_mask is not None: - attn_output_weights = torch.baddbmm(attn_mask, q_scaled, k.transpose(-2, -1)) + attn_output_weights = torch.baddbmm( + attn_mask, q_scaled, k.transpose(-2, -1) + ) else: attn_output_weights = torch.bmm(q_scaled, k.transpose(-2, -1)) attn_output_weights = softmax(attn_output_weights, dim=-1) @@ -232,7 +280,9 @@ def multi_head_attention_forward( attn_output = torch.bmm(attn_output_weights, v) - attn_output = attn_output.transpose(0, 1).contiguous().view(tgt_len * bsz, embed_dim) + attn_output = ( + attn_output.transpose(0, 1).contiguous().view(tgt_len * bsz, embed_dim) + ) attn_output = linear(attn_output, out_proj_weight, out_proj_bias) attn_output = attn_output.view(tgt_len, bsz, attn_output.size(1)) @@ -255,8 +305,12 @@ def multi_head_attention_forward( k = k.view(bsz, num_heads, src_len, head_dim) v = v.view(bsz, num_heads, src_len, head_dim) - attn_output = scaled_dot_product_attention(q, k, v, attn_mask, dropout_p, is_causal) - attn_output = attn_output.permute(2, 0, 1, 3).contiguous().view(bsz * tgt_len, embed_dim) + attn_output = scaled_dot_product_attention( + q, k, v, attn_mask, dropout_p, is_causal + ) + attn_output = ( + attn_output.permute(2, 0, 1, 3).contiguous().view(bsz * tgt_len, embed_dim) + ) attn_output = linear(attn_output, out_proj_weight, out_proj_bias) attn_output = attn_output.view(tgt_len, bsz, attn_output.size(1)) diff --git a/tests/cross_fw/examples/example_scope.json b/tests/cross_fw/examples/example_scope.json index 11857c49c16..a88d543ddca 100644 --- a/tests/cross_fw/examples/example_scope.json +++ b/tests/cross_fw/examples/example_scope.json @@ -355,14 +355,5 @@ "accuracy_metrics": { "acc1": 54.96 } - }, - "llm_compression_torch_gptqmodel_convertor": { - "backend": "torch", - "device": "cuda", - "requirements": "examples/llm_compression/torch/gptq_model_convertor/requirements.txt", - "extra_requirements": "examples/llm_compression/torch/gptq_model_convertor/requirements_extra.txt", - "accuracy_metrics": { - "word_count": 28 - } } } diff --git a/tests/post_training/pipelines/fx_modelling.py b/tests/post_training/pipelines/fx_modelling.py index 61b077d6761..0dc08a42aab 100644 --- a/tests/post_training/pipelines/fx_modelling.py +++ b/tests/post_training/pipelines/fx_modelling.py @@ -93,7 +93,7 @@ def convert_and_export_with_cache(model: PreTrainedModel): dynamic_shapes = {"input_ids": {1: torch.export.Dim.DYNAMIC}, "cache_position": {0: torch.export.Dim.DYNAMIC}} - exported_program = torch.export.export_for_training( + exported_program = torch.export.export( model, args=( example_input_ids, diff --git a/tests/post_training/pipelines/image_classification_torchvision.py b/tests/post_training/pipelines/image_classification_torchvision.py index 7fe8815edd4..f25d5eddaa7 100644 --- a/tests/post_training/pipelines/image_classification_torchvision.py +++ b/tests/post_training/pipelines/image_classification_torchvision.py @@ -24,8 +24,8 @@ from tests.post_training.pipelines.image_classification_base import ImageClassificationBase -def _torch_export_for_training(model: torch.nn.Module, args: tuple[Any, ...]) -> torch.fx.GraphModule: - return torch.export.export_for_training(model, args, strict=True).module(check_guards=False) +def _torch_export(model: torch.nn.Module, args: tuple[Any, ...]) -> torch.fx.GraphModule: + return torch.export.export(model, args, strict=True).module(check_guards=False) def _torch_export(model: torch.nn.Module, args: tuple[Any, ...]) -> torch.fx.GraphModule: @@ -43,13 +43,11 @@ class ImageClassificationTorchvision(ImageClassificationBase): """Pipeline for Image Classification model from torchvision repository""" models_vs_model_params = { - models.resnet18: VisionModelParams(models.ResNet18_Weights.DEFAULT, _torch_export_for_training), - models.mobilenet_v3_small: VisionModelParams( - models.MobileNet_V3_Small_Weights.DEFAULT, _torch_export_for_training - ), + models.resnet18: VisionModelParams(models.ResNet18_Weights.DEFAULT, _torch_export), + models.mobilenet_v3_small: VisionModelParams(models.MobileNet_V3_Small_Weights.DEFAULT, _torch_export), models.vit_b_16: VisionModelParams( models.ViT_B_16_Weights.DEFAULT, - _torch_export_for_training, + _torch_export, export_torch_before_ov_convert=False, # OV convert of exported model has issues Issue-162009 ), models.swin_v2_s: VisionModelParams( diff --git a/tests/torch/conftest.py b/tests/torch/conftest.py index 7af6044fbf9..286cc8bdd6a 100644 --- a/tests/torch/conftest.py +++ b/tests/torch/conftest.py @@ -22,13 +22,6 @@ from nncf.common.quantization.structs import QuantizationScheme -@pytest.fixture(scope="session", autouse=True) -def disable_tf32_precision(): - if torch: - torch.backends.cuda.matmul.fp32_precision = "ieee" - torch.backends.cudnn.conv.fp32_precision = "ieee" - - def pytest_addoption(parser: Parser): parser.addoption( "--regen-ref-data", diff --git a/tests/torch/function_hook/test_wrapper.py b/tests/torch/function_hook/test_wrapper.py index ac3d9b59f7a..833bb1f7b91 100644 --- a/tests/torch/function_hook/test_wrapper.py +++ b/tests/torch/function_hook/test_wrapper.py @@ -177,7 +177,7 @@ def test_compile_via_trace(): torch.testing.assert_close(actual, return_origin + ADD_VALUE) -@pytest.mark.parametrize("dynamo", [True, False]) +@pytest.mark.parametrize("dynamo", [True, False], ids=["dynamo", "no_dynamo"]) def test_export_onnx(tmp_path: Path, dynamo: bool): example_input = helpers.ConvModel.get_example_inputs() diff --git a/tests/torch/fx/helpers.py b/tests/torch/fx/helpers.py index 24d451b8b9a..70a6bb51e61 100644 --- a/tests/torch/fx/helpers.py +++ b/tests/torch/fx/helpers.py @@ -54,13 +54,9 @@ def get_torch_fx_model( device_ex_input.append(inp.to(device)) device_ex_input = tuple(device_ex_input) - # Temporary workaround for executorch tests. Can be removed once torch>=2.11.0 - export_fn = ( - torch.export.export_for_training if hasattr(torch.export, "export_for_training") else torch.export.export - ) model.eval() with torch.no_grad(): - return export_fn(model, args=device_ex_input, dynamic_shapes=dynamic_shapes, strict=True).module( + return torch.export.export(model, args=device_ex_input, dynamic_shapes=dynamic_shapes, strict=True).module( check_guards=False ) diff --git a/tests/torch/fx/test_model_transformer.py b/tests/torch/fx/test_model_transformer.py index ab0095a5b6c..f0ce234bcf4 100644 --- a/tests/torch/fx/test_model_transformer.py +++ b/tests/torch/fx/test_model_transformer.py @@ -586,8 +586,6 @@ def test_constant_folding_scalar_clone(use_cuda): ex_input = torch.ones(model.INPUT_SIZE).cuda() with torch.no_grad(): - # Use export function instead of export_for_training to - # reproduce SWIN model capturing captured_model = ( torch.export.export(model, args=(ex_input,), strict=True) .run_decompositions(decomp_table={}) diff --git a/tests/torch/test_tensor.py b/tests/torch/test_tensor.py index 39dff94e985..fa631f3eb4e 100644 --- a/tests/torch/test_tensor.py +++ b/tests/torch/test_tensor.py @@ -13,6 +13,7 @@ from nncf.tensor import Tensor from nncf.tensor import TensorDataType +from nncf.tensor import functions as fns from nncf.tensor.definitions import TensorBackend from nncf.tensor.definitions import TensorDeviceType from tests.cross_fw.test_templates.template_test_nncf_tensor import TemplateTestNNCFTensorOperators @@ -76,3 +77,21 @@ def backend() -> TensorBackend: @staticmethod def device() -> TensorDeviceType: return TensorDeviceType.GPU + + # TODO(AlexanderDokuchaev): Some tests cases failed on t4, ticket: 184285 + @pytest.mark.parametrize( + "a, upper, ref", + ( + ([[1.0, 0.0], [2.0, 1.0]], False, [[5.0, -2.0], [-2.0, 1.0]]), + ([[1.0, 2.0], [0.0, 1.0]], True, [[5.0, -2.0], [-2.0, 1.0]]), + ), + ) + def test_fn_linalg_cholesky_inverse(self, a, upper, ref): + tensor_a = Tensor(self.to_tensor(a)) + ref_tensor = self.to_tensor(ref) + + res = fns.linalg.cholesky_inverse(tensor_a, upper=upper) + + assert isinstance(res, Tensor) + assert fns.allclose(res.data, ref_tensor) + assert res.device == tensor_a.device