Skip to content

installer: fix false "no GPU detected" on AMD hosts (dead KFD check) + clearer ROCm-less warning - #7314

Merged
danielhanchen merged 27 commits into
unslothai:mainfrom
LeoBorcherding:amd-kfd-gpu-detect-fix
Jul 23, 2026
Merged

danielhanchen merged 27 commits into
unslothai:mainfrom
LeoBorcherding:amd-kfd-gpu-detect-fix

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Problem

On a fresh AMD box without ROCm userspace installed (e.g. CachyOS/Arch), the installer reports "no GPU detected" and installs CPU-only PyTorch, even though the AMD GPU is fully present and visible to the amdkfd kernel driver.

Reported on r/selfhosted by users on a 9070XT (CachyOS) and a 7900XTX, with the GPU clearly enumerated in KFD topology (vendor_id 4098).

Root cause

_has_amd_rocm_gpu() in install.sh tries rocminfo, then amd-smi, then a /dev/kfd sysfs-topology fallback for hosts with no ROCm tooling. That fallback required a gpu_id line inside each node's properties file:

awk 'FNR==1{ gpu=0; amd=0 } /gpu_id/{ gpu=($2+0>0) } /vendor_id/{ amd=($2==4098) } \
     gpu && amd { found=1 } END{ exit !found }' \
    /sys/class/kfd/kfd/topology/nodes/*/properties

But gpu_id is not a field in properties — it's a separate sibling sysfs file (nodes/N/gpu_id). So gpu never became 1, the condition could never be true, and the fallback silently failed for every ROCm-less AMD host. A user dump of the topology confirms it — only vendor_id lines exist, no gpu_id:

vendor_id 0        # CPU node
vendor_id 4098     # AMD GPU
vendor_id 4098     # AMD GPU

Fix

Key detection on vendor_id == 4098 (0x1002, AMD) directly. The KFD CPU node reports vendor_id 0, so any 4098 node is an AMD GPU; NVIDIA's open-kernel KFD nodes report 4318 (0x10DE) and remain excluded, so NVIDIA-only hosts don't false-positive.

awk '/vendor_id/ && $2 == 4098 { found = 1 } END { exit !found }' \
    /sys/class/kfd/kfd/topology/nodes/*/properties

Also reworked the follow-on "ROCm version could not be determined" warning into an actionable message. When the GPU is detected but no ROCm/HIP install is present to select the matching PyTorch wheel, it now tells the user to install the ROCm/HIP SDK (sudo pacman -S rocm-hip-sdk on Arch/CachyOS; docs link otherwise) instead of quietly falling back to CPU.

Testing

Verified the awk against synthesized topology dumps:

Host Result
AMD (CPU vendor_id 0 + GPU 4098) detected
NVIDIA-only (vendor_id 4318) not AMD
CPU-only (vendor_id 0) not AMD

Scope

  • Linux install.sh only. The Windows install.ps1 detection path (no /dev/kfd) is unchanged.
  • This is a detection + diagnostics fix. Hosts with no ROCm userspace still fall back to CPU for the wheel-version selection (version detection needs amd-smi/hipconfig/etc.), but now with a correct message instead of a false "no GPU detected." Auto-defaulting a ROCm version for pure-driver hosts can be a follow-up.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@LeoBorcherding LeoBorcherding changed the title Fix Linux AMD GPU detection on ROCm-less hosts (KFD topology fallback) installer: fix false "no GPU detected" on AMD hosts (dead KFD check) + clearer ROCm-less warning Jul 21, 2026
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

@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: 7d4bc89890

ℹ️ 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
danielhanchen added a commit to Souravrajvi0/unsloth that referenced this pull request Jul 22, 2026
…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).
The rocminfo/amd-smi-less fallback in _has_amd_rocm_gpu keyed on a
/gpu_id/ line inside each KFD node's properties file, but gpu_id is a
separate sibling sysfs file and never appears in properties. The guard
never matched, so the fallback missed every AMD host without ROCm
tooling (e.g. a fresh CachyOS/Arch box) and reported 'no GPU detected'
despite vendor_id 4098 being present in the KFD topology.

