Repository navigation
fix(install): infer Strix gfx when ROCm runtime is absent - #7305
LeoBorcherding merged 19 commits into
Conversation
When /dev/kfd and rocminfo are missing on Linux (e.g. Arch/CachyOS Strix Halo), route to AMD per-arch wheels via cpuinfo/lspci inference instead of CPU-only PyTorch. Mirrors install.ps1 Windows behavior and fixes studio update via install_python_stack.py (unslothai#7301).
There was a problem hiding this comment.
Code Review
This pull request introduces a fallback mechanism to infer AMD GPU architectures (such as Strix Halo/Point) on Linux when the ROCm runtime is not visible, routing the installation to AMD's arch-specific wheels. Feedback highlights issues with parsing lspci output in both install.sh and studio/install_python_stack.py when PCI domain prefixes are present, which can prevent successful GPU name matching. Additionally, the reviewer noted that the UNSLOTH_AMD_ROCM_MIRROR environment variable is currently ignored on Linux during Python stack installation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| fi | ||
| _mkt="" | ||
| if command -v lspci >/dev/null 2>&1; then | ||
| _mkt=$(lspci -nn 2>/dev/null | awk -F: '/VGA compatible controller|3D controller|Display controller/{sub(/^[^:]*:[^:]*:[[:space:]]*/,""); print; exit}') |
There was a problem hiding this comment.
The lspci parsing logic using awk fails on systems where the PCI address includes a domain prefix (e.g., 0000:03:00.0 instead of 03:00.0), which is the default on many modern Linux distributions. When a domain is present, sub(/^[^:]*:[^:]*:[[:space:]]*/,"") only strips the first two colons, leaving the controller description (e.g., 00.0 VGA compatible controller...) in the output, which prevents _infer_amd_gfx_arch_from_gpu_name from matching.
We can make this parsing robust by matching and stripping everything up to the controller class colon directly.
| _mkt=$(lspci -nn 2>/dev/null | awk -F: '/VGA compatible controller|3D controller|Display controller/{sub(/^[^:]*:[^:]*:[[:space:]]*/,""); print; exit}') | |
| _mkt=$(lspci -nn 2>/dev/null | awk '/VGA compatible controller|3D controller|Display controller/{sub(/^.*(VGA compatible|3D|Display) controller[^:]*:[[:space:]]*/,""); print; exit}') |
| for line in result.stdout.splitlines(): | ||
| if re.search(r"VGA compatible controller|3D controller|Display controller", line, re.I): | ||
| parts = line.split(":", 2) | ||
| if len(parts) >= 3: | ||
| name = parts[2].strip() | ||
| return name or None |
There was a problem hiding this comment.
Similar to the install.sh parser, line.split(":", 2) fails to extract the correct GPU marketing name when the PCI address contains a domain prefix (e.g., 0000:03:00.0). In such cases, parts[2] will still contain the controller description prefix (e.g., 00.0 VGA compatible controller [0300]: ...), causing downstream matching to fail.
Using a regular expression to extract the marketing name directly after the controller class colon is much more robust and handles both domain-present and domain-absent formats.
for line in result.stdout.splitlines():
match = re.search(r"(?:VGA compatible|3D|Display) controller[^:]*:\s*(.*)", line, re.I)
if match:
return match.group(1).strip() or None| def _amd_arch_index_url(gfx_arch: str | None) -> str | None: | ||
| """Return repo.amd.com pip index URL for a gfx arch (Linux + Windows).""" | ||
| return _windows_rocm_index_url(gfx_arch) |
There was a problem hiding this comment.
On Linux, the documented environment variable for the AMD ROCm mirror is UNSLOTH_AMD_ROCM_MIRROR (as used in install.sh). However, _amd_arch_index_url delegates directly to _windows_rocm_index_url, which only checks UNSLOTH_ROCM_WINDOWS_MIRROR and defaults to https://repo.amd.com/rocm/whl. This causes UNSLOTH_AMD_ROCM_MIRROR to be ignored on Linux during python stack installation/updates.
We should update _amd_arch_index_url to check UNSLOTH_AMD_ROCM_MIRROR first on Linux.
| def _amd_arch_index_url(gfx_arch: str | None) -> str | None: | |
| """Return repo.amd.com pip index URL for a gfx arch (Linux + Windows).""" | |
| return _windows_rocm_index_url(gfx_arch) | |
| def _amd_arch_index_url(gfx_arch: str | None) -> str | None: | |
| """Return repo.amd.com pip index URL for a gfx arch (Linux + Windows).""" | |
| arch_family = _GFX_TO_AMD_INDEX_ARCH.get(gfx_arch or "") | |
| if arch_family is None: | |
| return None | |
| base = os.environ.get("UNSLOTH_AMD_ROCM_MIRROR") or os.environ.get("UNSLOTH_ROCM_WINDOWS_MIRROR") or "https://repo.amd.com/rocm/whl" | |
| return f"{base.rstrip('/')}/{arch_family}/" |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24807981f1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ) | ||
| rocm_torch_ready = True |
There was a problem hiding this comment.
Stop after installing inferred gfx wheels
When a supported gfx arch is inferred and any ROCm userland version is readable, this block installs the AMD per-arch wheels but leaves has_hip_torch as the pre-install False value. Execution then reaches the later elif not has_hip_torch generic ROCm reinstall and overwrites the per-arch Strix/RDNA wheel from repo.amd.com with download.pytorch.org/whl/rocmX.Y, which breaks exactly the fresh-ROCm/no-/dev/kfd case this path is meant to repair. Return or otherwise skip the generic reinstall after this successful inferred install.
Useful? React with 👍 / 👎.
| if [ "$_torch_index_pinned" = false ] && [ "$SKIP_TORCH" = false ] && \ | ||
| ! _has_usable_nvidia_gpu && \ | ||
| case "$(uname -s)" in Linux) true ;; *) false ;; esac; then |
There was a problem hiding this comment.
Keep WSL CPU fallback when ROCm-on-WSL is skipped
This condition is also true inside WSL because uname -s returns Linux, so after _maybe_bootstrap_rocm_wsl declines/fails or the user sets UNSLOTH_SKIP_ROCM_WSL_SETUP=1, a Strix host matching /proc/cpuinfo is rerouted from the WSL CPU fallback to AMD per-arch Linux wheels without the ROCDXG/librocdxg runtime. That defeats the WSL-specific skip/fallback path and can leave users with a ROCm wheel that cannot expose the GPU; gate this bare-metal inference out for OS=wsl unless the WSL bootstrap actually made ROCm visible.
Useful? React with 👍 / 👎.
| def _amd_arch_index_url(gfx_arch: str | None) -> str | None: | ||
| """Return repo.amd.com pip index URL for a gfx arch (Linux + Windows).""" | ||
| return _windows_rocm_index_url(gfx_arch) |
There was a problem hiding this comment.
Honor the Linux AMD mirror for inferred installs
For the new Linux inferred-gfx path, this helper delegates to _windows_rocm_index_url(), whose base is controlled only by UNSLOTH_ROCM_WINDOWS_MIRROR. The shell Linux path and the existing Linux Strix override use UNSLOTH_AMD_ROCM_MIRROR, so a Linux air-gapped user setting the documented AMD mirror will still have studio update reach repo.amd.com unless they know to set a Windows-specific variable.
Useful? React with 👍 / 👎.
| if re.search(r"VGA compatible controller|3D controller|Display controller", line, re.I): | ||
| parts = line.split(":", 2) | ||
| if len(parts) >= 3: | ||
| name = parts[2].strip() | ||
| return name or None |
There was a problem hiding this comment.
Scan all lspci display rows for an AMD match
On hybrid Linux systems where lspci lists an Intel iGPU before a supported AMD Radeon dGPU, this returns the first display-controller line and never examines the later AMD line, so _infer_linux_amd_gfx_arch() stays None and the update keeps CPU torch even though the dGPU is inferable. The shell helper added in this commit has the same early-exit behavior, so both paths should scan until a supported AMD marketing name maps to a gfx arch.
Useful? React with 👍 / 👎.
| if [ "$_torch_index_pinned" = false ] && [ "$SKIP_TORCH" = false ] && \ | ||
| ! _has_usable_nvidia_gpu && \ | ||
| case "$(uname -s)" in Linux) true ;; *) false ;; esac; then |
There was a problem hiding this comment.
Preserve CPU fallback on non-x86 Linux
On Linux architectures without published PyTorch ROCm wheels, such as aarch64, get_torch_index_url deliberately returns the CPU index, but this new inference gate does not repeat the uname -m check before rewriting */cpu to repo.amd.com/rocm/whl/gfx.... If UNSLOTH_ROCM_GFX_ARCH leaks into one of those installs, the installer will try an x86_64-only AMD wheel index instead of the intended CPU fallback.
Useful? React with 👍 / 👎.
|
Rebased on main and resolved the conflict. The Relationship to #7314: complementary, not conflicting. This PR does not touch One thing to weigh before merge: the reroute only fires when the alternative is CPU torch (no NVIDIA, no ROCm visible), and it installs wheels that still need the kernel stack to actually run GPU compute, so it prints the kernel-stack warning and honors |
…slothai#7305 The _amd_gpu_present_via_pci helper and the PCI-bus 'no GPU detected' hint already landed in main via unslothai#7293 / unslothai#7264, so this drops the duplicated copies and keeps main's versions. The unique part of unslothai#7301 stays: _infer_linux_amd_gfx_arch (UNSLOTH_ROCM_GFX_ARCH, /proc/cpuinfo, lspci) plus the install.sh + install_python_stack.py routing that installs AMD per-arch wheels when no ROCm runtime is visible, mirroring install.ps1 on Windows. This does not touch _has_amd_rocm_gpu, so it is complementary to unslothai#7314 (which fixes detection when the kernel driver is present).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e55df79449
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case "$1" in | ||
| *"9070 XT"*|*9080*) echo gfx1201 ;; | ||
| *9070*|*9060*) echo gfx1200 ;; | ||
| *"8060S"*|*"8050S"*|*"8040S"*|*"Strix Halo"*|*"Ryzen AI Max"*|*"AI Max"*) echo gfx1151 ;; |
There was a problem hiding this comment.
Map Radeon 8065S in the Linux marketing-name fallback
Add 8065S to this Strix Halo pattern. When /proc/cpuinfo does not expose the Ryzen AI Max branding (for example, a container or VM with a passed-through GPU) but lspci reports AMD Radeon 8065S, the new fallback returns no gfx arch and leaves the install on CPU torch. The corresponding PowerShell and studio/setup.sh name tables already recognize 8065S as gfx1151.
Useful? React with 👍 / 👎.
|
Thank you so much for taking the time to rebase this, clean up the duplicate PCI bits, and walk through how it sits next to #7314 — really appreciate the care and the clear explanation. Totally agree on the tradeoff: installing the AMD wheels when the only alternative is CPU is the right call, and the kernel-stack warning plus If you have any other issues you'd recommend I pick up next, I'd love to help — happy to take whatever would be most useful. |
install.sh _infer_amd_gfx_arch_from_gpu_name missed 8065S, so a Strix Halo host that only exposes 'AMD Radeon 8065S' via lspci (no Ryzen AI Max branding in /proc/cpuinfo) was left on CPU torch. setup.sh and setup.ps1 already list 8065S -> gfx1151. Added it, and widened the cpuinfo regexes (install.sh and install_python_stack.py) from Radeon 80[0-9]0S to 80[0-9][05]S to match the 80X5S naming, consistent with the display-side check already in install.sh. Tests cover the 8065S name and the cpuinfo-only case.
|
Thanks @Souravrajvi0, appreciate it. Pushed one more small fix from the review: added |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f27708438e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # Mirror _ensure_cuda_torch: skip the NVIDIA/no-AMD/unreadable gates. | ||
| _rocm_pin = _explicit_rocm_torch_index_url() | ||
| _inferred_linux_gfx = ( | ||
| _infer_linux_amd_gfx_arch() if (_rocm_pin is None and not IS_WINDOWS) else None |
There was a problem hiding this comment.
Gate inferred ROCm repair out of WSL
When this runs under WSL as a standalone unsloth studio update, IS_WINDOWS is false and the new inference can resolve gfx1151 from /proc/cpuinfo/lspci even though the WSL ROCDXG/librocdxg runtime was never bootstrapped. That bypasses the WSL CPU fallback and installs AMD per-arch ROCm torch wheels into an environment that still cannot expose the GPU; skip this inference on WSL unless the WSL ROCm runtime is already present.
Useful? React with 👍 / 👎.
…r PR unslothai#7305 On WSL /proc/cpuinfo and lspci still see the host APU, so a standalone 'unsloth studio update' could infer gfx1151 and install per-arch ROCm wheels into a WSL env whose ROCDXG bridge (librocdxg) was never bootstrapped, i.e. one that cannot expose the GPU. Skip the cpuinfo/lspci inference on WSL unless librocdxg is present; an explicit UNSLOTH_ROCM_GFX_ARCH override still wins.
|
Good catch. Pushed a47e81f: the cpuinfo/lspci inference is now skipped on WSL unless the ROCDXG runtime is present. Rationale: on WSL /proc/cpuinfo and lspci still report the host APU (this box reads "AMD RYZEN AI MAX+ PRO 395 w/ Radeon 8060S"), so a standalone _wsl_rocm_runtime_present() mirrors the existing librocdxg probe in install_llama_prebuilt.py (checks /opt/rocm*/lib*). Verified on a real WSL + ROCm 7.2.1 box: _is_wsl() True, runtime present, _infer_linux_amd_gfx_arch() still returns gfx1151 (unchanged). Added test_infer_gfx_gated_out_of_wsl_without_runtime covering all four cases (WSL no-runtime, WSL runtime, native Linux, override). tests/studio/install/test_rocm_support.py: 349 passed, 3 skipped. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68143d2f4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case "$(uname -s)" in Linux) true ;; *) false ;; esac; then | ||
| case "$TORCH_INDEX_URL" in | ||
| */cpu) | ||
| _linux_inferred_gfx=$(_infer_linux_amd_gfx_arch 2>/dev/null || true) |
There was a problem hiding this comment.
Gate WSL inference on the ROCDXG runtime
On a WSL Strix host where the ROCm bootstrap is skipped, declined by Tauri, or fails, this block still infers the APU from /proc/cpuinfo and replaces the CPU index with AMD wheels. That contradicts _maybe_bootstrap_rocm_wsl's CPU fallback: without librocdxg, those wheels cannot expose the GPU and the installer reports a ROCm route despite the runtime being unavailable. Suppress automatic inference on WSL unless the ROCDXG runtime is present (while keeping an explicit gfx override authoritative).
Useful? React with 👍 / 👎.
| def _amd_arch_index_url(gfx_arch: str | None) -> str | None: | ||
| """Return repo.amd.com pip index URL for a gfx arch (Linux + Windows).""" | ||
| return _windows_rocm_index_url(gfx_arch) |
There was a problem hiding this comment.
Honor the Linux AMD mirror during Studio repair
When a native Linux inferred-gfx installation uses UNSLOTH_AMD_ROCM_MIRROR, this helper still delegates to _windows_rocm_index_url, whose base only reads UNSLOTH_ROCM_WINDOWS_MIRROR. Consequently, a subsequent unsloth studio update with CPU torch ignores the mirror that install.sh used and contacts repo.amd.com, breaking the new repair path for air-gapped or mirrored Linux deployments. Use the Linux AMD mirror variable for this Linux call path.
Useful? React with 👍 / 👎.
| if [ "$_torch_index_pinned" = false ] && [ "$SKIP_TORCH" = false ] && \ | ||
| ! _has_usable_nvidia_gpu && \ | ||
| case "$(uname -s)" in Linux) true ;; *) false ;; esac; then |
There was a problem hiding this comment.
Keep inferred ROCm routing restricted to x86_64
get_torch_index_url deliberately returns the CPU index on non-x86_64 Linux because the project does not publish ROCm wheels for those architectures, but this later block reroutes that CPU result solely based on uname -s. Thus an arm64 Linux host with a recognized AMD GPU (or UNSLOTH_ROCM_GFX_ARCH set) is sent to the AMD gfx index and the torch install fails instead of retaining the intended CPU fallback. Apply the same x86_64|amd64 guard here.
Useful? React with 👍 / 👎.
…rror, arch guard) - install.sh _infer_linux_amd_gfx_arch: skip the cpuinfo/lspci inference on WSL unless librocdxg is present (the ROCDXG bridge), mirroring the Python fix, so a WSL box whose ROCm bootstrap was skipped keeps the CPU fallback instead of installing AMD wheels that cannot reach the GPU. The explicit UNSLOTH_ROCM_GFX_ARCH override still returns first, so it stays authoritative. - install.sh: guard the inferred-gfx reroute on x86_64|amd64. ROCm torch wheels are not published for arm64, so an inferred/overridden gfx no longer pushes an arm64 host to the AMD arch index (get_torch_index_url returns CPU there). - install_python_stack.py _amd_arch_index_url: honour UNSLOTH_AMD_ROCM_MIRROR on Linux (the same var install.sh uses) instead of the Windows mirror var, so a mirrored/air-gapped Linux 'unsloth studio update' reaches the index install.sh chose. Windows still delegates unchanged; both default to repo.amd.com.
|
Addressed all three in a0fbf37:
Added tests for all three; tests/studio/install/test_rocm_support.py passes (352 passed, 3 skipped) and bash -n is clean. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9167e392fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| parts = line.split(":", 2) | ||
| if len(parts) >= 3: | ||
| name = parts[2].strip() | ||
| return name or None |
There was a problem hiding this comment.
Scan all display controllers before selecting an AMD architecture
On hosts where a non-AMD display controller is listed before a supported AMD GPU (for example, an Intel iGPU plus an AMD dGPU), this returns the first controller's name immediately. _gfx_arch_from_gpu_name then returns None, so studio update leaves the CPU torch installation in place despite a later supported AMD controller being available; continue scanning until a name maps to a supported gfx architecture.
Useful? React with 👍 / 👎.
| fi | ||
| _mkt="" | ||
| if command -v lspci >/dev/null 2>&1; then | ||
| _mkt=$(lspci -nn 2>/dev/null | awk -F: '/VGA compatible controller|3D controller|Display controller/{sub(/^[^:]*:[^:]*:[[:space:]]*/,""); print; exit}') |
There was a problem hiding this comment.
Scan all display controllers before selecting an AMD architecture
When lspci lists an unrelated display controller before a supported AMD GPU, the exit makes the installer inspect only that first controller. Its name cannot map to a gfx architecture, so this new fallback keeps the CPU index instead of routing the later AMD GPU to its per-arch wheels; scan subsequent display-controller lines until a supported AMD name is found.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40a74c95e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fi | ||
| _mkt="" | ||
| if command -v lspci >/dev/null 2>&1; then | ||
| _mkt=$(lspci -nn 2>/dev/null | awk -F: '/VGA compatible controller|3D controller|Display controller/{sub(/^[^:]*:[^:]*:[[:space:]]*/,""); print; exit}') |
There was a problem hiding this comment.
Search all display adapters for an AMD match
On Linux systems where an Intel iGPU (or another non-AMD adapter) appears before a supported AMD dGPU in lspci, this command captures the first display controller and exits. _infer_amd_gfx_arch_from_gpu_name then receives the non-AMD name and returns nothing, so a host with no visible ROCm runtime falls back to CPU wheels even though a supported AMD GPU is present later in the listing. Scan the display-controller lines until a known AMD mapping is found; the Python fallback has the same first-match behavior.
Useful? React with 👍 / 👎.
|
Thanks for landing the remaining Codex P2 (scan all display controllers / domain-safe matching) — that was the next item I was about to push. Looks good on my side; happy for you to merge whenever you're ready. |
|
Addressed the latest Codex P2 in 13d5534. It was real in both files: the lspci fallback inspected only the first display-class line (awk exit in install.sh, first-match return in install_python_stack.py), so a non-AMD controller enumerating first (Intel iGPU on a desktop with an AMD dGPU, an ASPEED BMC on a server) blocked a later supported AMD GPU and left the CPU torch in place. Both sides now scan every display-class line and take the first AMD one that maps to a known gfx arch. Two details worth noting from implementing it:
Executed tests on both sides: Intel-then-AMD finds the dGPU (gfx1100), NVIDIA-only maps nothing, a domain-prefixed Strix line maps gfx1151, and an unmapped AMD line followed by a mapped one keeps scanning. Full suite passes (356 tests) and bash -n is clean. No behavior change on hosts where cpuinfo already matches (this Strix Halo box never reaches the lspci fallback). |
Bring the PR branch up to date with upstream main (unslothai#7327, unslothai#7308, unslothai#5988).
After a successful inferred-gfx install, skip the generic pytorch.org ROCm reinstall so readable ROCm userland without /dev/kfd cannot undo the per-arch repair (Codex P1 on unslothai#7305). Also merge latest main.
|
Quick follow-up after rechecking all review notes + the “branch out of date” banner:
Happy to adjust if you’d rather handle that P1 differently. |
|
Just pushed two follow-ups on this branch:
Your lspci scan-all fix is unchanged. Happy to tweak anything if needed. |
|
Reviewed dee0b0c and it is correct, thanks. rocm_torch_ready is defined as has_hip_torch and not _rocm_pin_mismatch, so I also ran a fresh full-matrix review of this PR at head in a clean worktree (old and new AMD with and without ROCm, OEM-renamed cpuinfo, mixed Intel plus AMD and AMD plus NVIDIA boxes with and without nvidia-smi, BMC-first lspci, domain-prefixed lspci, NVIDIA-only, CPU-only, Mac, Windows, WSL with and without librocdxg, native Linux, arm64, containers, every pin and mirror, and the updater re-run path). Everything holds; the only residual note is benign: when ROCm userland AND the GPU are both visible with CPU torch installed, the inferred block and the Strix override can each install the same gfx1151 wheels once (identical index and pins, converges correctly, and the normal install.sh flow never enters that state since torch is already ROCm by then). Not worth more branching in my view. Suite passes at head: 357 tests, bash -n clean. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dee0b0c233
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if grep -qiE 'Ryzen AI Max|Radeon 80[0-9][05]S|Strix Halo' /proc/cpuinfo 2>/dev/null; then | ||
| echo gfx1151 | ||
| return 0 |
There was a problem hiding this comment.
Honor the selected AMD dGPU before cpuinfo fallback
When a Strix/Ryzen AI Max APU system also has a supported AMD dGPU and the user selects that dGPU with HIP_VISIBLE_DEVICES/ROCR_VISIBLE_DEVICES, this early /proc/cpuinfo return chooses the APU arch before the PCI display list is considered. The later reroute uses that value for TORCH_INDEX_URL, so the venv gets gfx1151 wheels rather than the selected dGPU's family (for example gfx110X-all), leaving GPU torch unusable once ROCm is made visible. Check the AMD display-controller candidates/visible-device selection before using cpuinfo as a fallback, and mirror the same fix in studio/install_python_stack.py.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dee0b0c233
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _inferred_linux_gfx = ( | ||
| _infer_linux_amd_gfx_arch() if (_rocm_pin is None and not IS_WINDOWS) else None | ||
| ) |
There was a problem hiding this comment.
Restrict inferred gfx routing to runtime-less hosts
When studio update runs on a host with a working ROCm runtime but CPU-only torch, this computes an inferred arch unconditionally and the later inferred-gfx branch installs from that per-arch index before the existing runtime/HIP_VISIBLE_DEVICES selection logic runs. On a mixed AMD system—e.g. a Strix APU plus an RX 7900 selected with HIP_VISIBLE_DEVICES—/proc/cpuinfo yields gfx1151, so the update replaces torch with gfx1151 wheels even though the active GPU is gfx1100. Those wheels are selected specifically per architecture and can leave the intended GPU unusable. Only use the cpuinfo/lspci fallback after confirming that ROCm cannot enumerate a GPU, or derive the arch from the runtime-visible device when it can.
Useful? React with 👍 / 👎.
|
Fixed the latest Codex P1 in 7562c19. Verified real: the inferred-gfx install was gated on torch not being ROCm, but never on the runtime actually failing to see a GPU. On a mixed box (Strix APU plus RX 7900 selected via HIP_VISIBLE_DEVICES, working ROCm, CPU torch) a studio update would install cpuinfo-derived gfx1151 wheels for a gfx1100 active GPU. The block now also requires Also ran sandboxed simulations for this PR: an 85-case corpus of real cpuinfo model strings and lspci lines (Strix, RDNA2/3/4, EPYC, Xeon, Intel Core/Arc, NVIDIA including the GTX 860M/880M name traps, ASPEED, Matrox, virtio, WSL Basic Render, PCI domain prefixes, multi-controller orderings) driven through BOTH the Python functions and the extracted install.sh mapper with shell/Python parity asserted, plus the WSL gate, override, and mirror matrices. All pass on Windows and Linux. Suite: 358 tests. |
|
One more from running the suite on a real Strix Halo Linux box in a sandbox (2f2): test_no_rocm_skips, test_version_unreadable_prints_warning and test_no_gpu_with_rocm_tools_skips did not mock _infer_linux_amd_gfx_arch, so on Strix hardware the live /proc/cpuinfo took the new inferred-install path and broke their "must not install" assertions. CI never sees it (runners are not Strix) and Windows never sees it (no /proc/cpuinfo), but any Strix Linux dev box running the suite would. Fixed in 326cce6 by mocking the inference to None in those three hosts. Suite now 358 passed on both Windows and Linux on this machine. |
… (Strix dev box leak)
|
Tested this branch on Windows 11 + Radeon RX 9060 XT (gfx1200, single dGPU, ROCm runtime present), to confirm the inferred-gfx fallback doesn't disturb normal detection when the runtime can see the GPU:
Works on RX 9060 XT. Can't exercise the Strix Halo inference path itself here (no Strix hardware), this covers the discrete-GPU non-regression side. |
LeoBorcherding
left a comment
There was a problem hiding this comment.
Reviewed the final diff. The approach is sound and the final state is consistent:
- The inference is properly fenced: it only engages with no explicit ROCm pin, no usable NVIDIA GPU, and
_has_rocm_gpu()false, and it yields to the runtime-visible arch when the runtime can enumerate a GPU, so a mixed APU + dGPU box with a working runtime never gets APU wheels. - Both earlier P1s are fixed in the final state: the generic
pytorch.org/rocmX.Yreinstall now gates onrocm_torch_readyso it can't overwrite a successful inferred per-arch install, and WSL withoutlibrocdxgsuppresses the inference in bothinstall.shandinstall_python_stack.py(an explicitUNSLOTH_ROCM_GFX_ARCHoverride stays authoritative). - The detection details are careful: the lspci scan covers all display-class lines with a case-sensitive
AMD|ATIvendor guard, the reroute is x86_64-only, and Linux honoursUNSLOTH_AMD_ROCM_MIRRORso mirrored installs don't fall back to repo.amd.com. - Verified no regression on a Windows + Radeon RX 9060 XT host (details in my comment above): 359 passed / 2 skipped in
test_rocm_support.py, and a fresh install off this branch still took the normal runtime-detection path (gfx1200) with a full studio workflow clean.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 326cce6eca
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…tup.sh for PR unslothai#7305 (Codex P2s)
|
Addressed both remaining Codex P2s in 1f7490f:
Added |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc17199641
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…rride with visible ROCm for PR unslothai#7305 (Codex P2s)
|
Both new Codex P2s were real; fixed in 652dcab.
Added |
…e-dup) Merge upstream/main (resolve the _ensure_rocm_torch elif chain against unslothai#7305's inferred-gfx path: keep the gfx906 branch, adopt the new 'elif not rocm_torch_ready' fallback), then fix three Codex findings: - Skip the prebuilt bitsandbytes wheel on gfx906 (install.sh + studio install_python_stack.py). It ships no gfx906 kernels and would clobber a user's source-built bnb on every studio update; gate both bnb call sites on a gfx906 target and print source-build guidance instead. - Honor UNSLOTH_ROCM_GFX_ARCH in the gfx906 reroute decision (was only consulted for the display label / Windows path), so a runtime-only ROCm host whose rocminfo/amd-smi emit no gfx token can still opt in. - Only auto-reroute when gfx906 is the SOLE distinct detected arch. _detect_amd_gfx_codes()/_gfx_all de-duplicate arches, losing per-device ordinals, so a mixed host with duplicate arches could downgrade a non-gfx906 selection to rocm6.3. Mixed gfx906+dGPU hosts opt in via UNSLOTH_ROCM_GFX_ARCH. New/updated tests: _runtime_target_is_gfx906 selection matrix, env override reroute, mixed-host skip, and generic-bnb skip. rocm_support + selection + cross-platform parity: 664 passed, 17 skipped; bash -n clean.
Reconcile PR #7256 (Windows torch 2.11 + release preservation, installer comment reduction, torch 2.11 default line) with 77 commits of main install rewrites. Base is main's newer install semantics; this branch's still-novel contributions are layered on top. Key decisions: - install.ps1: kept main's rollback lifecycle (try/finally Restore-StudioVenvRollback, #7342) and the installed-version report (#7265); layered this branch's torch-2.11 allowance (torch<2.12.0 on the Windows CUDA fresh-install, CPU fallback and flavor repairs), the release-preservation port (Get-InstalledTorchVersionRaw / kept-release installs / UNSLOTH_KEPT_TORCH handoff / torch-overrides freeze) and the Exit-InstallFailure UNSLOTH_KEPT_TORCH clear. - install.sh: took main's newer AMD/Strix routing (per-arch index reroute #7264/#7300, runtime-less gfx inference #7305, KFD detection fix #7314, Radeon 8065S regex #7290, signal-restore trap #7342) and the #7365 unsloth pin bump; kept this branch's _TORCH_CEILING/_TORCHVISION_CEILING/_TORCHAUDIO_CEILING refactor widening the default ceiling to torch<2.12.0. - studio/install_python_stack.py: deferred all five code conflicts to main's Strix inference logic (result is AST-identical to main; only comment reductions remain). - studio/setup.ps1: took main's comment covering the whisper.cpp dictation markers (#7095); the UNSLOTH_KEPT_TORCH consumption handoff auto-merged intact. Dropped as superseded by main: this branch's stale unsloth>=2026.7.4 pins (main #7365), the older rocm7.1->rocm7.2 Strix reroute (main #7264/#7300), the narrow Radeon 80[0-9]0S regex (main #7290), and the pre-inference has_hip_torch gate (main's rocm_torch_ready gate, Codex P1 #7305). The two review-item fixes (grep -E in test_torch_constraint.sh, UNSLOTH_KEPT_TORCH clear in Exit-InstallFailure) survive.
Fixes #7301
Problem
On bare-metal Linux (reported: Arch/CachyOS) with Strix Halo, the installer prints
gpu none (CPU-only)and installs CPU PyTorch because_has_amd_rocm_gpu()requires/dev/kfd,rocminfo, oramd-smi. Fresh ROCm installs often lack the kernel stack even though the APU is present in/proc/cpuinfoand on the PCI bus.Windows already handles this via
install.ps1name→gfx inference ($ROCmGfxArchroutes torepo.amd.comeven when$HasROCmis false). Linux had no equivalent.Fix
install.sh: Add_infer_linux_amd_gfx_arch()(UNSLOTH_ROCM_GFX_ARCH,/proc/cpuinfo, lspci marketing names) and reroute a CPU torch index to AMD per-arch wheels when a supported gfx arch is inferred.studio/install_python_stack.py: Mirror the same inference in_ensure_rocm_torch()sostudio updaterepairs torch on these hosts.tests/studio/install/test_rocm_support.py: Coverage for inferred-gfx installs without a ROCm runtime.The duplicated
_amd_gpu_present_via_pcihelper / PCI-bus hint were dropped after rebase — those already landed onmainvia #7293 / #7264.Verification
Compatibility
_has_usable_nvidia_gpugate).UNSLOTH_ROCM_GFX_ARCH.