Skip to content

fix(AMD): route Fedora/Bazzite to per-arch ROCm wheels when no version is readable - #9152

Merged
danielhanchen merged 24 commits into
unslothai:mainfrom
LeoBorcherding:fix-8731-rocm-arch-route
Sep 1, 2026
Merged

danielhanchen merged 24 commits into
unslothai:mainfrom
LeoBorcherding:fix-8731-rocm-arch-route

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #8731.

Problem

_detect_rocm_version_tag() polls five sources and all five miss on the reported host. Checked against Fedora 43's own repodata rather than the issue thread: amd-smi prints ROCm version: N/A because it dlopens the unversioned librocm-core.so, which only rocm-core-devel ships; no Fedora package owns any path under /opt/rocm at all, so .info/version cannot be there; hipconfig is /usr/bin/hipconfig from hipcc, which Bazzite does not install; dpkg is Debian-only; and rocm-core does exist on Fedora, but nothing except the rocm metapackage requires it, so a host running rocm-hip/rocm-runtime has no rocm-core to answer.

With no version, a working RX 9070 XT got CPU-only PyTorch and the reporter was told to run sudo pacman -S rocm-hip-sdk, on an immutable Fedora image, for a package he already had.

Readable arch plus unreadable version was the one combination nothing covered: the deferral in get_torch_index_url required UNSLOTH_ROCM_GFX_ARCH, and the runtime-less reroute excluded any host whose probe returned a gfx.

Fix

The version only chooses between the generic rocmX.Y leaves. _amd_arch_index_family_for_gfx already maps gfx1201 to gfx120X-all from the arch alone, and the arch was readable throughout.

  • Route on the family, not one card. The deferral now fires for any probed arch that maps to a per-arch index, not just an overridden one. Every agent has to agree on that family first: rocminfo names each agent twice, so a single-GPU host reads gfx1201\ngfx1201 and is one device, while an APU beside a discrete card is two and must not route on whichever the kernel enumerated first.

  • Keep the card separate from the family. gfx1200 beside gfx1201 agree on gfx120X-all and are still two cards. setup.sh takes UNSLOTH_ROCM_GFX_ARCH over its own visibility-aware selection, so such a host gets the wheels, which are right for both, without an export naming one at random.

  • Separate "no version readable" from "readable but unsupported". Only the second is a deliberate CPU fallback. A new _amd_no_rocm_version_reroute opens the reroute for the first and leaves the second excluded; it is computed behind the */cpu check so a healthy ROCm host does not pay a second _detect_rocm_version_tag.

  • More version sources. rpm asked about rocm-runtime and rocm-hip alongside rocm-core, in one query so a wedged rpm still costs one timeout rather than three: that is the Fedora fix. hipconfig from ROCM_PATH/bin when it is off PATH covers AMD's own installer layout, not Fedora, whose hipconfig is already on PATH.

  • One version probe per install. get_torch_index_url runs inside a command substitution, so the version it read cannot reach the reroute, which asked again. On a wedged rpm database that was _rocm_tag_from_rpm's 10s bound twice, on exactly the hosts this targets. _detect_rocm_version_tag memoises to a file inside an mktemp -d, not a $$-derived path in shared /tmp.

  • Honest warnings. Stop claiming no ROCm install was found on a host with /opt/rocm; _rocm_sdk_install_hint names only a package manager the host has; and the reroute gets its own branch, since the existing text blames an unreadable arch and would send exactly the wrong user off repairing rocminfo.

  • Do not brand the host a Radeon-repo install. _amd_gpu_radeon matched the whole index URL, and the AMD per-arch mirror is https://repo.amd.com/rocm/whl/gfx120X-all/, so the rocm in its base path set the flag on every host this reroute sends there. rocminfo calls consumer cards "Radeon", so a stock RX 9070 XT on Fedora, the host this PR exists to fix, then reported wheels: repo.radeon.com (Radeon) for wheels fetched from repo.amd.com and warned it could not read a full ROCm version to select wheels that do not need one. Now matched on _torch_index_leaf, which is what every other index classifier here already does. The two older per-arch reroutes each cleared the flag by hand; matching the leaf is what stops the next one having to.