Detect via vendor_id == 4098 directly: the KFD CPU node reports
vendor_id 0, so any 4098 node is an AMD GPU, while NVIDIA's KFD nodes
report 4318 and stay excluded.

Also rework the 'ROCm version could not be determined' warning into an
actionable message (install the ROCm/HIP SDK; Arch/CachyOS:
rocm-hip-sdk) so ROCm-less users know the concrete next step instead of
silently landing on CPU-only PyTorch.
…heck

The FNR==1 reset guarded the old paired gpu_id+vendor_id awk against
cross-node state leakage. The new detection is a single atomic
vendor_id==4098 line condition, so there is no per-node state to reset;
assert the new invariant instead (single-line vendor match, and no
/gpu_id/ pattern, which never matched inside properties).

tests/studio/install/test_rocm_support.py: 344 passed, 2 skipped.
@LeoBorcherding
LeoBorcherding force-pushed the amd-kfd-gpu-detect-fix branch from da3fd99 to 0abb39d Compare July 22, 2026 05:53
@LeoBorcherding
LeoBorcherding marked this pull request as ready for review July 22, 2026 05:53
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@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: 0abb39d590

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

@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: 0abb39d590

ℹ️ 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
LeoBorcherding and others added 2 commits July 22, 2026 01:07
…back summary

Codex P2 follow-ups:
- studio/setup.sh carried the same dead gpu_id-inside-properties awk, so a
  host install.sh now routes to ROCm still failed setup's independent AMD
  re-probe and got a CPU llama.cpp. Use the same per-line vendor_id 4098
  check.
- When the AMD GPU is detected but the torch index stays CPU, the summary
  printed the old false diagnosis (gpu none / "No GPU detected"). Gate both
  on _has_amd_rocm_gpu and say what actually happened: AMD GPU present, no
  usable ROCm, CPU fallback.
- Structure test asserting setup.sh's KFD awk stays in sync with install.sh.

@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: 99ef6c00b6

ℹ️ 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 studio/setup.sh
Comment on lines 1103 to 1105
elif [ -e /dev/kfd ] && \
awk 'FNR==1{ gpu=0; amd=0 } /gpu_id/{ gpu=($2+0>0) } /vendor_id/{ amd=($2==4098) } \
gpu && amd { found=1 } END{ exit !found }' \
awk '/vendor_id/ && $2 == 4098 { found = 1 } END { exit !found }' \
/sys/class/kfd/kfd/topology/nodes/*/properties 2>/dev/null; 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 Avoid forcing ROCm prebuilds without a gfx target

On KFD-only AMD machines that this branch now matches (no rocminfo/amd-smi, so _setup_gfx_all and _setup_mkt stay empty), _setup_amd_detected=true later makes setup append --has-rocm even though no gfx target was resolved (studio/setup.sh:1360-1363). The prebuilt resolver returns no published ROCm choice when host.rocm_gfx_target is missing (studio/install_llama_prebuilt.py:3914), so these installs skip the CPU prebuilt they used to get and fall into a local source build; on the ROCm-less hosts targeted by the install.sh warning, that becomes a slow CPU build or a degraded install if build deps are absent. Please keep KFD-only/no-userspace hosts on the CPU prebuilt fallback, or gate the ROCm forwarding/source-build path on a resolved gfx target or usable HIP toolchain.

Useful? React with 👍 / 👎.

Comment thread install.sh
Comment on lines +2118 to 2119
awk '/vendor_id/ && $2 == 4098 { found = 1 } END { exit !found }' \
/sys/class/kfd/kfd/topology/nodes/*/properties 2>/dev/null; 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 Avoid generic ROCm wheels when Strix gfx is unknown

