Skip to content

Fix ROCm wheel-index unit test: extract the gfx-arch probe helpers get_torch_index_url now calls - #7399

Merged
danielhanchen merged 2 commits into
mainfrom
fix-rocm-torch-index-test
Jul 24, 2026
Merged

Fix ROCm wheel-index unit test: extract the gfx-arch probe helpers get_torch_index_url now calls#7399
danielhanchen merged 2 commits into
mainfrom
fix-rocm-torch-index-test

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

tests/sh/test_get_torch_index_url.sh fails on main with 9 failures. Every ROCm case resolves to the CPU wheel index:

FAIL: ROCm 6.3 -> rocm6.3 (expected 'https://download.pytorch.org/whl/rocm6.3', got 'https://download.pytorch.org/whl/cpu')
...
Results: 40 passed, 9 failed

This is what the Repo tests (CPU) CI job trips on.

Root cause

The test sources a curated subset of install.sh functions (extracted with sed) so it can unit-test get_torch_index_url while stubbing nvidia-smi. The ROCm path in get_torch_index_url later gained a gfx-arch probe (the Strix reroute work), so it now calls:

  • _ensure_rocm_probe_env
  • _probe_amd_gfx_arch
  • _infer_linux_amd_gfx_arch (and its _amd_gpu_present_via_pci / _infer_amd_gfx_arch_from_gpu_name helpers)
  • _amd_arch_index_family_for_gfx

The extraction list was never updated. In the harness those helpers are undefined, so on the ROCm path _amd_gfx_probe=$(_probe_amd_gfx_arch) invokes an undefined function, the branch silently falls through to echo "$_base/cpu", and every ROCm assertion fails. install.sh itself is correct: real installs define all of these, so ROCm hosts are unaffected. This is purely a test harness gap.

Fix

Extract the six missing helpers alongside the ones already sourced. With the gfx-arch probe defined, the mock amd-smi (which reports gfx1100) lets the ROCm branch run end to end and select the right rocmX.Y index.

Added a comment noting the extraction list must stay in sync with install.sh so the next helper addition doesn't silently reintroduce this.

Verification

bash tests/sh/test_get_torch_index_url.sh
...
Results: 49 passed, 0 failed

…ch_index_url now calls

get_torch_index_url gained a gfx-arch probe on the ROCm path (Strix reroute
work) and now calls _ensure_rocm_probe_env, _probe_amd_gfx_arch,
_infer_linux_amd_gfx_arch and friends. The unit test in
tests/sh/test_get_torch_index_url.sh sources a curated subset of install.sh
functions, and that list was never updated, so those helpers were undefined
in the harness. On the ROCm path the gfx probe hit an undefined function,
the branch silently fell through to the CPU wheel index, and every ROCm
assertion failed (9 failures: all ROCm versions resolved to /whl/cpu).

Extract the six missing helpers so the ROCm branch runs end to end. All 49
assertions pass. Adds a comment noting these must stay in sync with
install.sh.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6c3561919

ℹ️ 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".

# references a helper that is not extracted here, the ROCm branch hits an
# undefined function, silently falls through to the CPU wheel index, and the
# ROCm assertions below fail.
sed -n '/^_ensure_rocm_probe_env()/,/^}/p' "$INSTALL_SH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Isolate ROCm probes from the host environment

On WSL/ROCm hosts where rocminfo exists only at /opt/rocm/bin (and /dev/kfd is absent), extracting _ensure_rocm_probe_env makes the supposedly minimal-PATH test rediscover and execute the real host rocminfo. The no-GPU and CUDA-visible-device assertions can then select the host ROCm wheel index rather than their expected CPU result, so this test becomes host-dependent. Add a controlled rocminfo mock/stub (and prevent the helper from appending the real ROCm path) to preserve the test's isolation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 46e4723. You are right: extracting _ensure_rocm_probe_env pulled its absolute-path host probe into the harness (it appends /opt/rocm/bin to PATH and runs the real rocminfo, and version detection reads /opt/rocm/.info/version), so on a ROCm host the no-GPU/CVD assertions could pick up the host GPU. The whole /opt/rocm prefix is now redirected to an empty temp dir in the same sed pass that stubs /usr/bin/nvidia-smi, so the probes stay hermetic. All 49 assertions pass and the generated harness contains no real /opt/rocm path.

Extracting _ensure_rocm_probe_env pulled its absolute-path host probe into the
harness: it appends /opt/rocm/bin to PATH and runs the real host rocminfo, and
version detection reads /opt/rocm/.info/version. On a host with ROCm installed
that leaks the host GPU into the minimal-PATH test, so the no-GPU and
CUDA-visible-device assertions could select a host ROCm wheel index instead of
their expected CPU result, making the test host-dependent.

Redirect the whole /opt/rocm prefix to an empty temp dir in the same sed pass
that stubs /usr/bin/nvidia-smi, so the probes stay hermetic. All 49 assertions
pass and the generated harness contains no real /opt/rocm path.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 46e472344a

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 418ae14 into main Jul 24, 2026
15 checks passed
@danielhanchen
danielhanchen deleted the fix-rocm-torch-index-test branch July 24, 2026 09:12
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.

2 participants