Known gap, not fixed here

studio/install_python_stack.py::_detect_rocm_version and studio/install_llama_prebuilt.py::_detect_host_rocm_version carry comments claiming they match install.sh. They do not, and this PR widens the gap by two cases: neither has the multi-name rpm query nor the off-PATH hipconfig lookup. That matters because Studio users reach install_python_stack.py through setup.sh and never run install.sh, so a Fedora host with rocm-hip installed still resolves differently there.

Left for a follow-up rather than fixed here, on purpose: those two files already diverge from install.sh in four larger, older ways (first-answer-wins instead of highest-wins, and no ${Status} filter on the dpkg probe, so a package removed with apt remove still reports its version). Fixing two of six leaves the parity comment just as false, and both files are also touched by #8886, which already conflicts with this PR.

Scope

Broader than the reported host by design: any arch with a dedicated repo.amd.com index (gfx110X, gfx103X, gfx115X, gfx120X, gfx90a, gfx908) now routes on a readable arch with no readable version, where before it took CPU. An arch with no per-arch index (gfx906) still needs a version and still falls back with the warning.

Tests

New tests/sh/test_rocm_no_version_arch_route.sh, 42 assertions across three halves.

Routing: mapped arch defers to the reroute, unsupported version stays a CPU fallback, supported version still picks its leaf, unmapped arch still needs a version, both new version sources resolve, warnings stop misdescribing the host.

Which GPU: duplicate agents are one device and name it, two cards in one family agree on the family and name neither, an APU beside a discrete card agrees on nothing, an unmappable agent rejects the whole host, and a same-family pair still routes while exporting no arch.

The memo: two calls report the same tag and probe once, and an unset memo path caches nothing.

Mutation-tested. Restoring the UNSLOTH_ROCM_GFX_ARCH requirement reproduces the original bug on the reported host. Reducing the agent check to first-agent-wins reproduces the APU-takes-the-discrete-card's-wheels case and fails five assertions.

A second suite, tests/sh/test_rocm_no_version_arch_route_e2e.sh, executes the reroute rather than grepping for it. The reroute is top-level code, so assertions that reach only get_torch_index_url cannot see it: the suite above passes unchanged when _amd_no_rocm_version_reroute is forced false, because its reroute assertions grep the gate's own variable names, and a grep survives a gate that is wired but always decides no. The e2e suite splices the block out by stable markers, redirects the host paths and asserts the resulting TORCH_INDEX_URL. 21 assertions; 5 of them fail with the fix removed, and it is the only detector of the core decision anywhere in the test tree. Four are controls on the redirects themselves, since a host with a real NVIDIA GPU sends every AMD scenario down the CUDA path and a broken redirect is indistinguishable from a working one.

Existing suites had assertions encoding the old behaviour and were updated in place, keeping their intent: test_rocm_version_source_disagreement.sh cases 9/10, and test_no_version_cpu_warning_respects_gfx_override, which gains a gfx906 case so the CPU-warning path stays covered. Four harnesses slice functions out of install.sh by name and needed the new helpers added; those splices are one arch_fns blob per harness now, so the next helper is a single edit rather than four.

tests/sh: 42/42 and 17/17 new, 58/58 and 64/64 existing. Verified on a real gfx1151 (Strix Halo) runner and identical under dash and bash.

Hardware and OS coverage

No hosted CI runner has an AMD GPU, so a green check does not exercise this change on real
silicon. This table is the actual test report.

Where it ran

machine arch / OS what ran what this proves
this desk, WSL2 Debian under Windows 11 no AMD GPU reachable, no /dev/kfd tests/sh 37/37, 58/58, 64/64; tests/studio/install 2572 passed / 108 skipped; both mutations that the routing decision is right for every arch, agent-set and version combination the tests name
GitHub hosted runners no AMD GPU the full suite at the head commit pending at the time of this edit; the thread carries the result per push