For KFD-only AMD hosts where rocminfo/amd-smi are absent but hipconfig, /opt/rocm/.info/version, or rocm-core is present, this new fallback lets get_torch_index_url select a generic rocmX.Y PyTorch index. The later Strix reroute only discovers gfx1150/gfx1151 from rocminfo or amd-smi, so _runtime_gfx stays empty and the installer skips the arch-specific index even though the script documents that generic ROCm indexes below 7.13 lack the required Strix fixes (install.sh:2858-2864). On those Strix KFD-only installs, this changes the outcome from CPU fallback to a GPU torch build that is expected to hit the known Strix failures; please derive/require the gfx target for the KFD path or keep unknown-gfx KFD hosts on CPU with an override hint.

Useful? React with 👍 / 👎.

The KFD-topology fix makes _has_amd_rocm_gpu / _setup_amd_detected true on hosts that expose an AMD GPU to the kernel but ship no rocminfo/amd-smi. Detection alone does not mean ROCm is usable or that the gfx arch is known, and two downstream paths wrongly assumed it did:

- studio/setup.sh forwarded --has-rocm with no gfx, so install_llama_prebuilt found no per-gfx bundle and dropped to a HIP source build (slow, or a hard failure without build deps) instead of the CPU prebuilt these hosts used to get. Now --has-rocm is forwarded for a gfx-unknown host only when hipcc is present; otherwise it keeps the CPU prebuilt.

- install.sh get_torch_index_url selected a generic rocmX.Y index whenever the ROCm version was readable, but the Strix reroute only learns gfx from rocminfo/amd-smi, so a Strix KFD-only host landed on the broken _grouped_mm wheels. Now, when neither rocminfo nor amd-smi is present (gfx unknowable), it stays on CPU with a hint to install them.

Detection and the improved diagnostics are unchanged; only the routing for gfx-unknown KFD-only hosts is made safe. Adds tests for both gates.
@danielhanchen

Copy link
Copy Markdown
Member

Pushed a fix for both P2s from the Codex review.

