Repository navigation
Linux: index AMD visible-device masks by device, and floor gfx1102/RDNA4 to rocm6.4 - #9672
danielhanchen merged 50 commits into
Conversation
Three fixes on top of the split-Debian ROCm detection work. studio/install_python_stack.py gated the kernel-less-wheel repair on _gfx_needs_rocm64_generic_index(ver), so a gfx1200 host reading ROCm 6.4 or newer skipped it entirely and studio update left an installed +rocm6.1 build in place. Split the runtime-target test from the host-version test: the index reroute stays version-gated, the repair now runs on the target alone. install.sh resolved _runtime_gfx from HIP_VISIBLE_DEVICES and ROCR_VISIBLE_DEVICES only. AMD documents CUDA_VISIBLE_DEVICES as a HIP visibility variable and recommends it for cross-vendor portability, so a mixed gfx1100 + gfx1200 host masked with CUDA_VISIBLE_DEVICES=1 selected gfx1200 at runtime while the installer routed for gfx1100. Resolve the three variables first-set-wins, matching _pick_visible_index. install.sh also took UNSLOTH_ROCM_GFX_ARCH verbatim, so a value copied from a HIP gcnArchName (gfx1200:xnack-) matched none of the bare architecture patterns. Strip the suffix and surrounding whitespace the way _gfx906_env and _runtime_target_needs_rocm64_generic_index already do. Regressions cover all three, and each fails without its fix.
get_torch_index_url clips its leaf to a family PyTorch publishes: ROCm 6.5 becomes rocm6.4, 7.3 and newer become rocm7.2, and no leaf ever carries a patch level. repo.radeon.com does publish rocm-rel-6.5 and rocm-rel-7.2.1, so passing that leaf into get_radeon_wheel_url pointed a Radeon host at an older directory, or at none when only the patch-level directory exists. The caller's X.Y.Z to X.Y retry cannot recover it because a leaf is already X.Y. Treat the resolved leaf as a floor instead. The host probe runs as before and wins whenever it reads no older than the leaf, so 6.5.0 and 7.2.1 reach their own directories. The leaf takes over when the probe is missing or older than the resolver's answer, which is the split Debian host whose hipconfig reports 5.7, the case the argument was added for. tests/sh/test_rocm_version_source_disagreement.sh covers both directions and extracts the new comparison helper alongside the functions it tests.
HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES carry device ordinals, but install.sh built its gfx list with a flat grep and then de-duplicated it before indexing. On a host enumerating gfx1100, gfx1100, gfx1200 an ordinal of 2 ran past the end of the two-entry list and silently fell back to the first gfx1100, so the selected RDNA 4 card never reached the rocm6.4 floor and received wheels with no kernels for it. The de-duplication was not gratuitous: rocminfo prints a device's arch on both its Name and ISA lines, so counting raw tokens is wrong too. _gfx_targets_per_device splits on agent headers and takes one token per device, exactly as _detect_amd_gfx_codes(dedup=False) does in studio/install_python_stack.py, and falls back to first-seen order for flat output such as amd-smi's. With the list now one entry per device, the indexing step no longer de-duplicates. Also refreshes the gfx906 comment that justified its policy by the old de-duplication, and extracts the new helper in the two Strix probe tests that run the detection block standalone.
ROCR_VISIBLE_DEVICES is an ROCr-level mask, so rocminfo returns only the selected agents, already in the mask's order. Indexing that filtered list again by the mask's first ordinal double-applies it: on physical gfx1100,gfx1200 with ROCR_VISIBLE_DEVICES=1,0 rocminfo reports gfx1200,gfx1100 and ordinal 1 picked gfx1100, leaving the runtime-selected gfx1200 on kernel-less wheels. Track which probe answered and skip the ordinal when rocminfo answered and ROCR_VISIBLE_DEVICES is the first-set mask, matching the _LAST_AMD_GFX_PROBE check in _runtime_target_needs_rocm64_generic_index. HIP_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES are applied by the HIP runtime rather than by ROCr, and amd-smi ignores all three, so both keep ordinal indexing. The existing ROCR row in the visible-mask test modelled an impossible host, rocminfo listing both GPUs while ROCR_VISIBLE_DEVICES selected one, and is replaced by cases that report what a masked rocminfo actually returns.
Two gaps in the gfx1102/RDNA 4 rocm6.4 floor. The per-device gfx parser recognised rocminfo's "Agent N" and hipinfo's "Device #N" but not amd-smi's "GPU: N" and "GPU[N]", which install.sh already parses at line 3104 for its GPU-presence check. Without rocminfo, a host with gfx1100, gfx1100, gfx1200 therefore collapsed to two entries and an ordinal of 2 fell out of range, so the selected RDNA 4 card missed the floor. _detect_amd_gfx_codes had the same omission and is fixed alongside. A header sharing its line with the token, as "GPU[0] : gfx1100" does, now contributes that token instead of dropping it. The migrated-environment repair only reinstalled torch when torch.version.hip was empty, so a legacy venv already carrying a kernel-less +rocm6.1 wheel finished migration with it after printing the reroute warning. It now also reinstalls when the architecture floor selected rocm6.4 and the installed wheel reports an older family, matching _installed_rocm_wheel_is_below on the Python side. _venv_torch_rocm_below reads the family from the venv's torch, and an unidentifiable family counts as older, as it does in Python.
The flag the migrated repair reads was set inside the reroute, so it only covered hosts detected at ROCm 6.0 to 6.3. A gfx1102/gfx1200/gfx1201 host already reading 6.4 or newer selects a good index without rerouting, so the flag stayed false and a legacy venv carrying +rocm6.1 kept it, which is the same shape as the earlier install_python_stack.py fix that separated _gfx_rocm64_target from _gfx_rocm64_floor. _gfx_rocm64_target now records that the runtime GPU needs the floor at all, independent of the leaf, and the reroute stays gated on the detected version. An explicit index pin still skips the whole block, so it never triggers the extra reinstall. The routing harness in the tests returns the flag alongside the leaf, and test_install_sh_marks_the_floor_target_independently_of_the_leaf pins it for gfx1200 on rocm6.1, rocm6.4 and rocm7.2, with gfx1100 as the negative.
…m detection The rocm6.4 floor rewrote TORCH_INDEX_URL but left _amd_gpu_radeon set, so on a Radeon-branded card the install took the Radeon branch and the floored index was only its fallback. repo.radeon.com's newest pairing trio under rocm-rel-6.4/ is torch 2.6.0+rocm6.4.0, whose rocBLAS Tensile libraries carry gfx1030/1100/1101/ 1200/1201/908/942 and no gfx1102 at all, and rocm-rel-7.2/ is narrower still (gfx120X-all, gfx90a, gfx942, gfx950). The arch the floor exists for therefore still received a wheel with no kernels for it. Clear the flag whenever one of the three arches is the runtime target, mirroring the gfx906 branch below, which clears it even when its own reroute is a no-op. Memoise _detect_rocm_version on the _TORCH_RUNTIME_PROBE pattern already in the file. _ensure_rocm_torch() runs twice on Linux and the detector no longer short-circuits, so all five sources were probed twice and the source-disagreement warning printed twice where install.sh prints it once. The host ROCm stack cannot change mid-run, so unlike the torch probe nothing invalidates it after a pip operation; the reset exists for the autouse test fixtures. Correct install_llama_prebuilt.py's claim that its detector mirrors install.sh and _detect_rocm_version(). It no longer does: no status gate, no HSA runtime, still first-answer-wins. The detector itself is left to a follow-up since it moves llama.cpp asset selection rather than the torch family.
…e host rocm-core comes from AMD's repo and marks the ROCm release; libhsa-runtime64-1 comes from the distro archive and tracks the archive. Ubuntu 24.04 with AMD's ROCm 7.2 repo really does carry rocm-core 7.2.1 beside Ubuntu's own libhsa-runtime64-1 5.7.1-2build1, so voting them as peers made every healthy host print a disagreement warning naming a 5.7 reading that means nothing. AMD's own HSA package is hsa-rocr, under a different name and versioned 1.x. Debian ships no rocm-core, so the fallback still fires exactly where it was added and the reported host still resolves rocm6.1. Also stop three TestDetectRocmVersion cases reading the developer's machine: the detector no longer returns at the first answer, so an unpatched test picks up the host's real hipconfig or dpkg packages and CI never sees it. And terminate records in the dpkg stub. $(...) strips trailing newlines, so a real "\n" showformat concatenated every package onto one line and the multi-package assertion only ever tested the first record.
danielhanchen asked for this PR to stay the ROCm version-source change, so the per-device gfx indexing, the gfx1102/gfx1200/gfx1201 rocm6.4 floor and the migrated installed-wheel repair all move out. They are one dependency chain rather than three separable pieces: the floor needs per-device indexing to read the right runtime arch, and the repair keys off the floor target. Kept here: get_radeon_wheel_url taking the already-resolved leaf. Without it a split Debian host resolves rocm6.1 and then the Radeon branch re-probes from scratch, rediscovers hipconfig 5.7 and asks for rocm-rel-5.7/, so it closes a hole this change opens rather than adding scope.
…rocm6.4 Split out of unslothai#8886 so that PR stays the ROCm version-source change. Stacked on it: the floor consumes the leaf unslothai#8886 resolves. One dependency chain. _gfx_targets_per_device emits one gfx token per device, so a visible-device mask selects a card rather than an arch. The floor then reads the right runtime arch and routes gfx1102/gfx1200/gfx1201 to the generic rocm6.4 wheels, which are the oldest family shipping their kernels. The migrated repair keys off that floor target so an upgraded venv stops keeping a kernel-less wheel.
|
Confirmed the per-device indexing fixes the mask path in install.sh, where a deduplicated arch list made HIP_VISIBLE_DEVICES=2 miss the third card, and the rocm6.4 floor matches the wheels that actually ship gfx1102 kernels. The new _gfx_targets_per_device overlaps _rocminfo_gpu_records that main already has at install.sh:4790, so please collapse them into one helper and rebase onto the version-source PR before this lands. |
…ith the other rocminfo is an ROCr client, so its output is already filtered by ROCR_VISIBLE_DEVICES. The routing then picked the first variable that was SET across all three layers, so an ROCr mask that had already done its work shadowed CUDA_VISIBLE_DEVICES, the HIP-layer alias, which should select among the survivors. With ROCR_VISIBLE_DEVICES=2,1 and CUDA_VISIBLE_DEVICES=1 the target is the second survivor; the old chain named the first and floored the index for the wrong card. Consult only the HIP layer once rocminfo has applied the ROCr one, mirroring _HIP_LAYER_MASKS in studio/install_python_stack.py, which already did this.
TestGfx1102Rocm64Floor._ensure_for_gfx patched the detectors but left _installed_rocm_wheel_family and _torch_requires_rocm_sdk reading the RUNNING interpreter. The scenarios it sets up install generic pytorch.org wheels, which do not pull rocm[libraries], so the per-arch family is None by construction. On a gfx1151 Strix Halo runner whose venv holds 2.11.0+rocm7.13.0 they answered gfx1151 instead. The per-arch repick arm then saw _have != _want, reinstalled, and test_installed_64_wheel_left_alone_on_newer_host and test_unaffected_arch_not_repaired_on_newer_host failed on AMD hardware while passing on every CUDA or CPU box, this one included. Pin both to the scenario. A test about the generic-wheel floor must not depend on what the machine running it happens to have installed.
|
Update: running this PR's own install suites on a real gfx1151 Strix Halo Linux runner found a defect that passes on every CUDA and CPU machine, including mine. Fixed in 8a2e597. This is the result I most wanted from the hardware, so the detail is worth recording. What the hardware said
The two extra failures are both tests this PR adds: so nothing pre-existing broke. The harness called it REGRESSION because it compares failing-id sets, which is the right arithmetic and the wrong English: a PR that adds a failing test reads the same as one that breaks an existing test. The accurate statement is that the PR shipped two tests that fail on the hardware they are about. Verbatim, from the head: Root cause
The fix pins both to the scenario, which is also the honest value for it: these tests install generic pytorch.org wheels ( patch.object(m, "_torch_requires_rocm_sdk", return_value = False),
patch.object(m, "_installed_rocm_wheel_family", return_value = None),Reproduced and confirmed both waysI did not want to take a remote failure on trust, so I reproduced it locally by making the test module's 740 passed, 1 skipped across the three rocm suites at head. The mask was ruled out, not assumed awayA test that fails only inside a GPU-masked CI job is often the mask. That was checked: the same workflow with
The mask genuinely flipped device visibility on a genuinely ROCm-enabled torch and the suite result did not move, so the failure is a property of the installed wheel's build tag rather than of what HIP can see. What this run still could not answer
|
|
CI triage note, since several checks here are red and none of them are this PR. Posting the evidence rather than asking anyone to take it on trust. 1. This was a transient breakage on
CI runs against main as of run time, and these runs predate 12:48, so they caught the window in between. No PR in this batch touches 2. The three 3. I ran that test on a clean So: buckets 3 and 3 and 3, in the runbook's terms. Nothing here blocks these PRs, and I have re-run the affected jobs now that main carries the fix. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Merged current The branches had drifted far enough that CI was testing a stale combination rather than the change. The clearest case:
Merged cleanly with no conflicts. Verified before pushing:
Two other red checks that were also main's rather than this branch's, for the record:
Still genuinely outstanding and not from this branch: |
Comments only. Every load-bearing fact stays: the issue numbers, the POSIX awk constraint on -v newlines, the two amd-smi header shapes, why an unreadable arch keeps its slot, why the ROCr and HIP layers compose rather than shadow, and the keep-in-sync pointers to studio/setup.sh and install_python_stack.py. Applied to studio/setup.sh as well: test_rocminfo_gpu_name_7307.sh asserts the two copies of the amd-smi parser and HIP reorder are byte identical, so editing one alone breaks parity. The same test also sed-matches the first-set-wins comment to lift a block, so that anchor line is preserved verbatim.
_visible_masks_select_no_gpu reads CUDA_VISIBLE_DEVICES as the HIP alias when HIP_VISIBLE_DEVICES is unset, so a host running the suite with CUDA_VISIBLE_DEVICES="" (a CPU CI shard, or a developer hiding a CUDA card) made _runtime_gfx_target answer no GPU and the three debian-split floor tests took the generic index instead of the per-arch one. The fixture already scrubbed the HIP and ROCr masks; scrub the CUDA one too, as the other fixtures in this file do. 625 pass with the variable empty, set and unset.
|
Re-validated on current main (1e07231) with the branch merged, on real gfx1151 Strix Halo hardware on Linux and Windows, and through a hermetic installer matrix. Four commits pushed today: a fixture fix, a comments-only pass, and two fixes described below. Before and afterBefore: main collects the AMD architecture list with
On an amd-smi-only host main also applies a HIP ordinal to amd-smi's discovery order; this branch translates through After: one record per adapter, indexed by the mask, and a per-arch generic-wheel floor: gfx1102 to rocm6.3, gfx1200 and gfx1201 to rocm6.4, read from the kernels each published wheel actually carries. What I changed todayThe three Second pass: an amd-smi fallback this branch had brokenOn a host where Third pass: the ROCr layer on the amd-smi pathThe P1 review item was right. amd-smi is not ROCr-filtered, so with both EvidenceReal hardware, self-hosted gfx1151 Linux:
Windows 11 gfx1151, re-run on the final head: Installer matrix, 183 cells over [Linux, WSL, macOS, Windows msys] x [NVIDIA, AMD, CPU, XPU pin] x tool states: this branch differs from main in 42 cells and every one is either the intended floor (gfx1102 below 6.3, gfx1200 and gfx1201 below 6.4), the mask cells above, or two consequences the code comments document: the Radeon repo flag is cleared on floored arches because that repo's rocm-rel-6.4 trio ships no gfx1102, and a copied Hosted runners ( Old installs and updating
Not tested hereThe pool has one gfx1151 per box, so the multi-adapter mask headline was demonstrated on synthetic |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…NA4 to rocm6.4 (unslothai#9672) * Fix ROCm detection on split Debian stacks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Harden ROCm detection on split Debian stacks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * close the gaps in the gfx1102/RDNA4 rocm6.4 floor Three fixes on top of the split-Debian ROCm detection work. studio/install_python_stack.py gated the kernel-less-wheel repair on _gfx_needs_rocm64_generic_index(ver), so a gfx1200 host reading ROCm 6.4 or newer skipped it entirely and studio update left an installed +rocm6.1 build in place. Split the runtime-target test from the host-version test: the index reroute stays version-gated, the repair now runs on the target alone. install.sh resolved _runtime_gfx from HIP_VISIBLE_DEVICES and ROCR_VISIBLE_DEVICES only. AMD documents CUDA_VISIBLE_DEVICES as a HIP visibility variable and recommends it for cross-vendor portability, so a mixed gfx1100 + gfx1200 host masked with CUDA_VISIBLE_DEVICES=1 selected gfx1200 at runtime while the installer routed for gfx1100. Resolve the three variables first-set-wins, matching _pick_visible_index. install.sh also took UNSLOTH_ROCM_GFX_ARCH verbatim, so a value copied from a HIP gcnArchName (gfx1200:xnack-) matched none of the bare architecture patterns. Strip the suffix and surrounding whitespace the way _gfx906_env and _runtime_target_needs_rocm64_generic_index already do. Regressions cover all three, and each fails without its fix. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * keep the real host ROCm release for repo.radeon.com get_torch_index_url clips its leaf to a family PyTorch publishes: ROCm 6.5 becomes rocm6.4, 7.3 and newer become rocm7.2, and no leaf ever carries a patch level. repo.radeon.com does publish rocm-rel-6.5 and rocm-rel-7.2.1, so passing that leaf into get_radeon_wheel_url pointed a Radeon host at an older directory, or at none when only the patch-level directory exists. The caller's X.Y.Z to X.Y retry cannot recover it because a leaf is already X.Y. Treat the resolved leaf as a floor instead. The host probe runs as before and wins whenever it reads no older than the leaf, so 6.5.0 and 7.2.1 reach their own directories. The leaf takes over when the probe is missing or older than the resolver's answer, which is the split Debian host whose hipconfig reports 5.7, the case the argument was added for. tests/sh/test_rocm_version_source_disagreement.sh covers both directions and extracts the new comparison helper alongside the functions it tests. * index visible-device masks by device, not by arch HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES carry device ordinals, but install.sh built its gfx list with a flat grep and then de-duplicated it before indexing. On a host enumerating gfx1100, gfx1100, gfx1200 an ordinal of 2 ran past the end of the two-entry list and silently fell back to the first gfx1100, so the selected RDNA 4 card never reached the rocm6.4 floor and received wheels with no kernels for it. The de-duplication was not gratuitous: rocminfo prints a device's arch on both its Name and ISA lines, so counting raw tokens is wrong too. _gfx_targets_per_device splits on agent headers and takes one token per device, exactly as _detect_amd_gfx_codes(dedup=False) does in studio/install_python_stack.py, and falls back to first-seen order for flat output such as amd-smi's. With the list now one entry per device, the indexing step no longer de-duplicates. Also refreshes the gfx906 comment that justified its policy by the old de-duplication, and extracts the new helper in the two Strix probe tests that run the detection block standalone. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * do not re-index an rocr mask rocminfo already applied ROCR_VISIBLE_DEVICES is an ROCr-level mask, so rocminfo returns only the selected agents, already in the mask's order. Indexing that filtered list again by the mask's first ordinal double-applies it: on physical gfx1100,gfx1200 with ROCR_VISIBLE_DEVICES=1,0 rocminfo reports gfx1200,gfx1100 and ordinal 1 picked gfx1100, leaving the runtime-selected gfx1200 on kernel-less wheels. Track which probe answered and skip the ordinal when rocminfo answered and ROCR_VISIBLE_DEVICES is the first-set mask, matching the _LAST_AMD_GFX_PROBE check in _runtime_target_needs_rocm64_generic_index. HIP_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES are applied by the HIP runtime rather than by ROCr, and amd-smi ignores all three, so both keep ordinal indexing. The existing ROCR row in the visible-mask test modelled an impossible host, rocminfo listing both GPUs while ROCR_VISIBLE_DEVICES selected one, and is replaced by cases that report what a masked rocminfo actually returns. * split amd-smi device blocks and repair floored wheels on migration Two gaps in the gfx1102/RDNA 4 rocm6.4 floor. The per-device gfx parser recognised rocminfo's "Agent N" and hipinfo's "Device #N" but not amd-smi's "GPU: N" and "GPU[N]", which install.sh already parses at line 3104 for its GPU-presence check. Without rocminfo, a host with gfx1100, gfx1100, gfx1200 therefore collapsed to two entries and an ordinal of 2 fell out of range, so the selected RDNA 4 card missed the floor. _detect_amd_gfx_codes had the same omission and is fixed alongside. A header sharing its line with the token, as "GPU[0] : gfx1100" does, now contributes that token instead of dropping it. The migrated-environment repair only reinstalled torch when torch.version.hip was empty, so a legacy venv already carrying a kernel-less +rocm6.1 wheel finished migration with it after printing the reroute warning. It now also reinstalls when the architecture floor selected rocm6.4 and the installed wheel reports an older family, matching _installed_rocm_wheel_is_below on the Python side. _venv_torch_rocm_below reads the family from the venv's torch, and an unidentifiable family counts as older, as it does in Python. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * key the migrated repair on the gpu, not on whether the leaf moved The flag the migrated repair reads was set inside the reroute, so it only covered hosts detected at ROCm 6.0 to 6.3. A gfx1102/gfx1200/gfx1201 host already reading 6.4 or newer selects a good index without rerouting, so the flag stayed false and a legacy venv carrying +rocm6.1 kept it, which is the same shape as the earlier install_python_stack.py fix that separated _gfx_rocm64_target from _gfx_rocm64_floor. _gfx_rocm64_target now records that the runtime GPU needs the floor at all, independent of the leaf, and the reroute stays gated on the detected version. An explicit index pin still skips the whole block, so it never triggers the extra reinstall. The routing harness in the tests returns the flag alongside the leaf, and test_install_sh_marks_the_floor_target_independently_of_the_leaf pins it for gfx1200 on rocm6.1, rocm6.4 and rocm7.2, with gfx1100 as the negative. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Keep floored gfx1102/gfx1200/gfx1201 off the Radeon repo; memoise ROCm detection The rocm6.4 floor rewrote TORCH_INDEX_URL but left _amd_gpu_radeon set, so on a Radeon-branded card the install took the Radeon branch and the floored index was only its fallback. repo.radeon.com's newest pairing trio under rocm-rel-6.4/ is torch 2.6.0+rocm6.4.0, whose rocBLAS Tensile libraries carry gfx1030/1100/1101/ 1200/1201/908/942 and no gfx1102 at all, and rocm-rel-7.2/ is narrower still (gfx120X-all, gfx90a, gfx942, gfx950). The arch the floor exists for therefore still received a wheel with no kernels for it. Clear the flag whenever one of the three arches is the runtime target, mirroring the gfx906 branch below, which clears it even when its own reroute is a no-op. Memoise _detect_rocm_version on the _TORCH_RUNTIME_PROBE pattern already in the file. _ensure_rocm_torch() runs twice on Linux and the detector no longer short-circuits, so all five sources were probed twice and the source-disagreement warning printed twice where install.sh prints it once. The host ROCm stack cannot change mid-run, so unlike the torch probe nothing invalidates it after a pip operation; the reset exists for the autouse test fixtures. Correct install_llama_prebuilt.py's claim that its detector mirrors install.sh and _detect_rocm_version(). It no longer does: no status gate, no HSA runtime, still first-answer-wins. The detector itself is left to a follow-up since it moves llama.cpp asset selection rather than the torch family. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Read rocm-core over the distro HSA package, and stop tests reading the host rocm-core comes from AMD's repo and marks the ROCm release; libhsa-runtime64-1 comes from the distro archive and tracks the archive. Ubuntu 24.04 with AMD's ROCm 7.2 repo really does carry rocm-core 7.2.1 beside Ubuntu's own libhsa-runtime64-1 5.7.1-2build1, so voting them as peers made every healthy host print a disagreement warning naming a 5.7 reading that means nothing. AMD's own HSA package is hsa-rocr, under a different name and versioned 1.x. Debian ships no rocm-core, so the fallback still fires exactly where it was added and the reported host still resolves rocm6.1. Also stop three TestDetectRocmVersion cases reading the developer's machine: the detector no longer returns at the first answer, so an unpatched test picks up the host's real hipconfig or dpkg packages and CI never sees it. And terminate records in the dpkg stub. $(...) strips trailing newlines, so a real "\n" showformat concatenated every package onto one line and the multi-package assertion only ever tested the first record. * Split the gfx floor and installed-wheel repair out to a follow-up danielhanchen asked for this PR to stay the ROCm version-source change, so the per-device gfx indexing, the gfx1102/gfx1200/gfx1201 rocm6.4 floor and the migrated installed-wheel repair all move out. They are one dependency chain rather than three separable pieces: the floor needs per-device indexing to read the right runtime arch, and the repair keys off the floor target. Kept here: get_radeon_wheel_url taking the already-resolved leaf. Without it a split Debian host resolves rocm6.1 and then the Radeon branch re-probes from scratch, rediscovers hipconfig 5.7 and asks for rocm-rel-5.7/, so it closes a hole this change opens rather than adding scope. * Index AMD visible-device masks by device, and floor gfx1102/RDNA4 to rocm6.4 Split out of unslothai#8886 so that PR stays the ROCm version-source change. Stacked on it: the floor consumes the leaf unslothai#8886 resolves. One dependency chain. _gfx_targets_per_device emits one gfx token per device, so a visible-device mask selects a card rather than an arch. The floor then reads the right runtime arch and routes gfx1102/gfx1200/gfx1201 to the generic rocm6.4 wheels, which are the oldest family shipping their kernels. The migrated repair keys off that floor target so an upgraded venv stops keeping a kernel-less wheel. * Collapse the per-device gfx probe onto the existing GPU record helpers _gfx_targets_per_device parsed a second time what _rocminfo_gpu_records (unslothai#9498) and _amd_smi_gpu_records already parse for the GPU summary, so delete it and read the gfx half of those records instead. Both move up to the probe-parser block so the arch routing can call them; their bodies are unchanged, so the studio/setup.sh mirrors and their tests stay as they are. One parser per tool now, shared by the routing block and the display block: a mask ordinal indexes cards in both, and a duplicate arch cannot collapse two devices into one entry in either. The amd-smi shim in test_gfx_probe_survives_no_match_under_set_e answered every subcommand with "GPU: gfx1151", which is not a shape amd-smi emits; it now answers `list` with BDF only and `static --asic` with TARGET_GRAPHICS_VERSION, so the test proves the fallthrough it describes. Same for the flat-output amd-smi stub in test_install_sh_still_indexes_amd_smi_output_under_a_rocr_mask. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * amd-smi: take the bracketed GPU[N] header too, arch and all The record parser only opened a device on `GPU: N`, so amd-smi's other header shape, `GPU[0] : gfx1100`, produced no records at all. That shape is not hypothetical: it carries the arch on the header line itself with no TARGET_GRAPHICS_VERSION following, and the rest of the tree already reads it. _has_amd_rocm_gpu matches `gpu[ ]*[:[][ ]*[0-9]` at install.sh:3208, the Python detector matches the same at install_python_stack.py:1660, and the per-device split at :1814 carries a comment saying install.sh parses the same shapes. It did not. Consequence on an amd-smi-only host (no rocminfo): _gfx_all came back empty, so _runtime_gfx was empty and every arch policy this PR adds was skipped without a word. A gfx1200 box resolving ROCm 6.1 keeps the kernel-less rocm6.1 wheels instead of being floored to rocm6.4, which is the case the PR exists for. Header shapes now both open a record, and the header's own gfx token is taken when it has one. Applied to studio/setup.sh identically; the parity assertion in test_rocminfo_gpu_name_7307.sh caught the two copies drifting on a comment while this was being written. Three cases added to that suite, which now sources the amd-smi parser rather than only diffing the two copies of it: bracketed multi-device keeps one record per device in order, the keyed form still pairs arch with name, and a header with no arch stays empty instead of borrowing the next device's. Verified: 26 passed, 0 failed on Git Bash. test_install_gpu_summary_probe_sources and test_setup_gpu_summary_probe_sources report identical results with and without this commit on this box (0/28 and 3/37); they need a POSIX symlink the environment cannot make, and pass on the Linux runner. * Translate amd-smi order before indexing it, and keep unreadable adapters Two ways the arch routing could read the wrong adapter, both from treating a position in a list as if it were a device id. Order. amd-smi enumerates in discovery order, which is not the order HIP numbers devices, and the routing applied a HIP/ROCR/CUDA ordinal to it directly. The translation already existed: _amd_smi_hip_order builds a HIP_ID map from `amd-smi list -e`, and the GPU summary has used it all along. Routing now runs the same translation, and when no map comes back and the adapters are not alike it declines with a warning rather than guess, which is the call the summary already makes on the same evidence. discovery [gfx90a MI210, gfx1200 RX 9070], HIP order reversed HIP_VISIBLE_DEVICES=0 before: gfx90a after: gfx1200 HIP_VISIBLE_DEVICES=1 before: gfx1200 after: gfx90a same, no HIP_ID map before: gfx90a after: declines Blank slots. _amd_smi_gpu_records emits an empty gfx field on purpose so an adapter whose arch it cannot read keeps its ordinal, and the index step then filtered those lines out with NF, collapsing the list. Command substitution ate a trailing one too. [blank, gfx1151], HIP_VISIBLE_DEVICES=0 before: gfx1151, so the Strix reroute fired on device 0's behalf after: unknown, which matches no policy _gfx_arch_slots does that preservation, and prints nothing when NO adapter has an arch so the probe chain still falls through to the next source. Two places deliberately keep the old behaviour. rocminfo is an ROCr client and already enumerates in the order HIP numbers from, which is the premise the mask handling was written on, so it is marked hip and skips the check. Identical adapters skip it too: every ordinal gives the same answer, so there is nothing to get wrong. Seven cases added to test_rocminfo_gpu_name_7307.sh, which now sources _gfx_arch_slots and _amd_smi_hip_order. 33 passed, 0 failed on Git Bash. sh -n and bash -n clean. test_install_gpu_summary_probe_sources and test_setup_gpu_summary_probe_sources report 0/28 and 3/37 with and without this commit alike; they need a POSIX symlink this box cannot make. The decline path itself is three lines of shell inside the routing block and is not covered end to end here: that needs the block harness, which is one of the two suites the environment cannot run. Its inputs are covered. * Define _amd_smi_hip_order before the routing calls it, and inject it into the tests Both are the same mistake in two places: a shell helper that is not in scope where it is used, hidden by an `|| true`. install.sh is sequential and the GPU probing runs at top level, inside the case opened at 4806. The translation call added last push sits at 4847; the helper was defined at 5108, 261 lines further down. So on every amd-smi host the shell said command not found, `|| true` swallowed it, _gfx_smi_out came back empty, and the next two lines erased records that were fine. Reproduced in three lines: out=$(printf 'x\n' | _fn 'recs' || true); echo "[$(printf '%s\n' "$out" | head -1)]" _fn() { echo hip; } -> _fn: command not found -> [] Moved next to _gfx_arch_slots at 3590, ahead of both call sites. Body unchanged, so the install.sh/setup.sh parity assertion still holds. Same shape in tests/studio/install/test_rocm_support.py. Its probe blocks are extracted from install.sh and run with only the helpers the harness injects, and that list was still the two record parsers. The routing block calls _gfx_arch_slots now, so bash printed `_gfx_arch_slots: command not found` four times and then a syntax error. Added both new helpers to _gpu_record_helpers, with a note on why a missing one is worse than a loud failure: the block's `|| true` turns it into an empty arch list and the assertion passes for the wrong reason. Four cases added to test_rocminfo_gpu_name_7307.sh asserting each helper is defined above its first call, by order rather than by line number so a later edit does not have to update them. Checked against b8fbc16 to confirm the guard actually fires: FAIL _amd_smi_hip_order def=5108 firstuse=4847 there, PASS here. 37 passed, 0 failed. sh -n, bash -n and python -m ast all clean. Not re-run: tests/studio/install/test_rocm_support.py. It downloads models and filled this disk mid-run, taking a baseline comparison with it. The command-not-found lines it printed are gone, which is what the harness change was for, but I am not quoting a pass count I did not watch finish. * Answer `amd-smi list -e` in the routing stubs so the ordinal tests test an ordinal The amd-smi stubs ignored argv and returned the ASIC listing for every call, `amd-smi list -e` included. So the routing block saw no HIP_ID map, and with unlike adapters known only in discovery order it correctly declined to apply an ordinal and left the caller's leaf alone. The leaf it left alone was rocm6.1, the default these tests pass in. That is a real miss, not a cosmetic one, and it was hiding in the pass column: splits_amd_smi_gpu_headers[HIP_VISIBLE_DEVICES=2] expected rocm6.4 got rocm6.1 splits_amd_smi_gpu_headers[HIP_VISIBLE_DEVICES=1] expected rocm6.1 got rocm6.1 still_indexes_amd_smi_output_under_a_rocr_mask expected rocm6.1 got rocm6.1 Only the first failed. The other two agree with the decline by coincidence, so they were asserting nothing about the header splitting and the ROCR indexing they are named for. _amd_smi_stub answers `list -e` with a HIP_ID map, identity by default, which is what a caller indexing the listing directly already assumes. Both call sites use it. Added a third test that withholds the map on the same adapters and asserts the decline, so the behaviour that was silently absorbing these three now has one test that means to land there. 4 passed, 0 failed, and the old stubs reproduce the table above against the same install.sh. Verified by running the harness's own assembled script from a file rather than through pytest. Git Bash on Windows truncates a `bash -c` payload at 8188 bytes and these scripts are ~23.5k, so every test in this class dies there with a syntax error from the cut, whatever the branch. That is this machine, not the diff; the Linux runner executes them normally. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Compose the ROCr and HIP visibility layers instead of shadowing one with the other rocminfo is an ROCr client, so its output is already filtered by ROCR_VISIBLE_DEVICES. The routing then picked the first variable that was SET across all three layers, so an ROCr mask that had already done its work shadowed CUDA_VISIBLE_DEVICES, the HIP-layer alias, which should select among the survivors. With ROCR_VISIBLE_DEVICES=2,1 and CUDA_VISIBLE_DEVICES=1 the target is the second survivor; the old chain named the first and floored the index for the wrong card. Consult only the HIP layer once rocminfo has applied the ROCr one, mirroring _HIP_LAYER_MASKS in studio/install_python_stack.py, which already did this. * Make the generic-wheel floor tests independent of the host's own torch TestGfx1102Rocm64Floor._ensure_for_gfx patched the detectors but left _installed_rocm_wheel_family and _torch_requires_rocm_sdk reading the RUNNING interpreter. The scenarios it sets up install generic pytorch.org wheels, which do not pull rocm[libraries], so the per-arch family is None by construction. On a gfx1151 Strix Halo runner whose venv holds 2.11.0+rocm7.13.0 they answered gfx1151 instead. The per-arch repick arm then saw _have != _want, reinstalled, and test_installed_64_wheel_left_alone_on_newer_host and test_unaffected_arch_not_repaired_on_newer_host failed on AMD hardware while passing on every CUDA or CPU box, this one included. Pin both to the scenario. A test about the generic-wheel floor must not depend on what the machine running it happens to have installed. * Tighten the comments this change adds Comments only. Every load-bearing fact stays: the issue numbers, the POSIX awk constraint on -v newlines, the two amd-smi header shapes, why an unreadable arch keeps its slot, why the ROCr and HIP layers compose rather than shadow, and the keep-in-sync pointers to studio/setup.sh and install_python_stack.py. Applied to studio/setup.sh as well: test_rocminfo_gpu_name_7307.sh asserts the two copies of the amd-smi parser and HIP reorder are byte identical, so editing one alone breaks parity. The same test also sed-matches the first-set-wins comment to lift a block, so that anchor line is preserved verbatim. * Scrub CUDA_VISIBLE_DEVICES in the generic-wheel floor fixture _visible_masks_select_no_gpu reads CUDA_VISIBLE_DEVICES as the HIP alias when HIP_VISIBLE_DEVICES is unset, so a host running the suite with CUDA_VISIBLE_DEVICES="" (a CPU CI shard, or a developer hiding a CUDA card) made _runtime_gfx_target answer no GPU and the three debian-split floor tests took the generic index instead of the per-arch one. The fixture already scrubbed the HIP and ROCr masks; scrub the CUDA one too, as the other fixtures in this file do. 625 pass with the variable empty, set and unset. * Tighten the comments this change adds for PR unslothai#9672 * Fall through to amd-smi static --asic when list carries no arch for PR unslothai#9672 * Layer ROCR_VISIBLE_DEVICES under the HIP index on the amd-smi path for PR unslothai#9672 * Decline arch routing on a ROCr UUID mask over unlike amd-smi adapters for PR unslothai#9672 --------- Co-authored-by: Natani L. Mayday <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maheswar Kumar <[email protected]> Co-authored-by: danielhanchen <[email protected]>

Split out of #8886 at @danielhanchen's request, so that PR stays the ROCm version-source change. Stacked on it: the floor consumes the leaf #8886 resolves, and both touch the same regions of
install.sh, so #8886 should land first.Three pieces, one dependency chain, which is why they arrive together rather than as three PRs.
1. Visible-device masks index devices, not arches. The arch routing now reads the gfx half of
_rocminfo_gpu_recordsand_amd_smi_gpu_records, the same per-device records the GPU summary block already builds, soHIP_VISIBLE_DEVICES=2on agfx1100, gfx1100, gfx1200host selects the third card instead of falling off the end of a deduplicated two-entry list. Also: first-set-wins acrossHIP_/ROCR_/CUDA_VISIBLE_DEVICES, no re-indexing of a ROCR maskrocminfoalready applied, andUNSLOTH_ROCM_GFX_ARCHnormalised so a copied HIPgcnArchNamestill matches.2. gfx1102 / gfx1200 / gfx1201 floor to the generic rocm6.4 wheels. The newest wheel on the rocm6.1 leaf, torch 2.6.0+rocm6.1, ships Tensile kernels for gfx1030, gfx1100 and gfx1101 only. torch 2.9.1+rocm6.4 adds gfx1102, gfx1200 and gfx1201. Without the floor those cards resolve a wheel with no kernels for them and die at the first BLAS call, the same failure class already special-cased for gfx906.
The floor also clears
_amd_gpu_radeon.rocm-rel-6.4/tops out at torch 2.6.0 with no gfx1102 Tensile libraries androcm-rel-7.2/carries neither gfx1102 nor gfx1100, so repo.radeon.com is not a viable source for gfx1102 at any version.3. Migrated environments repair a floored wheel. A migrated venv keeps its HIP torch, so a pre-6.4 wheel survives an upgrade and
studio updatewas a no-op on exactly the GPUs the floor exists for.Scope: no changes to ROCm version detection, no wheel-table changes, and explicit
UNSLOTH_TORCH_INDEX_*pins stay authoritative throughout.Validation: on Ubuntu 24.04,
tests/studio/install/2611 passed with 5 failures identical toupstream/mainat58c721d(2 intest_install_manifest.py, 3 intest_managed_node_runtime.py, all HOME-path assertions, none AMD).tests/shsuites at 23, 28 and 37 assertions.bash -nandsh -n install.shclean.Partly verified on hardware. Detection and routing were run on a real Radeon AI PRO R9700 (gfx1201) under WSL2 Ubuntu 24.04 with ROCm 7.2.1 from AMD's Debian packages: real
rocminfooutput parses togfx1201|AMD Radeon AI PRO R9700,_runtime_gfxresolves togfx1201, the leaf movesrocm6.1torocm6.4and_amd_gpu_radeonis cleared. The same block against a genuinely failingrocminfostill exits 0 underset -euo pipefailand leaves the leaf alone.Not verified: the wheel install and a training run, which is where a missing kernel actually surfaces. The kernel-presence claims come from reading the rocBLAS Tensile library names inside the published wheels, not from running them. The multi-device mask indexing is also stub-only, since that host has one GPU.
Two of the three floored arches are owned here, gfx1201 and gfx1200, but no gfx1102. What would close this: a gfx1102, gfx1200 or gfx1201 owner confirming a real train on the rocm6.4 wheels. gfx1102 matters most, since it is the arch the Radeon repo cannot serve at any version.
Also here:
_gfx_targets_per_devicehas been collapsed into_rocminfo_gpu_records(#9498) and_amd_smi_gpu_records, per review, so there is one parser per tool shared by the routing block and the display block.Hardware and OS coverage
Every check on this PR ran on hosted GitHub runners, which have no AMD GPU, so all of them exercised software stubs. Unsloth does have a self-hosted AMD runner, but nothing here was run on it. This table is the real test report. A row only counts as a test if the machine had the hardware, and only for the part of the diff that machine actually exercises.
Where it was run
rocm-core,hsa-rocras .debs)rocminfothrough the routing block_rocminfo_gpu_recordsreturnsgfx1201|AMD Radeon AI PRO R9700from real output,_runtime_gfxresolves togfx1201, the leaf movesrocm6.1torocm6.4,_gfx_rocm64_targetsets, and_amd_gpu_radeonis cleared fromtrue. The floor and the Radeon-branch clear are demonstrated on a real RDNA4 card.HSA_ENABLE_DXG_DETECTIONunsetrocminfohsa_initfails, the probe returns empty, the block still exits 0 underset -euo pipefailand leaves the leaf alone. The|| trueguards hold against a real failing tool, not a stub.tests/studio/install/2611 passed,test_rocm_support.py535 passed,tests/shsuites at 23 / 28 / 37,bash -nandsh -nProvenance: those suite counts were measured at
d828ee0. The head has since moved to8f95ff28e7through two merges ofmain, a pre-commit pass, and one code commit (amd-smi: take the bracketed GPU[N] header too, arch and all). The two hardware rows are unaffected, because no new hardware run has happened, but the counts have not been re-measured at the current head.Scope limits on that box, stated plainly: it is WSL2, so ROCr reaches the GPU through
/dev/dxgand there is no/dev/kfd. Therocminfooutput shape is the same as bare metal, which is what the parser consumes, so the parse and the route are genuinely settled. The wheel install and a training run are not. There is one GPU and noamd-smiin that image, so the multi-device and amd-smi branches remain stub-only.An RX 9060 XT (gfx1200) and a second R9700 are owned but not seated, so neither contributed.
The wheel claims (which rocBLAS Tensile libraries ship in torch 2.6.0+rocm6.1 versus 2.9.1+rocm6.4, and what
repo.radeon.comcarries underrocm-rel-6.4/androcm-rel-7.2/) come from reading the library names inside the published wheels. A real check, but a file listing, not a training run.What is still missing
repo.radeon.comcannot serve at any version, so a wrong floor there has no fallback. Nobody on this thread owns one.HIP_VISIBLE_DEVICES=2fell off the end of a deduplicated two-entry list. Two R9700s exist here but are not seated together, and even seated they would be two identical gfx1201 cards, which is not the mixed-arch case.amd-smianswers androcminfodoes notGPU[N]header added at the current head, the discovery-order-versus-HIP-order question, and adapters whoseTARGET_GRAPHICS_VERSIONcomes back blank. The WSL image above has noamd-smi, so every one of those is stub-only.Bottom line
Solid: on a real gfx1201 card, real
rocminfooutput parses to one record per device and the rocm6.1 leaf is floored to rocm6.4 with the Radeon branch cleared, and the probe survives a genuinely failingrocminfo. Biggest gap: gfx1102 is the arch this floor matters most for and no one on this thread has one, and nothing has yet installed the floored wheel and trained on it, which is where a missing kernel actually shows.