Skip to content

Commit 739606e

Browse files
authored
Fix mac unit test by skipping mac runtime on runners < macOS15 (#19615)
1 parent ea8b36e commit 739606e

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

devtools/intermediate_output_tap/tests/test_coreml_e2e.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import math
2525
import os
26+
import platform
2627
import sys
2728
import tempfile
2829
import types
@@ -83,6 +84,23 @@ def _assert_df_quality(
8384
)
8485

8586

87+
def _macos_version() -> tuple[int, int]:
88+
"""Return (major, minor) macOS version, or (0, 0) on non-macOS."""
89+
if sys.platform != "darwin":
90+
return (0, 0)
91+
release = platform.mac_ver()[0]
92+
if not release:
93+
return (0, 0)
94+
parts = release.split(".")
95+
major = int(parts[0]) if parts and parts[0].isdigit() else 0
96+
minor = int(parts[1]) if len(parts) > 1 and parts[1].isdigit() else 0
97+
return (major, minor)
98+
99+
100+
# iOS18 CoreML models require macOS 15+ to execute at runtime.
101+
_MACOS_SUPPORTS_IOS18_RUNTIME = _macos_version() >= (15, 0)
102+
103+
86104
def _print_df(df: pd.DataFrame, header: str) -> None:
87105
with pd.option_context(
88106
"display.max_columns",
@@ -240,6 +258,16 @@ def test_tap_compare_static_llama_coreml(self):
240258
with tempfile.TemporaryDirectory() as temp_dir:
241259
pte_path = os.path.join(temp_dir, "model.pte")
242260
et_program.save(pte_path)
261+
262+
# iOS18-targeted CoreML models require macOS 15+ at runtime; on
263+
# older macOS we exercise AOT lowering + .pte serialization only
264+
# and skip runtime execution and the AOT-vs-runtime comparison.
265+
if not _MACOS_SUPPORTS_IOS18_RUNTIME:
266+
self.skipTest(
267+
"Skipping runtime portion: iOS18 CoreML models require "
268+
f"macOS 15+, found macOS {platform.mac_ver()[0] or 'unknown'}"
269+
)
270+
243271
rt = Runtime.get()
244272
program = rt.load_program(pte_path, verification=Verification.Minimal)
245273
method = program.load_method("forward")

0 commit comments

Comments
 (0)