Skip to content

test: isolate the no-version gfx-override test from a real /opt/rocm - #7397

Merged
oobabooga merged 3 commits into
mainfrom
fix/rocm-version-test-isolation
Aug 7, 2026
Merged

oobabooga merged 3 commits into
mainfrom
fix/rocm-version-test-isolation

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

TestInstallShStructure::test_no_version_cpu_warning_respects_gfx_override (added in #7314's final round) shims every ROCm version TOOL (amd-smi, hipconfig, dpkg-query, rpm) but the version chain also reads /opt/rocm/.info/version directly, and a file read cannot be shimmed via PATH. On any Linux box with a real ROCm install the chain resolves the host's version (e.g. 7.2.1), get_torch_index_url returns rocm7.2, and the test fails because the no-version endpoint it exercises is never reached:

AssertionError: assert 'https://download.pytorch.org/whl/rocm7.2'.endswith('/cpu')

CI never sees this (runners have no ROCm); it reproduces on any ROCm dev box, found while verifying the merged AMD PRs on a Strix Halo WSL machine.

Fix

Substitute the /opt/rocm/.info/version literal in the extracted function copy with a nonexistent path inside the test's temp dir -- the same path-substitution technique the KFD topology tests use for /sys/class/kfd. Test-only change, no installer code touched.

Verification

tests/studio/install/test_rocm_support.py: 372 passed on Windows (no ROCm) and on WSL Ubuntu 24.04 with real ROCm 7.2.1 (previously 1 failed there).

@LeoBorcherding LeoBorcherding self-assigned this Jul 27, 2026
@LeoBorcherding

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 3efe941553

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LeoBorcherding

Copy link
Copy Markdown
Collaborator
image

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Merged current main into the branch to clear the red Repo tests (CPU) check. Those 9 failures
were all ROCm routing cases returning /cpu, fixed on main by #7469 two days after this branch's
last CI run; the branch was 74 commits behind. No conflicts, and the test change itself is untouched.

Also verified the fix on a real ROCm box (WSL2 Ubuntu 24.04, ROCm 7.2.1 at /opt/rocm/.info/version),
post-merge: tests/studio/install/test_rocm_support.py is 397 passed, 3 skipped. With the patch line
removed, test_no_version_cpu_warning_respects_gfx_override fails there:

E   AssertionError: assert False
E    +  where False = 'https://download.pytorch.org/whl/rocm7.2'.endswith('/cpu')

so the host's real ROCm version was leaking into the extracted shell body and the no-version endpoint
under test was never reached. The other absolute read of /opt/rocm/.info/version (install.sh:2770)
is in get_radeon_wheel_url, not reachable from the extracted get_torch_index_url, so one
substitution covers it.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 5a94eab6eb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

danielhanchen added a commit to Oxygen56/unsloth that referenced this pull request Jul 28, 2026
…nd non-directories

Two gaps found while simulating the fix against real ROCm layouts.

1. lib64 hosts got no LLVM dir. The candidate was built from the HSA dir, so a
   host with libhsa-runtime64 under lib64 probed <root>/lib64/llvm/lib. ROCm
   installs LLVM under <root>/lib/llvm regardless, so that host kept binding
   system libamd_comgr to the bundle's libLLVM: exactly the bug unslothai#7446 reports.
   Probe both spellings, the HSA dir's own first so a genuine lib64 layout still
   wins. When lib_sub is already "lib" the seen set collapses them.

2. os.path.exists accepted a non-directory. The serve-time caller joins these
   straight into LD_LIBRARY_PATH with no is-dir filter, so a file named
   llvm/lib reached the loader. os.path.isdir instead.

Verified on a 27-case matrix built from real directory trees (not mocks), run on
both Windows and Linux against three revisions: main, this PR as-is, and this
commit. Zero regressions and zero reorderings of the pre-existing entries in
every case, and the installer and launcher copies never disagree. The lib64 case
goes [lib64] -> [lib64, lib/llvm/lib]; the file case drops the bogus entry; a
symlinked llvm/lib resolves correctly on Linux.

End-to-end loader check: built real ELF objects mirroring the shipped bundle
(RUNPATH=$ORIGIN, an incomplete libLLVM.so.23.0git next to llama-server, system
comgr from /opt/rocm/lib) and reproduced the reported failure verbatim, then
confirmed the prepend clears it:
  before  undefined symbol: LLVMInitializeSPIRVTarget  ->  after  exit 0

Test helper now patches os.path.isdir alongside os.path.exists, else every fake
host reports its nested llvm dir as missing. New cases: lib64 finding llvm under
lib, lib64 preferring its own when both exist, and a real-filesystem check that a
non-directory is not prepended. Removing the lib fallback from one copy reddens
three tests including the two-copy parity guard.

tests/studio/install: 1361 passed on Linux, 4 pre-existing environmental
failures unchanged (3 managed-node-runtime under root, 1 the real /opt/rocm case
already covered by unslothai#7397). 30/30 on the helper suite on Windows and Linux.
danielhanchen added a commit that referenced this pull request Jul 28, 2026
* fix(rocm): prefer system LLVM runtime on native Linux

* Fix/adjust the nested LLVM probe for PR #7448: lib64 hosts and non-directories

Two gaps found while simulating the fix against real ROCm layouts.

1. lib64 hosts got no LLVM dir. The candidate was built from the HSA dir, so a
   host with libhsa-runtime64 under lib64 probed <root>/lib64/llvm/lib. ROCm
   installs LLVM under <root>/lib/llvm regardless, so that host kept binding
   system libamd_comgr to the bundle's libLLVM: exactly the bug #7446 reports.
   Probe both spellings, the HSA dir's own first so a genuine lib64 layout still
   wins. When lib_sub is already "lib" the seen set collapses them.

2. os.path.exists accepted a non-directory. The serve-time caller joins these
   straight into LD_LIBRARY_PATH with no is-dir filter, so a file named
   llvm/lib reached the loader. os.path.isdir instead.

Verified on a 27-case matrix built from real directory trees (not mocks), run on
both Windows and Linux against three revisions: main, this PR as-is, and this
commit. Zero regressions and zero reorderings of the pre-existing entries in
every case, and the installer and launcher copies never disagree. The lib64 case
goes [lib64] -> [lib64, lib/llvm/lib]; the file case drops the bogus entry; a
symlinked llvm/lib resolves correctly on Linux.

End-to-end loader check: built real ELF objects mirroring the shipped bundle
(RUNPATH=$ORIGIN, an incomplete libLLVM.so.23.0git next to llama-server, system
comgr from /opt/rocm/lib) and reproduced the reported failure verbatim, then
confirmed the prepend clears it:
  before  undefined symbol: LLVMInitializeSPIRVTarget  ->  after  exit 0

Test helper now patches os.path.isdir alongside os.path.exists, else every fake
host reports its nested llvm dir as missing. New cases: lib64 finding llvm under
lib, lib64 preferring its own when both exist, and a real-filesystem check that a
non-directory is not prepended. Removing the lib fallback from one copy reddens
three tests including the two-copy parity guard.

tests/studio/install: 1361 passed on Linux, 4 pre-existing environmental
failures unchanged (3 managed-node-runtime under root, 1 the real /opt/rocm case
already covered by #7397). 30/30 on the helper suite on Windows and Linux.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@oobabooga
oobabooga merged commit 2d231f8 into main Aug 7, 2026
21 of 22 checks passed
@oobabooga
oobabooga deleted the fix/rocm-version-test-isolation branch August 7, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants