Skip to content

fix(install): infer Strix gfx when ROCm runtime is absent - #7305

Merged
LeoBorcherding merged 19 commits into
unslothai:mainfrom
Souravrajvi0:fix/7301-strix-halo-gpu-detection
Jul 23, 2026
Merged

LeoBorcherding merged 19 commits into
unslothai:mainfrom
Souravrajvi0:fix/7301-strix-halo-gpu-detection

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

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, or amd-smi. Fresh ROCm installs often lack the kernel stack even though the APU is present in /proc/cpuinfo and on the PCI bus.

Windows already handles this via install.ps1 name→gfx inference ($ROCmGfxArch routes to repo.amd.com even when $HasROCm is 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() so studio update repairs 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_pci helper / PCI-bus hint were dropped after rebase — those already landed on main via #7293 / #7264.

Verification

bash -n install.sh
pytest tests/studio/install/test_rocm_support.py::TestEnsureRocmTorch::test_inferred_gfx_without_rocm_runtime_installs_amd_index -v
pytest tests/studio/install/test_rocm_support.py::TestStrixRocm71Override -v

Compatibility

  • Only fires when the torch index would otherwise be CPU and no torch index pin is set.
  • NVIDIA hosts unchanged (_has_usable_nvidia_gpu gate).
  • Users with a working ROCm runtime keep the existing rocminfo/KFD path.
  • Complementary to installer: fix false "no GPU detected" on AMD hosts (dead KFD check) + clearer ROCm-less warning #7314 (amdkfd present vs no ROCm runtime at all); either order is fine.
  • Inferred wheels still need the kernel stack to run GPU compute; the path prints that warning and honors UNSLOTH_ROCM_GFX_ARCH.

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).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread install.sh Outdated
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}')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
_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}')

Comment thread studio/install_python_stack.py Outdated
Comment on lines +786 to +791
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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

Comment thread studio/install_python_stack.py Outdated
Comment on lines +809 to +811
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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}/"

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment on lines +1782 to +1783
)
rocm_torch_ready = True

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread install.sh Outdated
Comment on lines +2819 to +2821
if [ "$_torch_index_pinned" = false ] && [ "$SKIP_TORCH" = false ] && \
! _has_usable_nvidia_gpu && \
case "$(uname -s)" in Linux) true ;; *) false ;; esac; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread studio/install_python_stack.py Outdated
Comment on lines +809 to +811
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread studio/install_python_stack.py Outdated
Comment on lines +787 to +791
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread install.sh Outdated
Comment on lines +2819 to +2821
if [ "$_torch_index_pinned" = false ] && [ "$SKIP_TORCH" = false ] && \
! _has_usable_nvidia_gpu && \
case "$(uname -s)" in Linux) true ;; *) false ;; esac; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

Rebased on main and resolved the conflict.

The _amd_gpu_present_via_pci helper and the PCI-bus "no GPU detected" hint already landed in main via #7293 / #7264, so I dropped the duplicated copies here (main's versions stand). The unique part of this PR is kept intact: _infer_linux_amd_gfx_arch (UNSLOTH_ROCM_GFX_ARCH, /proc/cpuinfo, lspci) plus the install.sh and install_python_stack.py routing that installs AMD per-arch wheels when no ROCm runtime is visible, mirroring what install.ps1 already does on Windows.

Relationship to #7314: complementary, not conflicting. This PR does not touch _has_amd_rocm_gpu; #7314 fixes detection when the amdkfd driver is present, while this handles the case where no ROCm runtime is visible at all. They can land in either order.

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 UNSLOTH_ROCM_GFX_ARCH as the explicit override. Green and mergeable now.

…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).

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread install.sh Outdated
case "$1" in
*"9070 XT"*|*9080*) echo gfx1201 ;;
*9070*|*9060*) echo gfx1200 ;;
*"8060S"*|*"8050S"*|*"8040S"*|*"Strix Halo"*|*"Ryzen AI Max"*|*"AI Max"*) echo gfx1151 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

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 UNSLOTH_ROCM_GFX_ARCH keep that path honest. Happy for you to merge whenever you're ready.

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.
@danielhanchen