Run under WSL deliberately: a Windows run silently skips the ~40 tests that need a POSIX sh, and one of them was the only thing catching a real regression in an earlier push.

Not covered

shape why we care
a Fedora or Bazzite host this is the reported host and nobody here runs one. The five probe sources miss in a way that is specific to Fedora packaging, so the failure only reproduces there
an rpm-based host of any kind the new rocm-runtime and rocm-hip queries are exercised as shell, never against a real rpm database
any real AMD GPU on Linux there is no Linux AMD box here: not hosted CI, not this desk, and the self-hosted amd_ci runner is a gfx1151 APU, which cannot speak for wheel routing on a discrete card
the reporter's RX 9070 XT gfx1201 silicon is on this desk, but in a Windows host, and this is a Linux-only install.sh path. Same arch, wrong OS, so it proves nothing here
two AMD GPUs of different archs in one Linux box the case the agreement check exists for, an APU beside a discrete card. Nobody on the team has that combination in a Linux host, so both the reject path and the same-family path run only against a mocked probe
two cards of the same family (gfx1200 + gfx1201) skipping the export is the fix, and setup.sh picking correctly afterwards has never been watched happen
a wedged rpm database the memo exists so that timeout is paid once. The test counts probe calls; it never waits on a real stuck rpm

Bottom line. The routing logic is covered thoroughly and mutation-tested, so the decision this
makes is right by construction. Two things are untested: the probing underneath it on a real rpm
host, which is where the original bug lived, and any host with two AMD GPUs in it, which is what
the agreement check was added for.

Interaction with #8412

The two touch the same regions, but #8412's hunks sit adjacent rather than on these lines: its gfx1033 gate is before version detection, and its reroute change is inside the */cpu body while this changes the gate condition. Whichever lands second needs a small manual merge, not a rewrite.

Worth flagging: #8412 does not fix #8731, as suggested in that thread. Its reroute hunk is inside a gate that never opens for this host.

Real gfx1151 hardware, executing the reroute

An earlier gfx1151 run could only show the absence of collateral damage, because it sourced individual functions and the reroute is top-level code. This one splices the top-level block and runs it, base vs head vs merge, under both dash and bash:

