Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PT FE] Enable PyTorch tests on ARM CPU (#29664)

Arseniy Obolenskiy8e94a1d1a1b6
diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag
index 291a918972d..55feab17485 100644
--- a/.github/dockerfiles/docker_tag
+++ b/.github/dockerfiles/docker_tag
@@ -1 +1 @@
-pr-33859
+pr-29664
diff --git a/.github/dockerfiles/ov_test/ubuntu_22_04_arm64/Dockerfile b/.github/dockerfiles/ov_test/ubuntu_22_04_arm64/Dockerfile
index 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.yml
index 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.yml
with:
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.py
index 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 math
import os
+import platform
import subprocess
import sys
import tempfile
@@ -120,9 +121,15 @@ class TestAlikedConvertModel(TestTorchConvertModel):
# remove all downloaded files from cache
self.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.py
index 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 os
import sys
import subprocess
+import platform
import pytest
import torch
from 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.precommit
def 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.py
index 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 platform
import pytest
import 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.py
index 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.0
import os
+import platform
from datasets import Audio, load_dataset
from huggingface_hub import hf_hub_download, model_info, snapshot_download
@@ -529,6 +530,8 @@ class TestTransformersModel(TestTorchConvertModel):
])
@pytest.mark.precommit
def 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.precommit
def 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.py
index 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 copy
import inspect
import numpy as np
+import platform
import pytest
import torch
from 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.nightly
def 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.py
index 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.0
import os
+import platform
import re
import 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.precommit
def 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.py
index 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.0
import os
+import platform
import tempfile
import 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.precommit
def 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.py
index 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_cache
import models_hub_common.utils as utils
import pytest
import os
+import platform
def 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.py
index 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 utils
from sdpa2pa_ref_diff import ref_diff_map, ref_diff_map_optimizations, nodes_to_compare
import pytest
import os
+import platform
import re
def 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_tuple
assert 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.py
index 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 retry
import models_hub_common.utils as utils
import pytest
import os
+import platform
import re
def 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.py
index 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 OVModelForCausalLM
import models_hub_common.utils as utils
import pytest
import os
+import platform
import openvino as ov
import tempfile
from 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':