Repository navigation
Studio: name the GPU agent, not the CPU, in the rocminfo probe - #9498
Conversation
|
Confirmed install.sh and studio/setup.sh still take the first Marketing Name in rocminfo, so the CPU agent gets printed as the GPU, and the record-per-agent parser lines the name up with the arch that was already selected. Will get this reviewed. |
…rts that were untested Follow-up to the rocminfo record parser in this branch, in the same two blocks. amd-smi upper-cases every key in its human-readable output (amdsmi_logger.py _capitalize_keys calls key.upper()), so `amd-smi static --asic` prints MARKET_NAME. The parser matched /[Mm]arket.?[Nn]ame/, which needs a literal lowercase "arket", so on a real host the fallback printed nothing at all. On an amd-smi-only box the summary therefore lost the GPU name outright rather than replacing the CPU's with the card's, which is the opposite of what this branch is for. The key is now matched case-folded, and the value is read past the FIRST colon only, so "MARKET_NAME: AMD Instinct MI300X OAM: 750W SKU" survives -- the same truncation the rocminfo parser here already fixed. Older title-cased "Market Name" still works. Both copies stay byte identical. Tests, all of which failed before the change or covered nothing: - tests/sh/test_setup_gpu_summary_probe_sources.sh is new. install.sh had an end-to-end probe test and studio/setup.sh had none, which is the wrong way round: install.sh's value is a display label, while $_setup_gfx is forwarded as --rocm-gfx to install_llama_prebuilt.py (setup.sh:2568) and to the whisper installer (:3309), so a wrong ordinal there picks the wrong binary. It drives the real detection and selection block with stub probes on a PATH built from scratch, and pins the probe call counts, which is what holds the three-rocminfo-calls-to-one improvement in place. - test_rocminfo_gpu_name_7307.sh no longer restates the production selector in a local _pick(). A restated copy cannot fail when the real one changes: re-adding !seen[$0]++ to production left all 15 assertions green. It is now read out of install.sh, and setup.sh's copy is asserted equal to it, so the two scripts must agree on selection as well as on parsing. - New cases for the two guards nothing exercised: an ISA line repeating a target id (what the leading ^ in the gfx match rejects; without it, match() finds gfx90a at offset 20 while substr() still cuts from RLENGTH+1 and emits a bogus "amdgcn" device), and a gfx token wider than the cap, which must drop the device rather than report a truncated arch. - The amd-smi stub no longer makes `amd-smi list` emit TARGET_GRAPHICS_VERSION. Real list prints BDF / UUID / KFD_ID and no gfx token, so the fallthrough to `static --asic` was never exercised. Fixtures now use the real MARKET_NAME spelling, keep a title-cased one, and add an embedded colon. - A Ryzen iGPU plus two identical R9700s, selected at device 2. The two dGPU records are byte identical, so a selector that folds duplicate lines away resolves that device back to the iGPU at ordinal 0. - Both harnesses now run the extracted block under the same set flags as the real scripts (set -eu for install.sh, set -euo pipefail for setup.sh). Verification: tests/sh 52/52. Parser output identical under gawk 5.2.1, gawk --posix, mawk 1.3.4 and busybox awk 1.36.1, under LC_ALL=C and C.UTF-8, including CRLF and non-ASCII names. tests/studio/install/ plus tests/python/test_cross_platform_parity.py and test_windows_no_torch_setup.py: 2708 passed, 3 failed, 3 skipped, with the failing and skipped node IDs identical to the merge base (the three are test_managed_node_runtime and pre-existing). 12 mutants over the parser, the selector and the amd-smi arm, all 12 killed. bash -n on both scripts, dash -n on install.sh, git diff --check. No AMD hardware here, so everything above is fixture- or stub-driven.
|
Thanks for splitting this out of #8606. The bug is real, the fix is right, and I could not find a host shape where it breaks something that worked. I pushed one follow-up commit to your branch ( No AMD hardware on any runner or on my box, so everything here is fixture- or stub-driven, and I have said which is which. The bug is real, and this fixes itI extracted the real probe block from
Two things worth calling out that the description does not: The ordinal fix reaches wheel and prebuilt selection, not just the label. Dropping
Ground truth I checked rather than recalled: Nothing else breaksCartesian product of [Linux, WSL, macOS] x [NVIDIA, AMD, CPU-only], plus XPU, Apple Silicon, iGPU-shadowing-dGPU, RDNA1, KFD-only and both-tools-absent, driving the real regions at base and head. Every non-AMD cell is byte-identical to the base. NVIDIA still wins on a mixed AMD-plus-NVIDIA box, including the WSL shape where Windows is untouched:
What I pushed
Now matched case-folded and read past the first colon only, so Test changes, in the same commit:
Because a test that cannot fail is not coverage, I mutated 12 behaviours across the parser, the selector and the amd-smi arm. Before: 6 of 9 killed, survivors were the trailing-character guard, the Left alone deliberately, each with a reproducerNone of these is a blocker and none is a regression from this PR, but three of them are the same bug class you are fixing, so they are worth their own change rather than a quiet rewrite of your branch. 1. The summary and the wheel routing now disagree about the arch. At the base both were wrong together; now the printed arch is right and routing still is not, so a Strix third device is announced as 2. That routes an Instinct card to 3. The visible-device mask is applied twice on the rocminfo path. 4. A blank rocminfo name no longer falls back to amd-smi. With 5. The Happy to take 1 to 3 in a follow-up unless you would rather own them. |
…minfo path The rocminfo path pairs each device's arch with its own name; the amd-smi fallback did not. Its arch was indexed by HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES while the name came from a separate awk that exited on the first MARKET_NAME, so selecting any adapter past 0 announced that adapter's arch with adapter 0's name. Reproduced on three adapters, before: HIP_VISIBLE_DEVICES=0 gfx90a|AMD Instinct MI210 HIP_VISIBLE_DEVICES=1 gfx1100|AMD Instinct MI210 <- MI210 is device 0 HIP_VISIBLE_DEVICES=2 gfx1201|AMD Instinct MI210 This is not only a label. amd-smi 6.1.1 ships MARKET_NAME with no TARGET_GRAPHICS_VERSION (its documented static output has the former and not the latter), and with no gfx token the arch is inferred from the name, so on such a host the first adapter's name decided $_setup_gfx and therefore the --rocm-gfx handed to install_llama_prebuilt.py and the whisper installer. On two adapters, before: HIP_VISIBLE_DEVICES=1 gfx arch inferred from GPU name: gfx1100 <- selected card is gfx1201 _amd_smi_gpu_records / _setup_amd_smi_gpu_records emit one `gfx|marketing name` per `GPU: N` block, in enumeration order, the same record shape and the same selector the rocminfo path already uses, so both halves of the report always describe one device. An adapter that reports neither field still occupies its slot. Both copies are byte identical and a test asserts it, as for the rocminfo parser. Two follow-on simplifications, not separate changes: `static --asic` is parsed once instead of grepped twice, and the standalone unindexed name lookup is gone. The record only replaces rocminfo's when amd-smi actually enumerated something, so a silent amd-smi still leaves the APU fallback name alone. Tests: the amd-smi arm now has the coverage the rocminfo arm had. Three adapters selected at 0, 1, 2 and out of range; a build with names and no gfx token, asserting the inference follows the selected adapter; the parser-identity assertion; and the `static --asic` call count, which drops 2 to 1. Verification: tests/sh 52/52, the three GPU-probe files 20/20/20 under gawk 5.2.1, mawk 1.3.4 and busybox awk 1.36.1. tests/studio/install/ plus tests/python/test_cross_platform_parity.py and test_windows_no_torch_setup.py: 2708 passed, 3 failed, 3 skipped, failing and skipped node IDs identical to the merge base. 12 mutants over the two parsers, the selector and both amd-smi arms, all killed. A [Linux, WSL, macOS] x [NVIDIA, AMD, CPU-only] sweep of both scripts at base and head leaves every non-AMD cell byte identical. bash -n on both, dash -n on install.sh, git diff --check. No AMD hardware here, so all of it is fixture- and stub-driven.
Comment-only pass: no executable line changed in install.sh, studio/setup.sh or the three shell tests (verified by comparing comment-stripped signatures before and after). tests/sh suite: 52 ran, 0 failed.
|
Codex Review: Didn't find any major issues. 🚀 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". |
…er set -u studio/setup.sh runs with set -euo pipefail and _setup_gfx was never in the initializer group, so the new `if [ -z "$_setup_gfx" ]` fallback read an unset variable on every arm that detects an AMD GPU without producing a record: the KFD sysfs fallback, and an amd-smi that answers `list` but returns nothing from `static --asic`. Those hosts got an unbound-variable abort out of `unsloth studio update` instead of falling through to the source build. install.sh already initialized its copy; this brings setup.sh in line. The test harness had been seeding _setup_gfx itself, which is what hid this. It now extracts the real initializer group, and asserts the KFD-shaped path reaches the end, that every variable the selection block reads is initialized up front, and that a list-but-not-static amd-smi is handled. Removing the fix fails 5 assertions. tests/sh: 52 ran, 0 failed.
… mask amd-smi enumerates in discovery order over its KFD view. HIP_VISIBLE_DEVICES and ROCR_VISIBLE_DEVICES index HIP/ROCr order, which the library derives from the KFD node id instead, and the two disagree on real hardware (MI350X SPX/NPS1). Indexing amd-smi records directly with the mask therefore selects another adapter, and _setup_gfx becomes --rocm-gfx for the llama.cpp and whisper prebuilts, so the installer can fetch a binary built for a different architecture. The untranslated indexing predates this branch, but the old selector deduplicated architectures, which hid it on a uniform cluster. Dropping that dedup so duplicate architectures keep separate ordinals is what makes a heterogeneous amd-smi host return a genuinely wrong per-ordinal arch. Adds _amd_smi_hip_order / _setup_amd_smi_hip_order, reading HIP_ID from `amd-smi list -e` (ROCm 6.4.0+), the mapping AMD publishes for exactly this. Same rules as the Python side in studio/backend/utils/hardware/amd.py get_hip_id_by_gpu_index: all or nothing, so an older CLI that rejects -e, a hip_id reading N/A, a colliding id or an out-of-range id all keep discovery order rather than half-applying a map. rocminfo is an HSA client and already reports in ROCr order, so that path is left alone. The records reach awk on stdin behind a sentinel rather than through `-v`: POSIX awk forbids a physical newline in a -v value and gawk --posix makes it fatal, which would have emptied the amd-smi arm outright on a strict awk. gawk, mawk and busybox awk all tolerate it, so the tests now run the real helper under gawk --posix too. tests/sh: 52 ran, 0 failed. The three targeted suites (23 + 24 + 32) pass under gawk, gawk --posix, mawk and busybox awk. Removing the reorder fails 5 assertions; restoring the -v form fails 3.
…id map Keeping discovery order when `amd-smi list -e` is unavailable still let the mask index an untranslated list, so on ROCm before 6.4, or when the map is partial or colliding, an ordinal could still name one adapter while selecting another, and that value is forwarded as --rocm-gfx. The reorder helper now reports which index space the records came back in on its first output line, and the caller declines when there is no usable map AND the adapters do not agree on an architecture. Identical adapters and single-adapter hosts are unaffected: every ordinal yields the same arch either way, so declining there would regress multi-GPU ROCm<6.4 hosts that are not actually ambiguous. UNSLOTH_ROCM_GFX_ARCH still overrides, and setup.sh now says so when it declines. The new flags are initialized with the rest of the group, so the assertion added for the earlier set -u fix covers them. tests/sh: 52 ran, 0 failed. Targeted suites 23 + 26 + 35, green under gawk, gawk --posix, mawk and busybox awk. Disabling the decline fails 5 assertions; widening it to every multi-adapter host fails 5 others.
…ty gate The gate added for the HIP id map compared records on TARGET_GRAPHICS_VERSION alone. amd-smi 6.1.1 does not report that field at all, so on such a host every record has an empty arch, the distinct count collapses to one, and two unlike adapters bypassed the guard. The arch is inferred from the marketing name in that case, so a wrong ordinal still produced a wrong --rocm-gfx, which is the exact path the gate exists to close. Records are now compared on the arch when they have one and on the name when they do not. Matching names prove interchangeability; differing names do not prove the opposite, since an RX 7900 XTX and an XT both infer gfx1100, so this over-declines rather than under-declines. Comparing inferred architectures exactly would need the name table, which install.sh keeps as an inline case rather than a function, and the two scripts have to stay in step. tests/sh: 52 ran, 0 failed. Targeted suites 23 + 28 + 37, green under gawk, gawk --posix, mawk and busybox awk. Reverting the gate to arch-only fails the new assertion in both harnesses.
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
The ambiguity gate reached for wc, which neither install.sh nor studio/setup.sh used anywhere before this branch, where head, tail and sort were already in use. Folding the count into the awk that was already running drops the new dependency and two of the three processes. No behaviour change: tests/sh 52 ran, 0 failed, and the targeted suites are unchanged at 23 + 28 + 37 under gawk, gawk --posix, mawk and busybox awk.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
Verified on real Strix Halo hardwareEverything in this review so far was fixture- and stub-driven, since there is no AMD GPU on my box. I ran the probe on an AMD DevLab ephemeral runner, which is the same hardware class as the #7307 report: Ryzen AI MAX+ 395 with Radeon 8060S, The headline question, running the real That is #7307 reproduced and fixed on the machine that reported it. The arch is unchanged at The raw tool output also settles four things that were, until now, only read out of source:
Suites on that host: |
Real hardware, round two: the updater path, the
|
End to end: the real installer, on the reporting hardwareThe earlier hardware reports ran the probe region extracted out of the scripts. That shares the parser but not the surrounding script, so it could in principle have been right while a real run still printed the wrong thing. This is That is the #7307 output format, with the reported value on the left and the corrected one on the right. Two details worth recording. The GPU summary is emitted at The job asserts the difference rather than relying on reading it: if base and head produced the same string it would have failed. |
The red
|
| run | branch | head | parity pytest | failure |
|---|---|---|---|---|
| 32620040644 | amd-rocminfo-gpu-name | 2edb934 | 516 passed, 2 skipped | Test-StudioPathPresent |
| 32619888472 | main | 90644db | 516 passed, 2 skipped | Test-StudioPathPresent |
| 32619788861 | main | f1f95f7 | 516 passed, 2 skipped | Test-StudioPathPresent |
It is also failing on amd-rocm-fastpath-probe and worktree-venv-clear-recreate. The last green run of this workflow was fix/studio-duplicate-metadata-integrity at 05:05, so something landed on main just after that.
This branch changes five files, install.sh, studio/setup.sh and three tests/sh/*.sh, and no .ps1 at all. Test-StudioPathPresent is defined in install.ps1:4018 and the test evaluates an extracted region where it is not in scope. Nothing here can reach it.
Staging CI, run on owned repos to spare the org queue, is green on this head: 43 workflows across two branches, all success, including Windows UI / API / GGUF, Mac Studio Install Matrix, cross-platform parity and Backend CI.
Both red checks bisect to 90644db on main, not to this branchUpdating my earlier note: there are two failures now, and both come from the same main-side commit,
Bisected on plain
This branch changes five files: One thing worth flagging for anyone else rebasing onto current main: a local Staging CI on owned repos, run on this head, was 43 workflows across two branches, all success. |
_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.
…NA4 to rocm6.4 (#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 #8886 so that PR stays the ROCm version-source change. Stacked on it: the floor consumes the leaf #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 (#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 #9672 * Fall through to amd-smi static --asic when list carries no arch for PR #9672 * Layer ROCR_VISIBLE_DEVICES under the HIP index on the amd-smi path for PR #9672 * Decline arch routing on a ROCr UUID mask over unlike amd-smi adapters for PR #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]>
…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]>
Problem
On an AMD host both the installer and
unsloth studio updatereported the processor as the GPU. On a Ryzen AI MAX+ 395 (gfx1151):rocminfo lists the CPU agent before the GPU agents, and both scripts took the first
Marketing Name:line in the whole output:On a real gfx1151 runner that parser prints
AMD RYZEN AI MAX+ 395 w/ Radeon 8060S. The arch shown next to it came from a separate grep, so the two halves of the line could describe different devices.Change
_rocminfo_gpu_recordsemits onegfx|marketing namerecord per rocminfo GPU agent, in agent order, and the summary selects a record with the same visible-device index that already picked the arch. Identical awk ininstall.shandstudio/setup.sh, with a test asserting the two copies stay byte-identical, since the installer and the updater must not name different cards on the same host.Details the parser has to get right:
-F': ', soAMD Instinct MI300X OAM: 750W SKUsurvives intact.gfx1030|), or every later device shifts down one ordinal.gfx90a:sramecc+:xnack-) still registers while the ISA section'sName: amdgcn-amd-amdhsa--gfx1151does not.The two probes have different shapes, so
install.shnow follows the division of labourstudio/setup.shalready had:Deliberately unchanged: visibility-mask handling, the amd-smi and KFD detection fallbacks, the name-based arch inference table, and the ordering of the arms in the summary.
setup.shcalls rocminfo once instead of three times, which follows from building the records rather than being a separate goal.Verification
tests/sh/test_rocminfo_gpu_name_7307.sh: 15 assertions on the parser, covering the CPU-first host, two discrete cards with index selection, two cards of one arch, a blank marketing name keeping its slot, an embedded colon, a target-id agent name, and the no-GPU-agent fallback.tests/sh/test_install_gpu_summary_probe_sources.sh: 10 assertions driving the real probe-and-select block out ofinstall.shwith stub probes, pinning down which source wins in each combination. It builds itsPATHfrom scratch, because the host running it may itself have a real rocminfo and amd-smi.rocminfooutput: the previous parser printsAMD RYZEN AI MAX+ 395 w/ Radeon 8060S, both patched copies printgfx1151|AMD Radeon Graphics. The NPU agent (aie2p, Device Type DSP) and both ISAName:lines produce no records. Both new test files pass in full on that host.tests/sh52/52;tests/studio/install/plustests/python/test_cross_platform_parity.pyandtests/python/test_windows_no_torch_setup.pyat 2574 passed, 118 skipped.tests/studio/install/fails the same 6 tests with and without the change (3 intest_managed_node_runtime.py, 1 intest_rocm_gfx_spoof_7331.py, 2 intest_unsupported_arch_routing_guards_8529.py), andtests/shthe same 1 (test_install_rollback_lifecycle.sh, which needs signal traps the runner does not allow). That baseline was measured with this change and Studio: escape the dependency fast path when AMD torch is the wrong wheel #9499 both applied.bash -nanddash -noninstall.sh,bash -nonstudio/setup.sh,git diff --check.Related: #7307. Replaces the reporting half of #8606.