OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[PT FE] Enable PyTorch tests on ARM CPU (#29664)
Arseniy Obolenskiy8e94a1d1a1b6
diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tagindex 291a918972d..55feab17485 100644--- a/.github/dockerfiles/docker_tag+++ b/.github/dockerfiles/docker_tag@@ -1 +1 @@-pr-33859+pr-29664diff --git a/.github/dockerfiles/ov_test/ubuntu_22_04_arm64/Dockerfile b/.github/dockerfiles/ov_test/ubuntu_22_04_arm64/Dockerfileindex 4d2eaf82e2c..dcc40bac7c4 100644--- a/.github/dockerfiles/ov_test/ubuntu_22_04_arm64/Dockerfile+++ b/.github/dockerfiles/ov_test/ubuntu_22_04_arm64/Dockerfile@@ -33,6 +33,13 @@ RUN apt-get update && \python3.11-distutils \libhdf5-dev \libgomp1 \+ # libGL for PyTorch Models tests+ ffmpeg \+ libsm6 \+ libxext6 \+ libgl1 \+ libgl1-mesa-glx \+ libglib2.0-0 \&& \rm -rf /var/lib/apt/lists/*diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.ymlindex 4d00081b1d6..49c7200f007 100644--- a/.github/workflows/linux_arm64.yml+++ b/.github/workflows/linux_arm64.yml@@ -270,9 +270,8 @@ jobs:PyTorch_Models_Tests:name: PyTorch Models tests- if: ${{ 'false' }} # TODO: Enable once the dependencies are ready for arm (no tensorflow-text available for arm from PyPI)- # if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test- needs: [ Build, Docker, Smart_CI ]+ if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test+ needs: [ Build, Docker, Smart_CI, Openvino_tokenizers ]uses: ./.github/workflows/job_pytorch_models_tests.ymlwith:runner: 'aks-linux-16-cores-32gb-arm'diff --git a/tests/model_hub_tests/pytorch/test_aliked.py b/tests/model_hub_tests/pytorch/test_aliked.pyindex 7fd25a8b354..c738a2a726d 100644--- a/tests/model_hub_tests/pytorch/test_aliked.py+++ b/tests/model_hub_tests/pytorch/test_aliked.py@@ -3,6 +3,7 @@import mathimport os+import platformimport subprocessimport sysimport tempfile@@ -120,9 +121,15 @@ class TestAlikedConvertModel(TestTorchConvertModel):# remove all downloaded files from cacheself.repo_dir.cleanup()+ def get_supported_precommit_models():+ models = []+ if platform.machine() not in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ models.extend(['aliked-n16rot'])+ return models+@pytest.mark.nightly@pytest.mark.precommit- @pytest.mark.parametrize("name", ['aliked-n16rot'])+ @pytest.mark.parametrize("name", get_supported_precommit_models())def test_convert_model_all_models_default(self, name, ie_device):self.run(name, None, ie_device)diff --git a/tests/model_hub_tests/pytorch/test_detectron2.py b/tests/model_hub_tests/pytorch/test_detectron2.pyindex ce87001deee..6ac10caa870 100644--- a/tests/model_hub_tests/pytorch/test_detectron2.py+++ b/tests/model_hub_tests/pytorch/test_detectron2.py@@ -4,6 +4,7 @@import osimport sysimport subprocess+import platformimport pytestimport torchfrom models_hub_common.utils import get_models_list, compare_two_tensors@@ -96,6 +97,8 @@ class TestDetectron2ConvertModel(TestTorchConvertModel):get_models_list(os.path.join(os.path.dirname(__file__), "detectron2_precommit")))@pytest.mark.precommitdef test_detectron2_precommit(self, name, type, mark, reason, ie_device):+ if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ pytest.skip("Detectron2 models are not enabled on ARM")self.run(name, None, ie_device)@pytest.mark.parametrize("name",diff --git a/tests/model_hub_tests/pytorch/test_easyocr.py b/tests/model_hub_tests/pytorch/test_easyocr.pyindex 0022ca451f9..6bd3fe6c93b 100644--- a/tests/model_hub_tests/pytorch/test_easyocr.py+++ b/tests/model_hub_tests/pytorch/test_easyocr.py@@ -1,6 +1,7 @@# Copyright (C) 2018-2026 Intel Corporation# SPDX-License-Identifier: Apache-2.0+import platformimport pytestimport torch@@ -29,4 +30,6 @@ class TestEasyOCRConvertModel(TestTorchConvertModel):@pytest.mark.nightly@pytest.mark.parametrize("name", ["detector", "recognizer"])def test_convert_model(self, name, ie_device):+ if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ pytest.skip("EasyOCR models are not enabled on ARM")self.run(name, None, ie_device)diff --git a/tests/model_hub_tests/pytorch/test_hf_transformers.py b/tests/model_hub_tests/pytorch/test_hf_transformers.pyindex f8be663420d..1fdad7905ec 100644--- a/tests/model_hub_tests/pytorch/test_hf_transformers.py+++ b/tests/model_hub_tests/pytorch/test_hf_transformers.py@@ -2,6 +2,7 @@# SPDX-License-Identifier: Apache-2.0import os+import platformfrom datasets import Audio, load_datasetfrom huggingface_hub import hf_hub_download, model_info, snapshot_download@@ -529,6 +530,8 @@ class TestTransformersModel(TestTorchConvertModel):])@pytest.mark.precommitdef test_convert_model_precommit(self, name, type, ie_device):+ if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ pytest.skip("hf_transformers models are not enabled on ARM")self.run(model_name=name, model_link=type, ie_device=ie_device)@pytest.mark.parametrize("name,type", [("bert-base-uncased", "bert"),@@ -536,6 +539,8 @@ class TestTransformersModel(TestTorchConvertModel):])@pytest.mark.precommitdef test_convert_model_precommit_export(self, name, type, ie_device):+ if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ pytest.skip("hf_transformers models are not enabled on ARM")self.mode = "export"self.run(model_name=name, model_link=type, ie_device=ie_device)diff --git a/tests/model_hub_tests/pytorch/test_llm.py b/tests/model_hub_tests/pytorch/test_llm.pyindex 1e6ef9de185..eeca66b98b5 100644--- a/tests/model_hub_tests/pytorch/test_llm.py+++ b/tests/model_hub_tests/pytorch/test_llm.py@@ -5,6 +5,7 @@ import copyimport inspectimport numpy as np+import platformimport pytestimport torchfrom huggingface_hub import snapshot_download@@ -239,12 +240,19 @@ class TestLLMModel(TestTorchConvertModel):return pkv, for_pkv["attention_mask"]- @pytest.mark.parametrize("type,name", [- ("opt_gptq", "katuni4ka/opt-125m-gptq"),- ("llama", "TinyLlama/TinyLlama-1.1B-Chat-v1.0"),- ("gpt2", "openai-community/gpt2"),- ("llama_awq", "casperhansen/tinyllama-1b-awq")- ])+ def get_supported_precommit_models():+ models = [+ ("gpt2", "openai-community/gpt2"),+ ]+ if platform.machine() not in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ models.extend([+ ("opt_gptq", "katuni4ka/opt-125m-gptq"),+ ("llama", "TinyLlama/TinyLlama-1.1B-Chat-v1.0"),+ ("llama_awq", "casperhansen/tinyllama-1b-awq"),+ ])+ return models++ @pytest.mark.parametrize("type,name", get_supported_precommit_models())@pytest.mark.precommit@pytest.mark.nightlydef test_convert_model_precommit(self, name, type, ie_device):diff --git a/tests/model_hub_tests/pytorch/test_timm.py b/tests/model_hub_tests/pytorch/test_timm.pyindex b1b6256b942..b8f91c9c800 100644--- a/tests/model_hub_tests/pytorch/test_timm.py+++ b/tests/model_hub_tests/pytorch/test_timm.py@@ -2,6 +2,7 @@# SPDX-License-Identifier: Apache-2.0import os+import platformimport reimport pytest@@ -135,13 +136,22 @@ class TestTimmConvertModel(TestTorchConvertModel):fw_outputs = [fw_outputs.numpy(force=True)]return fw_outputs- @pytest.mark.parametrize("name", ["mobilevitv2_050.cvnets_in1k",- "poolformerv2_s12.sail_in1k",- "vit_tiny_patch16_224.augreg_in21k",- "efficientnet_b0.ra_in1k",- "convnext_atto.d2_in1k",- "gcresnext26ts.ch_in1k",- "volo_d1_224.sail_in1k"])+ def get_supported_precommit_models():+ models = [+ "mobilevitv2_050.cvnets_in1k",+ "poolformerv2_s12.sail_in1k",+ ]+ if platform.machine() not in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ models.extend([+ "vit_tiny_patch16_224.augreg_in21k",+ "efficientnet_b0.ra_in1k",+ "convnext_atto.d2_in1k",+ "gcresnext26ts.ch_in1k",+ "volo_d1_224.sail_in1k",+ ])+ return models++ @pytest.mark.parametrize("name", get_supported_precommit_models())@pytest.mark.precommitdef test_convert_model_precommit(self, name, ie_device):self.mode = "trace"diff --git a/tests/model_hub_tests/pytorch/test_torchvision_models.py b/tests/model_hub_tests/pytorch/test_torchvision_models.pyindex b44c40a9c8d..ac02fb1cd56 100644--- a/tests/model_hub_tests/pytorch/test_torchvision_models.py+++ b/tests/model_hub_tests/pytorch/test_torchvision_models.py@@ -2,6 +2,7 @@# SPDX-License-Identifier: Apache-2.0import os+import platformimport tempfileimport pytest@@ -98,11 +99,19 @@ class TestTorchHubConvertModel(TestTorchConvertModel):fw_outputs = [fw_outputs.numpy(force=True)]return fw_outputs- @pytest.mark.parametrize("model_name", ["efficientnet_b7",- "raft_small",- "swin_v2_s",- "quantized_mobilenet_v3_large",- ])+ def get_supported_precommit_models():+ models = [+ "efficientnet_b7",+ ]+ if platform.machine() not in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ models.extend([+ "raft_small",+ "swin_v2_s",+ "quantized_mobilenet_v3_large",+ ])+ return models++ @pytest.mark.parametrize("model_name", get_supported_precommit_models())@pytest.mark.precommitdef test_convert_model_precommit(self, model_name, ie_device):self.mode = "trace"diff --git a/tests/model_hub_tests/transformation_tests/test_gptq_torchfx_transformations.py b/tests/model_hub_tests/transformation_tests/test_gptq_torchfx_transformations.pyindex 0d86eb41996..11783bf3ba0 100644--- a/tests/model_hub_tests/transformation_tests/test_gptq_torchfx_transformations.py+++ b/tests/model_hub_tests/transformation_tests/test_gptq_torchfx_transformations.py@@ -9,6 +9,7 @@ from openvino.frontend.pytorch.torchdynamo.execute import compiled_cacheimport models_hub_common.utils as utilsimport pytestimport os+import platformdef patch_gptq(config):do_gptq_patching = False@@ -96,9 +97,14 @@ def run_gptq_torchfx(tmp_path, model_id, model_link, prompt_result_pair):def test_gptq_torchfx_precommit(tmp_path, model_name, model_link, mark, reason, prompt_result_pair, ie_device):assert mark is None or mark == 'skip' or mark == 'xfail', \"Incorrect test case: {}, {}".format(model_name, model_link)+ arm_machine_names = {'arm', 'armv7l', 'aarch64', 'arm64', 'ARM64'}+ arm_missing_accelerate_models = {+ "atorsvn/TinyLlama-1.1B-Chat-v0.3-gptq-4bit",+ }+ if platform.machine() in arm_machine_names and model_name in arm_missing_accelerate_models:+ pytest.skip("accelerate is not available on ARM for this GPTQ model")if mark == 'skip':pytest.skip(reason)elif mark == 'xfail':pytest.xfail(reason)run_gptq_torchfx(tmp_path, model_name, model_link, prompt_result_pair)-diff --git a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py b/tests/model_hub_tests/transformation_tests/test_pa_transformation.pyindex bfb74c05b83..07a9ee6cd58 100644--- a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py+++ b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py@@ -14,6 +14,7 @@ import models_hub_common.utils as utilsfrom sdpa2pa_ref_diff import ref_diff_map, ref_diff_map_optimizations, nodes_to_compareimport pytestimport os+import platformimport redef apply_transformation_and_compare_diffs(ov_model: ov.Model,@@ -190,6 +191,8 @@ def test_pa_precommit(tmp_path, model_info_tuple, ie_device, use_optimizations):model_class, model_name, model_link, mark, reason = model_info_tupleassert mark is None or mark == 'skip' or mark == 'xfail', \"Incorrect test case: {}, {}".format(model_name, model_link)+ if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:+ pytest.skip("PagedAttention tests are not enabled on ARM")if mark == 'skip':pytest.skip(reason)elif mark == 'xfail':diff --git a/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py b/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.pyindex cb09e0b6433..770dbc4d30e 100644--- a/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py+++ b/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py@@ -9,6 +9,7 @@ from models_hub_common.utils import retryimport models_hub_common.utils as utilsimport pytestimport os+import platformimport redef get_read_value_ops(model: ov.Model):@@ -80,6 +81,17 @@ def run_stateful_to_stateless_in_runtime(tmp_path, model_id, model_link):def test_stateful_to_stateless_precommit(tmp_path, model_name, model_link, mark, reason, ie_device):assert mark is None or mark == 'skip' or mark == 'xfail', \"Incorrect test case: {}, {}".format(model_name, model_link)+ arm_machine_names = {'arm', 'armv7l', 'aarch64', 'arm64', 'ARM64'}+ arm_dtype_mismatch_models = {+ "hf-internal-testing/tiny-random-LlamaForCausalLM",+ "hf-internal-testing/tiny-random-StableLmForCausalLM",+ "hf-internal-testing/tiny-random-PhiForCausalLM",+ "hf-internal-testing/tiny-random-CodeGenForCausalLM",+ "hf-internal-testing/tiny-random-Starcoder2ForCausalLM",+ "hf-internal-testing/tiny-random-OPTForCausalLM",+ }+ if platform.machine() in arm_machine_names and model_name in arm_dtype_mismatch_models:+ pytest.skip("stateful_to_stateless dtype mismatch on ARM")if mark == 'skip':pytest.skip(reason)elif mark == 'xfail':diff --git a/tests/model_hub_tests/transformation_tests/test_transformations.py b/tests/model_hub_tests/transformation_tests/test_transformations.pyindex 33f2a10fa52..92289f2838e 100644--- a/tests/model_hub_tests/transformation_tests/test_transformations.py+++ b/tests/model_hub_tests/transformation_tests/test_transformations.py@@ -6,6 +6,7 @@ from optimum.intel import OVModelForCausalLMimport models_hub_common.utils as utilsimport pytestimport os+import platformimport openvino as ovimport tempfilefrom collections import deque@@ -90,6 +91,13 @@ def run_test(model_id, ie_device, ts_names, expected_layer_types):def test_transformations_precommit(tmp_path, model_name, model_link, mark, reason, ie_device, ts_names, layer_types):assert mark is None or mark == 'skip' or mark == 'xfail', \"Incorrect test case: {}, {}".format(model_name, model_link)+ arm_machine_names = {'arm', 'armv7l', 'aarch64', 'arm64', 'ARM64'}+ arm_unsupported_rope_models = {+ "hf-internal-testing/tiny-random-GPTJForCausalLM",+ "hf-internal-testing/tiny-random-CodeGenForCausalLM",+ }+ if platform.machine() in arm_machine_names and model_name in arm_unsupported_rope_models:+ pytest.skip("RoPE fusion is not available for this model on ARM")if mark == 'skip':pytest.skip(reason)elif mark == 'xfail':