Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[GHA] windows precommit #3194

Merged
188 changes: 188 additions & 0 deletions .github/workflows/call_precommit_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
name: call-precommit
permissions: read-all

on:
workflow_call:
inputs:
python_version:
description: 'Python version'
type: string
required: true
override_requirements:
description: 'Override requirements'
default: ''
type: string
required: false

jobs:
common:
timeout-minutes: 40
runs-on: windows-2019
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python_version }}
- 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: pip install . -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: windows-2019-8-core
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python_version }}
- 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: pip install . -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: windows-2019-8-core
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python_version }}
- 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: pip install . -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

pytorch-cpu:
timeout-minutes: 100
runs-on: windows-2019-8-core
defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python_version }}
- uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1
- 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: pip install . -r tests/torch/requirements.txt
- name: Print installed modules
run: pip list
- name: Run PyTorch precommit test scope
run: |
set +e
export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")"
export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")"
export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")"
make test-torch-cpu
env:
NUM_WORKERS: 1 # Parallel tests are falls on build extenstion.

tensorflow:
timeout-minutes: 40
runs-on: windows-2019-8-core
if: ${{ inputs.python_version != '3.12' }}
defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python_version }}
- 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: pip install . -r tests/tensorflow/requirements.txt
- name: Print installed modules
run: pip list
- name: Run TensorFlow precommit test scope
run: make test-tensorflow
env:
NUM_WORKERS: 6

pytorch2-cpu:
timeout-minutes: 40
runs-on: windows-2019-8-core
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python_version }}
- uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1
- 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: |
pip install . -r tests/torch2/requirements.txt
- name: Print installed modules
run: pip list
- name: Run torch2 precommit test scope
run: |
set +e
export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")"
export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")"
export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")"
pytest -ra tests/torch2 -m "not cuda"
6 changes: 6 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ jobs:
weight-compression:
if: github.repository_owner == 'openvinotoolkit'
uses: ./.github/workflows/conformance_weight_compression.yml

precommit-windows:
if: github.repository_owner == 'openvinotoolkit'
uses: ./.github/workflows/call_precommit_windows.yml
with:
python_version: "3.10"
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ def process_tensor_attributes(self, output: torch.Tensor, op_meta: OpMeta) -> No
if output.grad_fn.name() == "TransposeBackward0":
fn_name = "transpose"
# grad_fn collect arguments as _saved_dim0=18446744073709551614
# Use static arguments for .mT
# https://pytorch.org/docs/stable/tensors.html#torch.Tensor.mT
fn_kwargs = {
"dim0": -(2**64 - output.grad_fn._saved_dim0), # type: ignore[attr-defined]
"dim1": -(2**64 - output.grad_fn._saved_dim1), # type: ignore[attr-defined]
"dim0": -2,
"dim1": -1,
}
if output.grad_fn.name() == "PermuteBackward0":
fn_name = "permute"
Expand Down
2 changes: 1 addition & 1 deletion tests/common/utils/test_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def test_timer(nncf_caplog):
with timer() as t:
time.sleep(1)
kshpv marked this conversation as resolved.
Show resolved Hide resolved
time.sleep(1.2)

t()

Expand Down
99 changes: 42 additions & 57 deletions tests/onnx/quantization/test_classification_models_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,72 +22,56 @@
from tests.onnx.quantization.common import mock_collect_statistics
from tests.onnx.weightless_model import load_model_topology_with_zeros_weights


def model_builder(model_name):
if model_name == "resnet18":
kshpv marked this conversation as resolved.
Show resolved Hide resolved
return models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1)
if model_name == "resnet50_cpu_spr":
return models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1)
if model_name == "mobilenet_v2":
return models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1)
if model_name == "mobilenet_v3_small":
return models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1)
if model_name == "inception_v3":
return models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1)
if model_name == "googlenet":
return models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1)
if model_name == "vgg16":
return models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1)
if model_name == "shufflenet_v2_x1_0":
return models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1)
if model_name == "squeezenet1_0":
return models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1)
if model_name == "densenet121":
return models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1)
if model_name == "mnasnet0_5":
return models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1)
raise ValueError(f"Unknown model name {model_name}")


TORCHVISION_TEST_DATA = [
(
ModelToTest("resnet18", [1, 3, 224, 224]),
models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("resnet50_cpu_spr", [1, 3, 224, 224]),
models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1),
{"target_device": TargetDevice.CPU_SPR},
),
(
ModelToTest("mobilenet_v2", [1, 3, 224, 224]),
models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]),
models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("inception_v3", [1, 3, 224, 224]),
models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("googlenet", [1, 3, 224, 224]),
models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("vgg16", [1, 3, 224, 224]),
models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]),
models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("squeezenet1_0", [1, 3, 224, 224]),
models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("densenet121", [1, 3, 224, 224]),
models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1),
{},
),
(
ModelToTest("mnasnet0_5", [1, 3, 224, 224]),
models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1),
{},
),
(ModelToTest("resnet18", [1, 3, 224, 224]), {}),
(ModelToTest("resnet50_cpu_spr", [1, 3, 224, 224]), {"target_device": TargetDevice.CPU_SPR}),
(ModelToTest("mobilenet_v2", [1, 3, 224, 224]), {}),
(ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]), {}),
(ModelToTest("inception_v3", [1, 3, 224, 224]), {}),
(ModelToTest("googlenet", [1, 3, 224, 224]), {}),
(ModelToTest("vgg16", [1, 3, 224, 224]), {}),
(ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]), {}),
(ModelToTest("squeezenet1_0", [1, 3, 224, 224]), {}),
(ModelToTest("densenet121", [1, 3, 224, 224]), {}),
(ModelToTest("mnasnet0_5", [1, 3, 224, 224]), {}),
]


@pytest.mark.parametrize(
("model_to_test", "model", "quantization_parameters"),
("model_to_test", "quantization_parameters"),
TORCHVISION_TEST_DATA,
ids=[model_to_test[0].model_name for model_to_test in TORCHVISION_TEST_DATA],
)
def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, model, quantization_parameters):
def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, quantization_parameters):
mock_collect_statistics(mocker)
model = model_builder(model_to_test.model_name)
onnx_model_path = tmp_path / (model_to_test.model_name + ".onnx")
x = torch.randn(model_to_test.input_shape, requires_grad=False)
torch.onnx.export(model, x, onnx_model_path, opset_version=13)
Expand All @@ -105,6 +89,7 @@ def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_t
)
def test_min_max_quantization_graph_onnx_model(tmp_path, mocker, model_to_test):
mock_collect_statistics(mocker)

onnx_model_path = ONNX_MODEL_DIR / (model_to_test.model_name + ".onnx")
original_model = load_model_topology_with_zeros_weights(onnx_model_path)

Expand Down
Loading