Root cause: the KFD-topology fix correctly makes detection return true on hosts that expose an AMD GPU to the kernel but ship no rocminfo/amd-smi, but two downstream paths treated "AMD detected" as "usable ROCm + known gfx", which is false for exactly those hosts.

  • setup.sh (llama.cpp): _setup_amd_detected=true with no resolved gfx forwarded --has-rocm, so published_rocm_choice_for_host returned None (no gfx target) and the install dropped into a HIP source build instead of the CPU prebuilt these hosts used to get (slow, or a hard failure without build deps). Now the gfx-unknown --has-rocm branch is gated on hipcc being present; without a HIP toolchain it falls through to the CPU prebuilt.

  • install.sh (torch): get_torch_index_url selected a generic rocmX.Y index whenever the ROCm version was readable, but the Strix reroute only learns gfx from rocminfo/amd-smi, so a Strix KFD-only host landed on the broken _grouped_mm wheels. Now, when neither rocminfo nor amd-smi is present (so the gfx can't be read), it stays on CPU with a hint to install them.

Detection and the improved "AMD GPU detected, install ROCm" diagnostics are unchanged; only the routing for gfx-unknown KFD-only hosts is made safe. Added two tests (test_kfd_only_torch_falls_back_to_cpu, test_kfd_only_llama_requires_hipcc); full test_rocm_support.py is green (347 passed) and both scripts pass bash -n.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@Sandeep-Kommineni

This comment was marked as low quality.

@Sandeep-Kommineni

This comment was marked as low quality.

@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: e5da9331d1

ℹ️ 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
# (gfx1150/1151, which needs the arch-specific index) from other AMD GPUs.
# A generic rocm index would ship Strix the broken _grouped_mm wheels, so
# stay on CPU and point the user at the fix instead of guessing.
if ! command -v rocminfo >/dev/null 2>&1 && ! command -v amd-smi >/dev/null 2>&1; 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 Treat failed ROCm probes as KFD-only

On hosts where rocminfo/amd-smi are installed but do not enumerate the GPU or omit the gfx target, _has_amd_rocm_gpu can still succeed through the new KFD fallback, but this guard is bypassed solely because the binaries exist; with hipconfig/rocm-core available the function then selects a generic rocmX.Y index and the Strix reroute has no gfx value to correct it, so gfx1150/gfx1151 machines can still get the broken generic wheels instead of the CPU fallback. This is distinct from the previous no-binary case: the fallback is reached after a present probe fails, while the new guard only tests command -v.

Useful? React with 👍 / 👎.

Comment thread studio/setup.sh Outdated
Comment on lines +1360 to +1361
elif [ "$_setup_amd_detected" = true ] && \
{ command -v hipcc >/dev/null 2>&1 || [ -x /opt/rocm/bin/hipcc ]; }; 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 Recognize versioned ROCm hipcc paths

For KFD-only/gfx-unknown AMD hosts whose HIP toolchain is installed only under a versioned ROCm prefix such as /opt/rocm-6.4/bin/hipcc, this new gate evaluates false even though the later source-build path explicitly supports /opt/rocm-*/bin/hipcc at studio/setup.sh:1663. Because --has-rocm is not forwarded, install_llama_prebuilt.py treats the host as CPU-only and can install the CPU prebuilt successfully, so the ROCm source build that would have used that HIP toolchain is never reached.

Useful? React with 👍 / 👎.

Follow-up to the previous commit's two guards:

- install.sh: the KFD-only torch guard tested only 'command -v rocminfo/amd-smi', so a host where those binaries exist but do not enumerate the GPU (gfx unreadable) slipped through and, with hipconfig/rocm-core present, still got a generic rocm index -- breaking Strix. Now it actually reads the gfx (rocminfo, then amd-smi list / static --asic, the same probe the reroute uses) and falls back to CPU whenever the arch is unreadable, not just when the binaries are absent.

- studio/setup.sh: the hipcc gate missed a HIP toolchain installed only under a versioned prefix (/opt/rocm-*/bin/hipcc), which the source build at setup.sh:1663 does support, so such hosts were dropped to the CPU prebuilt unnecessarily. The gate now also accepts /opt/rocm-*/bin/hipcc.

Tests updated to assert the gfx-read (not binary-presence) gate and the versioned hipcc path; full test_rocm_support.py green (347 passed). Verified the gfx probe by execution: rocminfo-with-no-gfx now routes to CPU, amd-smi fallback still resolves gfx.
@danielhanchen

Copy link
Copy Markdown
Member

Addressed both follow-up P2s from the latest review.

  • install.sh (failed-probe vs no-binary): you're right that gating on command -v only caught the no-binary case. A host where rocminfo/amd-smi exist but don't enumerate the GPU still reached the KFD fallback and, with hipconfig/rocm-core present, got a generic rocm index. The guard now actually reads the gfx (rocminfo, then amd-smi list / static --asic -- the same probe the Strix reroute uses) and falls back to CPU whenever the arch is unreadable, not just when the binaries are missing. Verified by execution: a rocminfo that returns no gfx now routes to CPU, while the amd-smi fallback still resolves the arch.

  • setup.sh (versioned hipcc): the gate now also accepts /opt/rocm-*/bin/hipcc, matching the source-build detection at setup.sh:1663, so a HIP toolchain under a versioned prefix no longer gets dropped to the CPU prebuilt.

Tests updated to assert the gfx-read gate and the versioned hipcc path; test_rocm_support.py is green (347 passed) and both scripts pass bash -n.

@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: 1396ffc314

ℹ️ 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
Comment on lines +2218 to +2221
if [ -z "$_amd_gfx_probe" ]; then
echo "[WARN] AMD GPU detected but its gfx arch can't be read (rocminfo/amd-smi missing or not enumerating the GPU) -- installing CPU-only PyTorch." >&2
echo "[WARN] For GPU PyTorch, install or repair rocminfo/amd-smi (e.g. sudo pacman -S rocm-hip-sdk) and re-run this installer." >&2
echo "$_base/cpu"; return

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 ROCm gfx overrides before CPU fallback

On KFD-only AMD hosts where the ROCm version is still discoverable via hipconfig/rocm-core but rocminfo/amd-smi do not emit a gfx token, users can provide the missing arch with UNSLOTH_ROCM_GFX_ARCH (which studio/setup.sh already honors when no probe fired). This new guard ignores that override and returns the CPU index before ROCm version selection, so PyTorch stays CPU-only while setup may still pick a ROCm llama.cpp prebuilt from the same override; please seed the gfx probe from the override (and feed it into the Strix reroute) before falling back.

Useful? React with 👍 / 👎.

…7314

Seed both the gfx-unknown guard in get_torch_index_url and the Strix reroute
from UNSLOTH_ROCM_GFX_ARCH before probing rocminfo/amd-smi, so a host that
names its arch reaches the correct rocm index instead of being forced to CPU
(or to the generic wheels) when the runtime probes can't enumerate the GPU.
@danielhanchen

Copy link
Copy Markdown
Member

One more edge closed in ddb8843 from a fresh internal review pass: the Strix reroute re-probe guard used ${VAR:-}, so a SET-but-empty mask (ROCR_VISIBLE_DEVICES="") which also hides every agent skipped the unmasked re-probe and a Strix box would have kept the generic wheels. The guard now uses ${VAR+x} so any set mask (empty, -1, or out-of-range) triggers the re-probe when the masked probe saw nothing, while unset stays untouched. The mask-honouring shim test now covers the empty-string case alongside -1 and the partial mask.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: ddb8843b08

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

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: ddb8843b08

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

@danielhanchen

Copy link
Copy Markdown
Member

Found and fixed one more real defect in d0acfa9 via sandboxed end-to-end simulation of get_torch_index_url (every external tool shimmed, 19 scenarios x bash on Windows, bash and dash on Linux). The _rocm_tag fallback chain (amd-smi, /opt/rocm/.info/version, hipconfig, dpkg-query, rpm) fails as a WHOLE when every source is missing, and under set -euo pipefail a failing command-substitution assignment kills the installer silently, BEFORE the actionable "no ROCm version found" WARN this PR added. Concrete repro: rocminfo present (gfx readable) but rocm-core not installed, so dpkg-query and rpm exit nonzero. The chain now ends with an || guard so the empty tag reaches the WARN and the CPU fallback as designed. The hazard predates this PR, but this PR's messaging is what makes the path matter, so it belongs here. Added an executed regression test (shimmed failing tools under set -euo pipefail).

Simulation coverage for the PR overall: KFD topology detection against synthesized /sys trees (AMD GPU node, CPU-only vendor_id 0, NVIDIA vendor_id 4318, empty, garbage, tab-separated, no /dev/kfd) all correct on bash and dash; index selection over pins, mirrors, old and new gfx, ROCm 5.7 through 7.9 clipping, unreadable gfx with and without override, -1 and empty visibility masks, and aarch64, all as expected. Suite: 355 tests, bash -n clean.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 817c598ff2

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

@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: 950599e7bc

ℹ️ 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
LeoBorcherding and others added 2 commits July 22, 2026 21:19
The gfx-unknown CPU guard in get_torch_index_url fired before the
runtime-less reroute could run: with the KFD topology fix,
_has_amd_rocm_gpu is true on KFD-only hosts, so the reroute's
'! _has_amd_rocm_gpu' gate never let _infer_linux_amd_gfx_arch route
them to AMD per-arch wheels, regressing inferable boxes (PCI/cpuinfo/
lspci) from arch-specific PyTorch to CPU-only.

- Factor the override->rocminfo->amd-smi gfx probe (masks cleared)
  into _probe_amd_gfx_arch, shared by the guard and the reroute gate
  so the two can't disagree on what 'readable' means.
- Reroute gate now also fires when the GPU is detected but the probe
  is empty (KFD-only). Deliberate CPU fallbacks (old/unreadable ROCm
  version) all had a readable gfx and stay excluded.
- The guard defers to the reroute (no false 'installing CPU-only
  PyTorch' promise) only when inference yields a supported family;
  otherwise the actionable CPU warning is unchanged.

Executed tests: KFD-only host reroutes to repo.amd.com per-arch wheels
and exports UNSLOTH_ROCM_GFX_ARCH for setup.sh; readable-gfx CPU
fallback stays un-rerouted; undetected-GPU reroute unchanged; the
guard's three inference outcomes covered. Suite: 375 passed, bash -n
clean on both scripts.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Addressed the Codex P2 in fea4bc8. Real regression: the KFD fix makes _has_amd_rocm_gpu true on KFD-only hosts, so the reroute's ! _has_amd_rocm_gpu gate blocked _infer_linux_amd_gfx_arch for exactly the hosts that used to reach it, dropping inferable boxes (PCI/cpuinfo/lspci) from AMD per-arch wheels to CPU.

Fix: the gfx probe (override -> rocminfo -> amd-smi, masks cleared) moved into a shared _probe_amd_gfx_arch helper used by both the gfx-unknown guard and the reroute gate, and the gate now also fires when the GPU is detected but the probe reads no gfx. Deliberate CPU fallbacks (unsupported/unreadable ROCm version) always had a readable gfx and stay excluded. The guard defers to the reroute instead of printing the CPU-only warning when inference resolves a supported family; otherwise the actionable warning is unchanged.

Executed tests cover the KFD-only reroute to repo.amd.com per-arch wheels (with UNSLOTH_ROCM_GFX_ARCH exported for setup.sh), the untouched readable-gfx CPU fallback, and all three guard outcomes. Suite: 375 passed, bash -n clean.

@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: 6c9a1d6f36

ℹ️ 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
1. get_torch_index_url: with UNSLOTH_ROCM_GFX_ARCH set on a KFD-only
   host that has no ROCm version sources, the no-version endpoint
   printed 'falling back to CPU-only PyTorch' even though the reroute
   (gated on the override) then installs the per-arch wheels. When the
   override maps to a wheel family, defer with an accurate message;
   an unmappable override keeps the CPU warning since the reroute
   can't route it either.

2. Runtime-less reroute: the KFD-only branch reached the warning
   'ROCm runtime not visible (/dev/kfd, rocminfo, amd-smi)' although
   /dev/kfd is exactly what detected the GPU. The diagnostic now
   distinguishes KFD-visible/tooling-blind hosts from truly
   runtime-invisible ones.

Executed tests: supported override defers without the false CPU
warning, unsupported override and readable-gfx no-version hosts keep
it; KFD-only reroute emits the KFD wording, undetected-GPU reroute
keeps the original. Version sources are shimmed so the tests hold on
dev boxes with a real hipconfig. Suite: 376 passed, bash -n clean.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Both P3s addressed in 933ee4b. The override path: with UNSLOTH_ROCM_GFX_ARCH set on a KFD-only host with no version sources, the no-version endpoint printed "falling back to CPU-only PyTorch" while the reroute then installed the per-arch wheels; it now defers with an accurate message when the override maps to a wheel family, and keeps the CPU warning when it doesn't (the reroute can't map it either). The reroute diagnostic: KFD-only hosts no longer get "ROCm runtime not visible (/dev/kfd, ...)" since /dev/kfd is exactly what detected them; the message now distinguishes tooling-blind from runtime-invisible hosts.

Executed tests cover the three override outcomes and both diagnostic variants, with all ROCm version sources shimmed so they hold on dev boxes with a real hipconfig. Suite: 376 passed, bash -n clean.

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 314551bbdf

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

@danielhanchen
danielhanchen merged commit 430ada6 into unslothai:main Jul 23, 2026
48 of 52 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 430ada617a

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

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.

3 participants