Skip to content

Commit b426de0

Browse files
[tensilelite] Re-apply test component config and fix PyTorch SDK test failure
Re-applies #4991 (reverted in #5520) and fixes #5516. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 554d473 commit b426de0

6 files changed

Lines changed: 151 additions & 0 deletions

File tree

build_tools/github_actions/fetch_test_configurations.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ def _build_container_options(job_config: dict, platform: str) -> dict:
194194
],
195195
},
196196
},
197+
"tensilelite": {
198+
"job_name": "tensilelite",
199+
"fetch_artifact_args": "--blas --tests",
200+
"timeout_minutes": 15,
201+
"test_script": f"python {_get_script_path('test_tensilelite.py')}",
202+
"platform": ["linux"],
203+
"total_shards_dict": {
204+
"linux": 1,
205+
},
206+
},
197207
"hipblas": {
198208
"job_name": "hipblas",
199209
"fetch_artifact_args": "--blas --tests",
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env python3
2+
# Copyright Advanced Micro Devices, Inc.
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
Test runner for TensileLite and rocisa Python tests using pre-built artifacts.
7+
8+
Runs against installed artifacts from the hipBLASLt test component:
9+
share/hipblaslt/tensilelite/Tensile/ — Tensile Python package
10+
share/hipblaslt/tensilelite/rocisa/ — rocisa Python package + _rocisa.abi3.so
11+
share/hipblaslt/tensilelite/rocisa_tests/ — rocisa pytest modules
12+
13+
Test order: rocisa first (build dependency of TensileLite), then TensileLite
14+
unit tests. A rocisa failure means TensileLite tests will also fail.
15+
16+
Usage (TheRock CI):
17+
python test_tensilelite.py
18+
19+
Usage (local, after install):
20+
THEROCK_BIN_DIR=./build/bin python test_tensilelite.py
21+
"""
22+
23+
import logging
24+
import os
25+
import subprocess
26+
import sys
27+
from pathlib import Path
28+
29+
logging.basicConfig(level=logging.INFO, format="%(message)s")
30+
31+
SCRIPT_DIR = Path(__file__).resolve().parent
32+
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent
33+
THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR", "")
34+
35+
rocm_path = Path(THEROCK_BIN_DIR).resolve().parent
36+
tensilelite_root = rocm_path / "share" / "hipblaslt" / "tensilelite"
37+
38+
if not tensilelite_root.is_dir():
39+
raise FileNotFoundError(
40+
f"TensileLite test artifacts not found at {tensilelite_root}. "
41+
"Ensure the build used -DHIPBLASLT_INSTALL_TENSILELITE_TEST_ARTIFACTS=ON."
42+
)
43+
44+
env = os.environ.copy()
45+
existing_pythonpath = env.get("PYTHONPATH")
46+
env["PYTHONPATH"] = (
47+
f"{tensilelite_root}{os.pathsep}{existing_pythonpath}"
48+
if existing_pythonpath
49+
else str(tensilelite_root)
50+
)
51+
env["ROCM_PATH"] = str(rocm_path)
52+
53+
# _rocisa links libamdhip64.so — ensure HIP libraries are findable.
54+
lib_path = rocm_path / "lib"
55+
existing_ld_path = env.get("LD_LIBRARY_PATH", "")
56+
env["LD_LIBRARY_PATH"] = (
57+
f"{lib_path}{os.pathsep}{existing_ld_path}" if existing_ld_path else str(lib_path)
58+
)
59+
60+
# GPU unit tests use amdclang++ to assemble kernels.
61+
existing_path = env.get("PATH", "")
62+
env["PATH"] = os.pathsep.join(
63+
filter(
64+
None,
65+
[
66+
str(rocm_path / "bin"),
67+
str(rocm_path / "lib" / "llvm" / "bin"),
68+
existing_path,
69+
],
70+
)
71+
)
72+
73+
# Smoke test: verify install layout and stable ABI.
74+
logging.info("=== Verifying artifact install layout ===")
75+
rocisa_dir = tensilelite_root / "rocisa"
76+
logging.info(
77+
f"rocisa directory contents: {[f.name for f in rocisa_dir.iterdir() if not f.name.startswith('__')]}"
78+
)
79+
abi3_files = list(rocisa_dir.glob("*.abi3.*"))
80+
if abi3_files:
81+
logging.info(f"Stable ABI confirmed: {[f.name for f in abi3_files]}")
82+
else:
83+
logging.warning("No .abi3 extension found — stable ABI may not be enabled")
84+
subprocess.check_call(
85+
[
86+
sys.executable,
87+
"-c",
88+
"import Tensile, rocisa, rocisa.instruction; "
89+
"print('Tensile:', Tensile.ROOT_PATH); print('rocisa:', rocisa.__file__)",
90+
],
91+
cwd=str(THEROCK_DIR),
92+
env=env,
93+
)
94+
95+
# rocisa tests (includes GPU tests — runner has GPU access).
96+
logging.info("=== Running rocisa tests ===")
97+
subprocess.check_call(
98+
[
99+
sys.executable,
100+
"-m",
101+
"pytest",
102+
"-v",
103+
str(tensilelite_root / "rocisa_tests"),
104+
],
105+
cwd=str(THEROCK_DIR),
106+
env=env,
107+
)
108+
109+
# TensileLite Python unit tests (includes GPU subtile tests).
110+
logging.info("=== Running TensileLite unit tests ===")
111+
subprocess.check_call(
112+
[
113+
sys.executable,
114+
"-m",
115+
"pytest",
116+
"-v",
117+
str(tensilelite_root / "Tensile" / "Tests" / "unit"),
118+
],
119+
cwd=str(THEROCK_DIR),
120+
env=env,
121+
)

build_tools/packaging/python/templates/rocm/src/rocm_sdk/tests/libraries_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ def testSharedLibrariesLoad(self):
6666
# Though this is not needed for the amd-smi client.
6767
continue
6868

69+
if so_path.name.endswith(".abi3.so") or ".cpython-" in so_path.name:
70+
# Python C extensions must be loaded via importlib, not
71+
# ctypes.CDLL. Stable ABI extensions (.abi3.so) target a
72+
# minimum CPython version and may use symbols absent from
73+
# older interpreters (e.g. PyType_FromMetaclass requires
74+
# 3.12+). Version-tagged extensions (.cpython-3XX) are
75+
# similarly incompatible across interpreter versions.
76+
continue
77+
6978
extra_setup = ""
7079
if (
7180
"hipdnn_plugins" in str(so_path) or "test_plugins" in str(so_path)

math-libs/BLAS/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ therock_cmake_subproject_declare(hipBLASLt
134134
-DHIPBLASLT_ENABLE_BLIS=OFF # TODO: Evaluate
135135
-DTENSILELITE_BUILD_TESTING=OFF
136136
-DHIPBLASLT_BUILD_TESTING=${THEROCK_BUILD_TESTING}
137+
-DHIPBLASLT_INSTALL_TENSILELITE_TEST_ARTIFACTS=${THEROCK_BUILD_TESTING}
138+
-DROCISA_USE_STABLE_ABI=ON
137139
-DHIPBLASLT_ENABLE_ROCROLLER=${_enable_rocRoller}
138140
-DHIPBLASLT_ENABLE_FETCH=OFF
139141
-DHIPBLASLT_ENABLE_THEROCK=ON

math-libs/BLAS/artifact-blas.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ include = [
8484
"share/hipblaslt/performance/**",
8585
# Built samples (may want these in a samples component at some point).
8686
"libexec/hipblaslt-samples/**",
87+
# TensileLite Python test artifacts
88+
"share/hipblaslt/tensilelite/**",
8789
]
8890

8991
# rocBLAS

requirements-test.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ jsonschema==4.23.0
1313
packaging==25.0
1414
python-magic==0.4.27; sys_platform != "win32"
1515

16+
# tensilelite/rocisa test requirements
17+
msgpack>=1.0.0
18+
joblib>=1.4.0
19+
numpy>=1.26.0
20+
filelock>=3.0.0
21+
hip-python; sys_platform != "win32"
22+
1623
# libhipcxx test requirement
1724
lit==18.1.8
1825
psutil==7.1.3

0 commit comments

Comments
 (0)