Skip to content

Commit d7c54f4

Browse files
committed
[RELEASE ONLY CHANGES] Use the packaged ROCm development SDK
Install the development files matching the torch-provided ROCm runtime and point TorchAO and ExecuTorch builds at its expanded SDK root, where the HIP linker library is available. Assisted by Codex.
1 parent dbbc82f commit d7c54f4

2 files changed

Lines changed: 38 additions & 10 deletions

File tree

‎.ci/scripts/install-rocm-dependencies.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export LD_LIBRARY_PATH="${ROCM_PYTHON_PREFIX}/lib:${LD_LIBRARY_PATH:-}"
1818
TORCH_VERSION="$(python -c 'from torch_pin import TORCH_VERSION; print(TORCH_VERSION)')"
1919
python -m pip install "torch==${TORCH_VERSION}+rocm${ROCM_VERSION}" \
2020
--index-url "${PYTORCH_ROCM_INDEX}"
21+
ROCM_SDK_VERSION="$(python -c 'import rocm_sdk; print(rocm_sdk.__version__)')"
22+
python -m pip install "rocm[devel]==${ROCM_SDK_VERSION}" \
23+
--index-url "${PYTORCH_ROCM_INDEX}"
24+
ROCM_PATH="$(python -m rocm_sdk path --root)"
25+
export ROCM_PATH
26+
export ROCM_HOME="${ROCM_PATH}"
27+
export HIP_PATH="${ROCM_PATH}"
28+
export PATH="${ROCM_PATH}/bin:${PATH}"
29+
export LD_LIBRARY_PATH="${ROCM_PYTHON_PREFIX}/lib:${ROCM_PATH}/lib:${ROCM_PATH}/lib64:${LD_LIBRARY_PATH:-}"
2130
python -m pip install -r requirements-dev.txt ninja
2231
# ROCm 7.14 TorchAO wheels are Python-only. Build the pinned extension against
2332
# the installed torch and HIP libraries instead of reusing a ROCm 7.2 binary.

‎.ci/scripts/tests/test_rocm_dependencies.py‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def test_compiled_torchao_uses_the_selected_torch_and_propagates_failures(self):
1919
conda() { echo RUNTIME; }
2020
python() {
2121
if [[ "$1" == "-c" ]]; then
22-
if [[ "$2" == *torch_pin* ]]; then echo 2.15.0; else echo /env; fi
22+
if [[ "$2" == *torch_pin* ]]; then echo 2.15.0
23+
elif [[ "$2" == *rocm_sdk* ]]; then echo 7.14.1
24+
else echo /env; fi
25+
elif [[ "$*" == "-m rocm_sdk path --root" ]]; then
26+
echo /sdk
2327
elif [[ "$1" == "-" ]]; then
2428
cat >/dev/null
2529
echo VERIFY
@@ -28,29 +32,34 @@ def test_compiled_torchao_uses_the_selected_torch_and_propagates_failures(self):
2832
echo "PIP $* CPP=${USE_CPP:-unset} CPU=${USE_CPU_KERNELS:-unset} JOBS=${MAX_JOBS:-unset}"
2933
if [[ "$*" == *third-party/ao* ]]; then return "$AO_STATUS"; fi
3034
if [[ "$*" == *torch==* ]]; then return "$TORCH_STATUS"; fi
35+
if [[ "$*" == *'rocm[devel]'* ]]; then return "$SDK_STATUS"; fi
3136
fi
3237
}
3338
"""
34-
for torch_status, ao_status, verify_status in (
35-
(0, 0, 0),
36-
(1, 0, 0),
37-
(0, 1, 0),
38-
(0, 0, 1),
39+
for torch_status, sdk_status, ao_status, verify_status in (
40+
(0, 0, 0, 0),
41+
(1, 0, 0, 0),
42+
(0, 1, 0, 0),
43+
(0, 0, 1, 0),
44+
(0, 0, 0, 1),
3945
):
40-
with self.subTest(torch=torch_status, ao=ao_status, verify=verify_status):
46+
with self.subTest(
47+
torch=torch_status, sdk=sdk_status, ao=ao_status, verify=verify_status
48+
):
4149
result = subprocess.run(
4250
[
4351
"bash",
4452
"-c",
4553
stubs
46-
+ "source .ci/scripts/install-rocm-dependencies.sh\necho INSTALL_ET",
54+
+ "source .ci/scripts/install-rocm-dependencies.sh\necho INSTALL_ET\necho SDK_HOME=$ROCM_HOME HIP_PATH=$HIP_PATH ROCM_PATH=$ROCM_PATH",
4755
],
4856
cwd=ROOT,
4957
env={
5058
**os.environ,
5159
"ROCM_VERSION": "7.14",
5260
"PYTORCH_ROCM_INDEX": "https://download.pytorch.org/whl/rocm7.14",
5361
"TORCH_STATUS": str(torch_status),
62+
"SDK_STATUS": str(sdk_status),
5463
"AO_STATUS": str(ao_status),
5564
"VERIFY_STATUS": str(verify_status),
5665
"MAX_JOBS": "8",
@@ -60,7 +69,7 @@ def test_compiled_torchao_uses_the_selected_torch_and_propagates_failures(self):
6069
)
6170
self.assertEqual(
6271
result.returncode,
63-
max(torch_status, ao_status, verify_status),
72+
max(torch_status, sdk_status, ao_status, verify_status),
6473
result.stderr,
6574
)
6675
self.assertTrue(result.stdout.startswith("RUNTIME\n"))
@@ -69,16 +78,26 @@ def test_compiled_torchao_uses_the_selected_torch_and_propagates_failures(self):
6978
result.stdout,
7079
)
7180
if not torch_status:
81+
self.assertIn(
82+
"rocm[devel]==7.14.1 --index-url https://download.pytorch.org/whl/rocm7.14",
83+
result.stdout,
84+
)
85+
if not (torch_status or sdk_status):
7286
self.assertIn(
7387
"--no-build-isolation --no-deps third-party/ao CPP=1 CPU=1 JOBS=8",
7488
result.stdout,
7589
)
7690
else:
7791
self.assertNotIn("third-party/ao", result.stdout)
7892
self.assertEqual(
79-
"VERIFY" in result.stdout, not (torch_status or ao_status)
93+
"VERIFY" in result.stdout,
94+
not (torch_status or sdk_status or ao_status),
8095
)
8196
self.assertEqual("INSTALL_ET" in result.stdout, result.returncode == 0)
97+
if result.returncode == 0:
98+
self.assertIn(
99+
"SDK_HOME=/sdk HIP_PATH=/sdk ROCM_PATH=/sdk", result.stdout
100+
)
82101

83102

84103
if __name__ == "__main__":

0 commit comments

Comments
 (0)