Skip to content

Commit

Permalink
Fix test examples on windows (openvinotoolkit#3045)
Browse files Browse the repository at this point in the history
### Changes

- `setuptools<=72.1.0` to avoid issue `Could not compile CPU
quantization extensions. Falling back on torch native operations - CPU
quantization fine-tuning may be slower than expected.` on windows.
- Add catch `BackendCompilerFailed` exception for
`post_training_quantization_torch_fx_resnet18`
- Bump version of anomalib to 1.0.1
`quantization_aware_training_torch_resnet18` tests on windows

### Related tickets

155866
  • Loading branch information
AlexanderDokuchaev authored Oct 30, 2024
1 parent 7576aef commit 688c81e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ openvino==2024.4
scikit-learn
torch==2.4.0
torchvision==0.19.0
setuptools<=72.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ torch==2.4.0
torchmetrics==1.0.1
torchvision==0.19.0
numpy<2
setuptools<=72.1.0
13 changes: 12 additions & 1 deletion examples/post_training_quantization/torch_fx/resnet18/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import torchvision.models as models
import torchvision.transforms as transforms
from fastdownload import FastDownload
from torch._dynamo.exc import BackendCompilerFailed

import nncf
import nncf.torch
from nncf.common.logging.track_progress import track
from nncf.common.utils.helpers import create_table
from nncf.common.utils.os import is_windows
from nncf.torch import disable_patching

IMAGE_SIZE = 64
Expand Down Expand Up @@ -205,7 +207,16 @@ def transform_fn(data_item):
print("Benchmark FP32 model compiled with default backend ...")
with disable_patching():
compiled_model = torch.compile(model)
fp32_latency = measure_latency(compiled_model, example_inputs=example_input)
try:
fp32_latency = measure_latency(compiled_model, example_inputs=example_input)
except BackendCompilerFailed as exp:
if not is_windows():
raise exp
print(
"WARNING: Torch Inductor is currently unavailable on Windows. "
"For more information, visit https://github.com/pytorch/pytorch/issues/135954"
)
fp32_latency = float("nan")
print(f"{fp32_latency:.3f} ms")

print("Benchmark FP32 model compiled with openvino backend ...")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
anomalib[core,openvino]==1.0.0
anomalib[core,openvino]==1.0.1
setuptools<=72.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ fastdownload==0.0.7
openvino==2024.4
torch==2.4.0
torchvision==0.19.0
setuptools<=72.1.0

0 comments on commit 688c81e

Please sign in to comment.