scenario base head
real_host (this runner's own unstubbed gfx1151 ROCm stack) amd/gfx1151/ amd/gfx1151/
fedora_no_version_gfx1201 (issue 8731) pt/cpu amd/gfx120X-all/ gfx1201
strix_gfx1151_alone pt/cpu amd/gfx1151/ gfx1151
strix_beside_discrete_gfx1201 pt/cpu pt/cpu
gfx906_no_version pt/cpu pt/cpu
fedora_no_version_aarch64 pt/cpu pt/cpu
fedora_no_version_on_darwin pt/cpu pt/cpu
nvidia_with_stale_rocm pt/cu128 pt/cu128
cpu_only_with_stale_rocm pt/cpu pt/cpu

Verdict CONFIRMED: the defect reproduces at the base and is absent at the head. real_host is the control saying a healthy host did not move. Every other row stubs rocminfo, amd-smi, hipconfig, rpm, dpkg-query, lspci and uname on a hermetic PATH and redirects /opt/rocm, /dev/kfd, /sys/class/kfd, /sys/bus/pci/devices and /proc/driver/nvidia, so they exercise the routing decision rather than real packaging. The splice was gated first: every required function present, the block ending on its end marker, and the get_torch_index_url call still in place, in all three states.

Merge order

…n is readable

install.sh polls five sources for a ROCm version and all five miss on Fedora
packaging: amd-smi reports the arch but no version, /opt/rocm/.info/version is the
AMD-installer layout, hipconfig sits under /opt/rocm rather than on PATH, dpkg is
Debian-only, and rocm-core is not a package Fedora ships. With no version the
installer put CPU-only PyTorch on a working RX 9070 XT and told the reporter to run
pacman on an immutable Fedora image.

The version only picks between the generic rocmX.Y leaves.
_amd_arch_index_family_for_gfx already maps gfx1201 to gfx120X-all from the arch
alone, and the arch was readable throughout. Route on it: the no-version deferral no
longer requires UNSLOTH_ROCM_GFX_ARCH, and the runtime-less reroute gets a disjunct
for readable-arch/unreadable-version hosts. A readable but UNSUPPORTED version stays
a deliberate CPU fallback; only an unreadable one is treated as a detection miss.

Also: read hipconfig from ROCM_PATH/bin when it is not on PATH, ask rpm about
rocm-runtime and rocm-hip alongside rocm-core (in one query, so a wedged rpm still
costs one timeout), and stop claiming no ROCm install was found on a host that has
one, naming only a package manager the host actually has.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

LeoBorcherding and others added 5 commits August 18, 2026 00:35
Codex P1 on a679d3f. The reroute decision is made from the arch rocminfo/amd-smi
read, but the body still preferred _infer_linux_amd_gfx_arch and only fell back to
the probe when inference came up empty. On a mixed APU + discrete AMD host the two
name different GPUs, so the wheels and the exported UNSLOTH_ROCM_GFX_ARCH could
target a card the decision never looked at.

Reduce the probe to its first token once, in the state computation, and route on it
whenever that state is set. The mapping check moves there too, so the state means
exactly "get_torch_index_url deferred on this arch" rather than merely "a probe
answered". Paths that reached the reroute before are untouched: they get there with
an empty probe and still use the inferred arch.

@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: 022cb270a6

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

Comment thread install.sh Resolved

@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: 269e8fd882

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

Comment thread install.sh Resolved
LeoBorcherding and others added 5 commits August 26, 2026 00:11
…he version once

An APU beside a discrete card reads two different arches. Both the gate and
get_torch_index_url took whichever the kernel enumerated first, so a Strix
laptop with a 9070 XT in it could take gfx1151 wheels for the discrete card
and export that arch to setup.sh as well. Before this PR that host got CPU
wheels, so the exposure is new here and worth closing here.

_amd_sole_index_arch collapses the duplicate agents rocminfo emits, then
requires every distinct arch to land in the same index family. No agreement,
no reroute: CPU wheels are useless on such a host but they are not wrong, and
UNSLOTH_ROCM_GFX_ARCH still names the card. Both call sites share the helper,
so the gate and the function cannot desync.

get_torch_index_url runs inside a command substitution, so the version it read
cannot reach the reroute and the reroute asked again. On a wedged rpm database
that is _rocm_tag_from_rpm's 10s timeout twice, on exactly the Fedora hosts
this PR targets. _detect_rocm_version_tag now memoises to a file, which
survives the subshell. Opt-in: an unset path means no cache, so a harness that
sources the function alone keeps the old behaviour.

11 new assertions, 29/29 in the suite. Mutation-tested: reducing the helper
back to first-agent-wins reproduces the APU-takes-the-wheels bug and fails
three of them.

tests/sh 29/29, 58/58, 64/64. tests/studio/install/test_rocm_support.py and
test_unsupported_arch_routing_guards_8529.py 585 passed; the 2 failures there
(test_rocm_version_detection_takes_the_highest_source,
test_removed_dpkg_rocm_core_cannot_pick_the_wheels) fail identically on clean
upstream/main.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Pushed 453b0f9. Merged main, now current with it.

Mixed-AMD host takes wheels for whichever GPU the kernel listed first. _probe_amd_gfx_arch returns one token per agent and both the reroute gate and get_torch_index_url reduced that to the first, so a Strix APU enumerated ahead of a discrete 9070 XT sent gfx1151 wheels to the discrete card and exported that arch to setup.sh as well. A new _amd_sole_index_arch collapses the duplicate agents rocminfo emits, then requires every distinct arch to land in the same index family. No agreement means no reroute: CPU wheels are useless on such a host but they are not wrong, and UNSLOTH_ROCM_GFX_ARCH still names the card. Both call sites share the helper so the gate and the function cannot desync.

The ROCm version was probed twice on the target host. get_torch_index_url runs inside a command substitution, so the version it read could not reach the reroute and the reroute asked again, costing _rocm_tag_from_rpm's 10s bound twice on a wedged rpm database. _detect_rocm_version_tag now memoises to a file, which survives the subshell, and the memo is cleaned up alongside the other install temporaries. Opt-in: an unset path means no cache, so a harness sourcing the function alone keeps the old behaviour.

11 new assertions in test_rocm_no_version_arch_route.sh, covering the mixed host end to end plus the helper directly (duplicate agents still route, same-family pair routes, APU-beside-discrete rejects, unmappable rejects) and both halves of the memo. Mutation-tested: reducing the helper back to first-agent-wins reproduces the APU-takes-the-wheels case and fails three of them.

tests/sh 29/29, 58/58, 64/64. tests/studio/install/test_rocm_support.py and test_unsupported_arch_routing_guards_8529.py: 585 passed, 57 skipped. The two failures there, test_rocm_version_detection_takes_the_highest_source and test_removed_dpkg_rocm_core_cannot_pick_the_wheels, fail identically on clean upstream/main with no branch changes applied.

Four harnesses that slice functions out of install.sh by name needed _amd_sole_index_arch added to their extraction lists, otherwise they source a script calling a command that does not exist.

@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: 573a845522

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

Comment thread install.sh Resolved
…nguessable

Two things a single helper was conflating.

The index FAMILY is a property of the host: the wheels have to work on
every AMD GPU in the box, so every agent must agree before anything
reroutes. The concrete ARCH is one device's, and gfx1200 beside gfx1201
agree on gfx120X-all while still being two different cards. setup.sh
takes UNSLOTH_ROCM_GFX_ARCH as authoritative over its own
visibility-aware selection, so exporting an arbitrary member of an
agreed family overruled a correct downstream pick with a coin flip and
could build llama.cpp for the wrong card.

_amd_agreed_index_family answers the first, _amd_sole_index_arch the
second, and it declines when there is more than one distinct arch. The
wheels still route on the family, because they are right for both cards;
only the export and the tip are skipped, and the warning names the
family instead. TORCH_CONSTRAINT now keys off the family too, which is
safe because a family never straddles that boundary.

The memo path was /tmp/unsloth-rocm-tag.1348. /tmp is shared and
1348 is observable, so a local user could pre-create it as a symlink and
both feed the probe a chosen ROCm version and redirect the write. It is
now a file inside an mktemp -d, created in the parent shell (the
subshell's own would die with it) and removed with the other install
temporaries.

Also fixes the real CI regression: a fifth harness slices functions out
of install.sh by name and only runs where sh exists, so Windows skipped
it locally while Repo tests (CPU) caught it. Those splices are now one
arch_fns blob per harness rather than four ad-hoc ones. _amd_sole_index_arch
uses awk rather than wc, which is not in the harnesses' tool allowlist.

tests/sh 37/37, 58/58, 64/64. tests/studio/install 2572 passed, 108
skipped, run under WSL so nothing sh-dependent is skipped; the 5 failures
in test_install_manifest.py and test_managed_node_runtime.py reproduce
with this branch stashed.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Two from the review of abc261d.

install.sh has an explicit block that blanks every cleanup target before
installing the EXIT and signal traps, precisely so an inherited value
cannot be deleted. _ROCM_TAG_MEMO_DIR was not in it, and the trap does
rm -rf on it, so an exit before the mktemp -d ran would remove whatever
path the caller had exported. Both memo variables are reset there now.

_infer_linux_amd_gfx_arch hands an explicit UNSLOTH_ROCM_GFX_ARCH back
verbatim, and people copy that out of HIP, which reports gcnArchName:
gfx1201:sramecc+:xnack-. The index case table has no arm for the suffix,
so the override reroute fell through to CPU while get_torch_index_url,
which strips it, had already told the user per-arch wheels were coming.
The reroute normalises through the same helper now, so the two agree and
a suffixed override reaches gfx120X-all.

Mutation-tested both. Dropping the reset fails two assertions; dropping
the normalisation fails one shell assertion and the end-to-end reroute
case, which needed the harness taught to set the override at all -- the
gate's first disjunct is the only way in on a host whose probe reads
fine, so every override case there was previously testing nothing.

tests/sh 42/42, 58/58, 64/64. tests/studio/install 2572 passed, 108
skipped; the same 5 failures in test_install_manifest.py and
test_managed_node_runtime.py reproduce with this branch stashed.
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6face730bd

ℹ️ 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 Author

ci failures unrelated to this pr
image

The reroute this PR adds for issue unslothai#8731 is top-level code in install.sh.
get_torch_index_url runs inside a command substitution, so it cannot assign
TORCH_INDEX_URL; it returns */cpu and defers, and the block underneath is what
actually rewrites the index. test_rocm_no_version_arch_route.sh sources
functions with sed -n '/^name()/,/^}/p', so it never runs that block. Its
reroute assertions are greps against install.sh source text, and the
executable half only ever reaches get_torch_index_url, which correctly still
answers */cpu.

The result is a suite that cannot fail. Deleting the fix entirely, with

    sed -i 's/_amd_no_rocm_version_reroute=true/_amd_no_rocm_version_reroute=false/' install.sh

still leaves it at 42 passed, 0 failed. Nothing in it showed that a Fedora
host ends up at a different index.

Add tests/sh/test_rocm_no_version_arch_route_e2e.sh, which splices the
top-level block out by stable text markers and runs it against a faked host,
so every assertion is the final TORCH_INDEX_URL an installer would use. The
splice runs past the reroute to the close of the whole index-decision region:
the Strix gfx115x reroute and the gfx906 pin can still rewrite the index, so
stopping earlier would assert a value the installer does not end up with.

Pinned behaviour:

  Fedora gfx1201, no readable version  -> repo.amd.com/rocm/whl/gfx120X-all/
  and UNSLOTH_ROCM_GFX_ARCH=gfx1201 handed to setup.sh
  gfx1100, no readable version         -> gfx110X-all/
  gfx906, no readable version          -> whl/cpu (no per-arch index exists)
  gfx1201 on a readable ROCm 5.7       -> whl/cpu (a deliberate fallback)
  gfx1201 beside gfx1036               -> whl/cpu (agents want different wheels)
  gfx1200 beside gfx1201               -> gfx120X-all/, no card named
  NVIDIA host, stale ROCm packages     -> whl/cu128
  GPU-less host, stale ROCm packages   -> whl/cpu
  the reported host on aarch64         -> whl/cpu (ROCm wheels are x86_64-only)

Every absolute host path the spliced code probes is redirected into a fake
tree, because a CI runner with a real NVIDIA driver would otherwise send every
AMD scenario down the CUDA path and the suite would pass while measuring
nothing. A broken redirect looks exactly like a working one from the outside,
so both controls are asserted: the real driver must be hidden, and a faked
driver tree must still be seen. The same pair is asserted for the AMD probe.
A splice that silently loses a function answers cpu for every row, so each
function the decision needs is checked for at column 0 first, and the block
splice must reach its end marker.

The last two cases re-run the decision under /bin/sh: install.sh is
POSIX, CI runs these files with bash, and a bashism in the reroute would
otherwise only surface on a Debian host.

Both suites now fail when the reroute is disabled (17 -> 12 passed, 5 failed)
and when _amd_agreed_index_family is forced to return 1. Section 8 of the
original file keeps its wiring greps, with a comment saying plainly that a
grep for the gate's variable names is a wiring check that survives a gate
which is wired but always decides no, and pointing at the file that runs it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-01T05:15:39.423105Z 3770cfe Manual request
🔒 Security Review ✅ Completed 2026-09-01T04:40:06.783855Z 767248f Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member

Consolidating my earlier comments into one summary and deleting the rest.

Validated on real AMD hardware (gfx1151 Strix Halo)

NO_REGRESSION on the runner, plus a 20-scenario end-to-end harness that actually executes the top-level reroute. Final TORCH_INDEX_URL per host, base versus head:

host base head
Fedora gfx1201, no version readable (#8731) whl/cpu gfx120X-all/
the literal #8731 host, amd-smi only, no rocminfo whl/cpu gfx120X-all/
gfx1100, no version whl/cpu gfx110X-all/
gfx906 (no per-arch index exists) whl/cpu whl/cpu
gfx1201 with readable but unsupported rocm5.7 whl/cpu whl/cpu
gfx1201 + gfx1036, different families whl/cpu whl/cpu
NVIDIA host with stale ROCm packages whl/cu128 whl/cu128
CPU-only host with stale ROCm packages whl/cpu whl/cpu

Every deliberate CPU fallback is preserved and the three pre-existing reroute paths still fire identically. Byte-identical under dash and bash.

Honest limit: the probes are stubbed on PATH; no actual Fedora or Bazzite machine was involved.

Correcting something I said earlier

I claimed your test suite "does not cover the fix". That was too broad, and I want it on the record properly. Re-running both mutations:

mutation test_rocm_no_version_arch_route.sh
_amd_agreed_index_family returns 1 37 passed, 5 failed (caught)
_amd_no_rocm_version_reroute=false 42 passed, 0 failed (missed)

So the suite is weak at exactly one thing, not uniformly weak. You did mutation-test, and the helper-level mutations are caught. What is invisible is deleting the fix itself, because the reroute is top-level code and the assertions covering it grep for the gate's own variable names. A grep is a wiring check: it survives a gate that is wired but always decides no.

f1e7e04f adds tests/sh/test_rocm_no_version_arch_route_e2e.sh, which splices and executes the block and asserts the resulting index. 17 assertions, and it fails 12/5 when the fix is deleted. Four of the 17 are controls on the host redirects themselves, because the box I ran on has a real NVIDIA GPU and a broken redirect looks exactly like a working one. install.sh is untouched by that commit.

One open item, which I do not think should block

The new version sources (rpm -q rocm-runtime|rocm-hip, off-PATH hipconfig) can now read a version on exactly the host class this PR targets. When they do, the host leaves the */cpu branch entirely, the arch-first reroute never runs, and it lands on a generic leaf: a Bazzite RX 9070 XT with ROCm 6.3 gets whl/rocm6.3, whose wheels carry no gfx1201 code objects, giving HIP error: invalid device function. Base already does this off the version file, so the gap pre-dates this PR; these sources widen its reach. A cheap follow-up is extending the Strix-style reroute to RDNA4 when the leaf is below rocm6.4.

The comment pass above is comment-only, verified by comment_tools check, a shell code-residue gate that treats heredoc bodies as data, and independently at AST level.

Checked against Fedora 43's own repodata (Everything/x86_64 filelists plus
mdapi), not against the issue thread:

- rocm-core IS a Fedora package (F43 6.4.4, F44 7.1.1, F45 7.2.2). Nothing
  except the `rocm` metapackage requires it, which is why a host running
  rocm-hip and rocm-runtime answered nothing. The multi-name query is right,
  the reason written next to it was not.
- Fedora's hipconfig is /usr/bin/hipconfig, owned by hipcc, so it is ON PATH.
  The ROCM_PATH/bin lookup is for AMD's own installer layout, and citing
  Fedora for it points the next reader at the wrong host shape.
- No Fedora package owns any path under /opt/rocm (zero matches across the
  whole F43 filelist), so Fedora reaches the SDK-hint branch, not the
  "/opt/rocm exists" one the comment was attached to.

No behaviour change.
rocminfo names the agent once and each ISA once, and on gfx1201 under ROCm 7.x
there are two ISAs, gfx1201 and gfx12-generic (ROCm/legacy-rocm-build#6110). That is three
gfx-bearing Name lines for one card. Pin both halves of the answer: the
duplicates still collapse to one device, and gfx12-generic does not widen the
host into a two-arch one that the sole-arch check would reject, which would
put a working 9070 XT back on cpu wheels.
_amd_gpu_radeon was matched on the whole index URL, and the AMD per-arch mirror
is https://repo.amd.com/rocm/whl/gfx120X-all/, so the "rocm" in its BASE PATH
set the flag on every host the new no-version reroute sends there. rocminfo
calls consumer cards "Radeon", so a stock RX 9070 XT on Fedora, the host this
PR exists to fix, then took the Radeon branch: the summary reported
"wheels: repo.radeon.com (Radeon)" for wheels fetched from repo.amd.com, the
Tauri marker recorded family "radeon", and get_radeon_wheel_url warned it could
not read a full ROCm version to select wheels that do not need one.

Match _torch_index_leaf instead, which is what the comment 70 lines above
already says every index classifier here does, and for the same reason: a
mirror whose base path happens to contain "rocm" must not relabel the leaf.
Leaves rocm6.4 and rocm-rel-6.4 classified exactly as before and only stops
gfx* leaves matching.

The two older per-arch reroutes each clear the flag by hand right after setting
their index; those lines are now redundant but left alone. Verified against the
Strix reroute as a control: it already reported false, and still does.
HSA_OVERRIDE_GFX_VERSION=11.0.0 is the standard Strix Halo workaround, so ROCr
reports gfx1100 on a physical gfx1151. The no-version reroute derives both the
wheel family and the exported UNSLOTH_ROCM_GFX_ARCH from that probe, and the
existing _hsa_spoofed_physical_gfx correction runs further down for the
llama.cpp path only, which is too late. Such a host took gfx110X-all wheels and
handed setup.sh a gfx1100 to build for.

Rank the rpm components by version instead of by argument order. rocm-core,
rocm-runtime and rocm-hip are all AMD packages from the same repo, so none
outranks the others by provenance the way rocm-core outranks the distro's
libhsa-runtime64-1. A partial upgrade leaving rocm-core 5.7 beside rocm-runtime
6.4 read as ROCm 5.7 and sent a supported runtime to CPU wheels.

Both mutation-checked: reverting the first fails the two spoof assertions with
gfx110X-all and gfx1100, reverting the second routes the split host to cpu.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

_hsa_spoofed_physical_gfx returns nothing for two different reasons, and only
one of them is "no spoof": it also declines whenever the KFD reports more than
one GPU node, because HSA_OVERRIDE_GFX_VERSION can collapse several physical
targets into one reported token. Reading that empty result as permission left a
mixed gfx1151 plus gfx1201 host agreeing on gfx110X-all, wheels neither GPU can
run. Count nodes rather than distinct arches, matching the helper's own rule.

Clear a corroborated override once native wheels are chosen. The existing
cleanup sits under case "$_torch_index_leaf" in rocm[0-9]*), which this reroute
never matches because it produces a gfx* leaf, so the host installed native
gfx1151 wheels while ROCr kept reporting gfx1100 and could not use them.

Mutation-checked: removing the veto routes the mixed host to gfx110X-all and
exports gfx1100; removing the cleanup leaves HSA_OVERRIDE_GFX_VERSION at 11.0.0.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from LeoBorcherding Sep 1, 2026
@unslothai unslothai deleted a comment from LeoBorcherding Sep 1, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 767248f014

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 767248f014

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

# Conflicts:
#	install.sh
#	tests/sh/test_rocm_version_source_disagreement.sh
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 3770cfe6dd

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
@danielhanchen
danielhanchen merged commit 0833157 into unslothai:main Sep 1, 2026
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] AMD: Fedora/Bazzite installs CPU PyTorch on gfx1201 because no source reports a ROCm version

3 participants