Skip to content

Commit f574a1f

Browse files
[GHA] windows precommit (#3194)
### Changes Run test from precommit test scope in nightly trigger - pt2: use fixed parameters for .T, _saved_dim0/1 depends from os, but actual value always -1, -2 - onnx: build model only inside test function, not in collect parameters, to more effective use memory - common: use `1.2` s for test timer, to be sure that will be catch 00:00:01 NOTE: pt test falls in case of parallel run on build quantization extension. ### Tests https://github.com/openvinotoolkit/nncf/actions/runs/12835288745/job/35794407928?pr=3194
1 parent 874f16a commit f574a1f

File tree

8 files changed

+261
-116
lines changed

8 files changed

+261
-116
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: call-precommit
2+
permissions: read-all
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
python_version:
8+
description: 'Python version'
9+
type: string
10+
required: true
11+
override_requirements:
12+
description: 'Override requirements'
13+
default: ''
14+
type: string
15+
required: false
16+
17+
jobs:
18+
common:
19+
timeout-minutes: 40
20+
runs-on: windows-2019
21+
defaults:
22+
run:
23+
shell: bash
24+
steps:
25+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
26+
with:
27+
lfs: true
28+
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
29+
with:
30+
python-version: ${{ inputs.python_version }}
31+
- name: Override constraints
32+
if: ${{ inputs.override_requirements != '' }}
33+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
34+
shell: bash
35+
- name: Install NNCF and test requirements
36+
run: pip install . -r tests/common/requirements.txt
37+
- name: Print installed modules
38+
run: pip list
39+
- name: Run common precommit test scope
40+
run: make test-common
41+
env:
42+
NUM_WORKERS: 2
43+
44+
onnx:
45+
timeout-minutes: 40
46+
runs-on: windows-2019-8-core
47+
defaults:
48+
run:
49+
shell: bash
50+
steps:
51+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
52+
with:
53+
lfs: true
54+
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
55+
with:
56+
python-version: ${{ inputs.python_version }}
57+
- name: Override constraints
58+
if: ${{ inputs.override_requirements != '' }}
59+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
60+
shell: bash
61+
- name: Install NNCF and test requirements
62+
run: pip install . -r tests/onnx/requirements.txt
63+
- name: Print installed modules
64+
run: pip list
65+
- name: Run ONNX precommit test scope
66+
run: make test-onnx
67+
env:
68+
NUM_WORKERS: 4
69+
70+
openvino:
71+
timeout-minutes: 40
72+
runs-on: windows-2019-8-core
73+
defaults:
74+
run:
75+
shell: bash
76+
steps:
77+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
78+
with:
79+
lfs: true
80+
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
81+
with:
82+
python-version: ${{ inputs.python_version }}
83+
- name: Override constraints
84+
if: ${{ inputs.override_requirements != '' }}
85+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
86+
shell: bash
87+
- name: Install NNCF and test requirements
88+
run: pip install . -r tests/openvino/requirements.txt
89+
- name: Print installed modules
90+
run: pip list
91+
- name: Run OV precommit test scope
92+
run: make test-openvino
93+
env:
94+
NUM_WORKERS: 4
95+
96+
pytorch-cpu:
97+
timeout-minutes: 100
98+
runs-on: windows-2019-8-core
99+
defaults:
100+
run:
101+
shell: bash
102+
env:
103+
DEBIAN_FRONTEND: noninteractive
104+
steps:
105+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
106+
with:
107+
lfs: true
108+
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
109+
with:
110+
python-version: ${{ inputs.python_version }}
111+
- uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1
112+
- name: Override constraints
113+
if: ${{ inputs.override_requirements != '' }}
114+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
115+
shell: bash
116+
- name: Install NNCF and test requirements
117+
run: pip install . -r tests/torch/requirements.txt
118+
- name: Print installed modules
119+
run: pip list
120+
- name: Run PyTorch precommit test scope
121+
run: |
122+
set +e
123+
export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")"
124+
export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")"
125+
export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")"
126+
make test-torch-cpu
127+
env:
128+
NUM_WORKERS: 1 # Parallel tests are falls on build extenstion.
129+
130+
tensorflow:
131+
timeout-minutes: 40
132+
runs-on: windows-2019-8-core
133+
if: ${{ inputs.python_version != '3.12' }}
134+
defaults:
135+
run:
136+
shell: bash
137+
env:
138+
DEBIAN_FRONTEND: noninteractive
139+
steps:
140+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
141+
with:
142+
lfs: true
143+
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
144+
with:
145+
python-version: ${{ inputs.python_version }}
146+
- name: Override constraints
147+
if: ${{ inputs.override_requirements != '' }}
148+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
149+
shell: bash
150+
- name: Install NNCF and test requirements
151+
run: pip install . -r tests/tensorflow/requirements.txt
152+
- name: Print installed modules
153+
run: pip list
154+
- name: Run TensorFlow precommit test scope
155+
run: make test-tensorflow
156+
env:
157+
NUM_WORKERS: 6
158+
159+
pytorch2-cpu:
160+
timeout-minutes: 40
161+
runs-on: windows-2019-8-core
162+
defaults:
163+
run:
164+
shell: bash
165+
steps:
166+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
167+
with:
168+
lfs: true
169+
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
170+
with:
171+
python-version: ${{ inputs.python_version }}
172+
- uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1
173+
- name: Override constraints
174+
if: ${{ inputs.override_requirements != '' }}
175+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
176+
shell: bash
177+
- name: Install NNCF and test requirements
178+
run: |
179+
pip install . -r tests/torch2/requirements.txt
180+
- name: Print installed modules
181+
run: pip list
182+
- name: Run torch2 precommit test scope
183+
run: |
184+
set +e
185+
export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")"
186+
export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")"
187+
export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")"
188+
pytest -ra tests/torch2 -m "not cuda"

.github/workflows/nightly.yml

+6
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ jobs:
4949
weight-compression:
5050
if: github.repository_owner == 'openvinotoolkit'
5151
uses: ./.github/workflows/conformance_weight_compression.yml
52+
53+
precommit-windows:
54+
if: github.repository_owner == 'openvinotoolkit'
55+
uses: ./.github/workflows/call_precommit_windows.yml
56+
with:
57+
python_version: "3.10"

nncf/experimental/torch2/function_hook/graph/build_graph_mode.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ def process_tensor_attributes(self, output: torch.Tensor, op_meta: OpMeta) -> No
192192
if output.grad_fn.name() == "TransposeBackward0":
193193
fn_name = "transpose"
194194
# grad_fn collect arguments as _saved_dim0=18446744073709551614
195+
# Use static arguments for .mT
196+
# https://pytorch.org/docs/stable/tensors.html#torch.Tensor.mT
195197
fn_kwargs = {
196-
"dim0": -(2**64 - output.grad_fn._saved_dim0), # type: ignore[attr-defined]
197-
"dim1": -(2**64 - output.grad_fn._saved_dim1), # type: ignore[attr-defined]
198+
"dim0": -2,
199+
"dim1": -1,
198200
}
199201
if output.grad_fn.name() == "PermuteBackward0":
200202
fn_name = "permute"

tests/common/utils/test_timer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
def test_timer(nncf_caplog):
1919
with timer() as t:
20-
time.sleep(1)
20+
time.sleep(1.2)
2121

2222
t()
2323

tests/onnx/quantization/test_classification_models_graph.py

+42-57
Original file line numberDiff line numberDiff line change
@@ -22,72 +22,56 @@
2222
from tests.onnx.quantization.common import mock_collect_statistics
2323
from tests.onnx.weightless_model import load_model_topology_with_zeros_weights
2424

25+
26+
def model_builder(model_name):
27+
if model_name == "resnet18":
28+
return models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1)
29+
if model_name == "resnet50_cpu_spr":
30+
return models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1)
31+
if model_name == "mobilenet_v2":
32+
return models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1)
33+
if model_name == "mobilenet_v3_small":
34+
return models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1)
35+
if model_name == "inception_v3":
36+
return models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1)
37+
if model_name == "googlenet":
38+
return models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1)
39+
if model_name == "vgg16":
40+
return models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1)
41+
if model_name == "shufflenet_v2_x1_0":
42+
return models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1)
43+
if model_name == "squeezenet1_0":
44+
return models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1)
45+
if model_name == "densenet121":
46+
return models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1)
47+
if model_name == "mnasnet0_5":
48+
return models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1)
49+
raise ValueError(f"Unknown model name {model_name}")
50+
51+
2552
TORCHVISION_TEST_DATA = [
26-
(
27-
ModelToTest("resnet18", [1, 3, 224, 224]),
28-
models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1),
29-
{},
30-
),
31-
(
32-
ModelToTest("resnet50_cpu_spr", [1, 3, 224, 224]),
33-
models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1),
34-
{"target_device": TargetDevice.CPU_SPR},
35-
),
36-
(
37-
ModelToTest("mobilenet_v2", [1, 3, 224, 224]),
38-
models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1),
39-
{},
40-
),
41-
(
42-
ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]),
43-
models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1),
44-
{},
45-
),
46-
(
47-
ModelToTest("inception_v3", [1, 3, 224, 224]),
48-
models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1),
49-
{},
50-
),
51-
(
52-
ModelToTest("googlenet", [1, 3, 224, 224]),
53-
models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1),
54-
{},
55-
),
56-
(
57-
ModelToTest("vgg16", [1, 3, 224, 224]),
58-
models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1),
59-
{},
60-
),
61-
(
62-
ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]),
63-
models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1),
64-
{},
65-
),
66-
(
67-
ModelToTest("squeezenet1_0", [1, 3, 224, 224]),
68-
models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1),
69-
{},
70-
),
71-
(
72-
ModelToTest("densenet121", [1, 3, 224, 224]),
73-
models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1),
74-
{},
75-
),
76-
(
77-
ModelToTest("mnasnet0_5", [1, 3, 224, 224]),
78-
models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1),
79-
{},
80-
),
53+
(ModelToTest("resnet18", [1, 3, 224, 224]), {}),
54+
(ModelToTest("resnet50_cpu_spr", [1, 3, 224, 224]), {"target_device": TargetDevice.CPU_SPR}),
55+
(ModelToTest("mobilenet_v2", [1, 3, 224, 224]), {}),
56+
(ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]), {}),
57+
(ModelToTest("inception_v3", [1, 3, 224, 224]), {}),
58+
(ModelToTest("googlenet", [1, 3, 224, 224]), {}),
59+
(ModelToTest("vgg16", [1, 3, 224, 224]), {}),
60+
(ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]), {}),
61+
(ModelToTest("squeezenet1_0", [1, 3, 224, 224]), {}),
62+
(ModelToTest("densenet121", [1, 3, 224, 224]), {}),
63+
(ModelToTest("mnasnet0_5", [1, 3, 224, 224]), {}),
8164
]
8265

8366

8467
@pytest.mark.parametrize(
85-
("model_to_test", "model", "quantization_parameters"),
68+
("model_to_test", "quantization_parameters"),
8669
TORCHVISION_TEST_DATA,
8770
ids=[model_to_test[0].model_name for model_to_test in TORCHVISION_TEST_DATA],
8871
)
89-
def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, model, quantization_parameters):
72+
def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, quantization_parameters):
9073
mock_collect_statistics(mocker)
74+
model = model_builder(model_to_test.model_name)
9175
onnx_model_path = tmp_path / (model_to_test.model_name + ".onnx")
9276
x = torch.randn(model_to_test.input_shape, requires_grad=False)
9377
torch.onnx.export(model, x, onnx_model_path, opset_version=13)
@@ -105,6 +89,7 @@ def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_t
10589
)
10690
def test_min_max_quantization_graph_onnx_model(tmp_path, mocker, model_to_test):
10791
mock_collect_statistics(mocker)
92+
10893
onnx_model_path = ONNX_MODEL_DIR / (model_to_test.model_name + ".onnx")
10994
original_model = load_model_topology_with_zeros_weights(onnx_model_path)
11095

0 commit comments

Comments
 (0)