Copy link
Copy Markdown
Member

Thanks @Souravrajvi0, appreciate it. Pushed one more small fix from the review: added 8065S to the Linux gfx inference (_infer_amd_gfx_arch_from_gpu_name). A Strix Halo host that only exposes "AMD Radeon 8065S" via lspci (no Ryzen AI Max branding in /proc/cpuinfo) was falling through to CPU torch, even though setup.sh and setup.ps1 already map 8065S to gfx1151. Also widened the two cpuinfo regexes from Radeon 80[0-9]0S to 80[0-9][05]S so the 80X5S naming matches, consistent with the display-side check already in install.sh. Tests cover both the name and cpuinfo-only paths.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@unslothai unslothai deleted a comment from Sandeep-Kommineni Jul 22, 2026
…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.
@danielhanchen

Copy link
Copy Markdown
Member

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 unsloth studio update could infer gfx1151 and pull the per-arch ROCm wheels into an env whose ROCDXG bridge (librocdxg over /dev/dxg) was never bootstrapped, i.e. one that still can't expose the GPU. The gate sits in _infer_linux_amd_gfx_arch after the override check: _is_wsl() and not _wsl_rocm_runtime_present() returns None, so WSL-without-runtime keeps CPU torch, while an explicit UNSLOTH_ROCM_GFX_ARCH override still wins and native Linux is untouched.

_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.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread install.sh
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread studio/install_python_stack.py Outdated
Comment on lines +837 to +839
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread install.sh Outdated
Comment on lines +2818 to +2820
if [ "$_torch_index_pinned" = false ] && [ "$SKIP_TORCH" = false ] && \
! _has_usable_nvidia_gpu && \
case "$(uname -s)" in Linux) true ;; *) false ;; esac; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@danielhanchen

Copy link
Copy Markdown
Member

Addressed all three in a0fbf37:

  1. Gate WSL inference on the ROCDXG runtime (P1): install.sh's _infer_linux_amd_gfx_arch now skips the cpuinfo/lspci inference on WSL unless librocdxg is present, mirroring the Python-side gate. A WSL box whose ROCm bootstrap was skipped/declined/failed keeps the CPU fallback instead of getting AMD wheels it can't drive over /dev/dxg. The explicit UNSLOTH_ROCM_GFX_ARCH override still returns first, so it stays authoritative. Verified on a real WSL + ROCm 7.2.1 box (librocdxg present -> still infers gfx1151, unchanged) and a path-simulated bare-WSL (no librocdxg -> inference skipped, override still honored).

  2. Honor the Linux AMD mirror (P2): _amd_arch_index_url now uses UNSLOTH_AMD_ROCM_MIRROR on Linux (the same var install.sh uses) instead of delegating to the Windows mirror var, so a mirrored/air-gapped unsloth studio update reaches the index install.sh chose. Windows still delegates unchanged; both default to repo.amd.com when unset (no change for default installs).

  3. Restrict inferred routing to x86_64 (P2): the reroute now guards on case "$_ARCH" in x86_64|amd64), so an inferred/overridden gfx no longer pushes an arm64 host to the AMD arch index (no arm64 ROCm wheels; get_torch_index_url already returns CPU there).

Added tests for all three; tests/studio/install/test_rocm_support.py passes (352 passed, 3 skipped) and bash -n is clean.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread studio/install_python_stack.py Outdated
parts = line.split(":", 2)
if len(parts) >= 3:
name = parts[2].strip()
return name or None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread install.sh Outdated
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}')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread install.sh Outdated
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}')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

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.

@danielhanchen

Copy link
Copy Markdown
Member

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:

  1. The candidate lines are vendor-guarded case-SENSITIVELY on AMD/ATI. A naive scan-all would have let an NVIDIA "GeForce GTX 860M" line hit the AMD 860M pattern and route an NVIDIA-only box to AMD wheels, and a case-insensitive guard would match the "ati" inside "Corporation" on every Intel/NVIDIA line. The new tests pin both traps.
  2. Matching now runs over the whole line instead of a colon-split, which also resolves the earlier Gemini review note about the 0000: PCI domain prefix. That claim did not actually break matching before (both matchers are substring based), but the rewrite makes it structurally moot and a domain-prefixed line is covered in the tests.

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).

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.
@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

Quick follow-up after rechecking all review notes + the “branch out of date” banner:

  1. Merged latest main into this branch (was 3 commits behind: Studio: reorder sidebar, rename Hub to Models #7327, Studio: lighten chat text weight on Linux to match macOS rendering #7308, Faster safetensors weight loading on unified-memory (integrated) GPUs #5988) — should clear the out-of-date warning.
  2. Your scan-all lspci fix in 13d5534 looks correct (AMD/ATI case-sensitive guard + whole-line match for domain prefixes). Left that as-is.
  3. One older Codex P1 still looked real in current code: after a successful inferred-gfx install, elif not has_hip_torch could still fall through and overwrite the AMD per-arch wheels with pytorch.org/rocmX.Y when ROCm userland version was readable but /dev/kfd wasn’t. Fixed by gating that path on not rocm_torch_ready, with a regression test.

Happy to adjust if you’d rather handle that P1 differently.

@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

Just pushed two follow-ups on this branch:

  1. Merged latest main so the branch is no longer out of date.
  2. Fixed the remaining Codex P1 where an inferred AMD per-arch torch install could still get overwritten by the generic pytorch.org/rocmX.Y path when ROCm userland was readable but /dev/kfd wasn’t — gated that on rocm_torch_ready and added a regression test.

Your lspci scan-all fix is unchanged. Happy to tweak anything if needed.

@danielhanchen

Copy link
Copy Markdown
Member

Reviewed dee0b0c and it is correct, thanks. rocm_torch_ready is defined as has_hip_torch and not _rocm_pin_mismatch, so elif not rocm_torch_ready is semantically identical to the old not has_hip_torch or _rocm_pin_mismatch on every pre-existing path (CPU torch reinstall and pin-mismatch reinstall both still fire), and differs only after a successful inferred-gfx install, which is exactly the overwrite this closes. It also removes the misleading "No PyTorch wheel for ROCm 0.0" line on the fresh no-ROCm path.

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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread install.sh Outdated
Comment on lines +2195 to +2197
if grep -qiE 'Ryzen AI Max|Radeon 80[0-9][05]S|Strix Halo' /proc/cpuinfo 2>/dev/null; then
echo gfx1151
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment on lines +1758 to +1760
_inferred_linux_gfx = (
_infer_linux_amd_gfx_arch() if (_rocm_pin is None and not IS_WINDOWS) else None
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

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 not _has_rocm_gpu(), so when the runtime CAN enumerate, the runtime-visible arch (Strix override or generic branch) decides, exactly as suggested. Both repair cases are preserved: no ROCm tools at all, and readable userland with an invisible GPU, still take the inferred path. Added test_inference_yields_to_runtime_visible_gpu (mixed-box scenario asserts no gfx1151 install and the generic rocm7.1 route).

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.

@danielhanchen

danielhanchen commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

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.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

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:

  • Full tests/studio/install/test_rocm_support.py in the studio venv: 359 passed, 2 skipped.
  • Fresh install off this branch: the installer detected AMD ROCm (gfx1200) via the runtime as before, selected the gfx120X wheel index, and installed torch 2.11.0+rocm7.13.0. The inference path stayed out of the way, as it should with a working runtime.
  • End to end in Studio: hardware detection reported ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XT, loaded Qwen3-1.7B-UD-Q4_K_XL through llama-server (~122 tok/s decode), ran two 30-step LoRA finetunes of Qwen3.5-2B (~867 tok/s training throughput on the second run), and exported the adapter to GGUF (Q4_K_M). No regressions.

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 LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.Y reinstall now gates on rocm_torch_ready so it can't overwrite a successful inferred per-arch install, and WSL without librocdxg suppresses the inference in both install.sh and install_python_stack.py (an explicit UNSLOTH_ROCM_GFX_ARCH override stays authoritative).
  • The detection details are careful: the lspci scan covers all display-class lines with a case-sensitive AMD|ATI vendor guard, the reroute is x86_64-only, and Linux honours UNSLOTH_AMD_ROCM_MIRROR so 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.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread install.sh Resolved
Comment thread install.sh Resolved
@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Addressed both remaining Codex P2s in 1f7490f:

  • Preserve CPU fallback for visible unsupported ROCm: real gap. The */cpu reroute only checked that the index was CPU, not why, so a host whose AMD GPU is visible but whose ROCm version is unsupported/unreadable (a deliberate, warned-about CPU fallback in get_torch_index_url) could be flipped to inferred per-arch wheels. The reroute is now gated on _has_amd_rocm_gpu being false, so it only engages when the runtime genuinely can't see the GPU. An explicit UNSLOTH_ROCM_GFX_ARCH override bypasses the gate and stays authoritative.
  • Forward the inferred gfx to setup.sh: also real. The reroute changed only install.sh's torch index; setup.sh re-probes ROCm independently, finds nothing on these runtime-less hosts, and installed the CPU llama.cpp prebuilt next to AMD-wheel torch. The reroute now exports UNSLOTH_ROCM_GFX_ARCH with the inferred arch, which setup.sh and install_llama_prebuilt.py already honor, so llama.cpp lands on the matching ROCm prebuilt. A user-set override re-exports its own value unchanged.

Added test_install_sh_reroute_skips_visible_rocm_gpu and test_install_sh_reroute_exports_gfx_for_setup_sh; full test_rocm_support.py passes (361 passed, 2 skipped) and bash -n is clean.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread install.sh Resolved
Comment thread studio/install_python_stack.py Resolved
@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Both new Codex P2s were real; fixed in 652dcab.

  • Require GPU evidence before CPU-model inference: a VM/container on a Strix host still exposes the host CPU model in /proc/cpuinfo while receiving no AMD GPU, so the CPU-model text alone could route a GPU-less guest to ROCm wheels. On native Linux the cpuinfo inference now requires an AMD PCI display device first: install.sh gates both cpuinfo greps on the existing _amd_gpu_present_via_pci helper (vendor 0x1002, class 0x03*), and the Python updater mirrors it with a new _linux_amd_display_device_present sysfs scan. WSL is exempt (it enumerates no PCI display device; the /dev/dxg + librocdxg gate is the evidence there), the lspci fallback needs no gate (an AMD display line is itself the evidence), and the explicit UNSLOTH_ROCM_GFX_ARCH override still needs no device (headless/cross-install).
  • Honor explicit gfx overrides with visible ROCm: correct inconsistency. The shell path already exempts the override from the visible-GPU gate, but the updater's inferred-install branch still required not _has_rocm_gpu(), so on a host with a visible GPU and an unreadable/unsupported ROCm version a user-set UNSLOTH_ROCM_GFX_ARCH was silently discarded and CPU torch stayed. The gate now exempts the explicit override (automatic cpuinfo/lspci inference still yields to the runtime-visible arch, so the mixed APU + dGPU protection is unchanged).

Added test_infer_gfx_requires_amd_display_device_on_native_linux, test_install_sh_cpuinfo_inference_requires_pci_evidence, and test_gfx_override_installs_despite_visible_rocm; updated the WSL-gate test for the new evidence check. Full test_rocm_support.py passes (364 passed, 2 skipped), bash -n clean.

@LeoBorcherding
LeoBorcherding merged commit 978ae47 into unslothai:main Jul 23, 2026
50 of 53 checks passed
LeoBorcherding added a commit to LeoBorcherding/unsloth that referenced this pull request Jul 23, 2026
…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.
danielhanchen pushed a commit that referenced this pull request Jul 24, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Strix Halo no GPU detected (Linux)

3 participants