Skip to content

Studio installer (AMD, Linux): Vulkan llama.cpp for RDNA 1 and Polaris when ROCm is installed - #13694

Merged
danielhanchen merged 2 commits into
mainfrom
r6/linux-amd-no-rocm-vulkan-llama
Oct 14, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
r6/linux-amd-no-rocm-vulkan-llama

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

On Linux, an AMD card from a generation that ROCm does not support (RDNA 1: RX 5500 / 5600 / 5700, gfx1010/1011/1012; Polaris: RX 470-590, gfx803) never gets the Vulkan llama.cpp build when ROCm userspace is installed:

  • rocminfo lists the card, so detect_host sets has_rocm. has_amd_gpu_without_rocm, which gates the Linux Vulkan branch, is only probed when has_rocm is False.
  • The Linux ROCm branch then looks for a linux-rocm bundle. The current release (b11541-mix-2500203) maps only gfx103X, gfx110X, gfx1150/1151, gfx120X, gfx908 and gfx90a, so the plan is empty.
  • setup then runs a HIP source build. These archs have no rocBLAS kernels, so the result cannot run on the card. Without hipcc, it is a CPU build ("ROCm driver found but hipcc missing").

setup.sh already names these cards and tells the user to export UNSLOTH_LLAMA_CPP_BACKEND=vulkan and reinstall. Windows does this automatically (#7373, _should_auto_vulkan_for_amd_windows), and Ollama does the same: it drops ROCm devices with no rocBLAS kernels and keeps the Vulkan entry for that card.

Fix

_should_auto_vulkan_for_amd_linux(host) is ORed into the existing Windows no-HIP route in _route_to_vulkan_prebuilt, so the host is rewritten as Vulkan-only and the marker persists auto. It answers True only when all of these hold:

  • Linux, has_rocm, and no physical NVIDIA card;
  • every physical AMD gfx is in LINUX_NO_ROCM_GFX_TARGETS (gfx1010, gfx1011, gfx1012, gfx803; the same set as install_python_stack._LINUX_UNCOVERED_AMD_GFX and setup.sh, with a parity test);
  • no HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES, CUDA_VISIBLE_DEVICES or GGML_VK_VISIBLE_DEVICES (the same guards as the integrated-GPU preference);
  • no HSA_OVERRIDE_GFX_VERSION, which means the user runs the card on ROCm on purpose;
  • an AMD Vulkan ICD is present, so a box without RADV keeps today's path.

Unchanged:

  • A mixed host where any AMD card has ROCm kernels (for example gfx1010 + gfx1100).
  • An explicit rocm / cpu / cuda backend, or --force-cpu.
  • Windows and macOS.

Tests

27 new cases in test_install_resolve_prebuilt.py:

  • Routed to Vulkan: gfx1010, gfx1011, gfx1012, gfx803 and gfx1010 + gfx803. At plan level, against a bundle shaped like the real release, gfx1010 goes from [] (the source-build path) to ["linux-vulkan", "linux-cpu"].
  • Unchanged:
    • gfx1010 + gfx1100, gfx1100, gfx1030, gfx906 and gfx1151;
    • each mask variable and HSA_OVERRIDE_GFX_VERSION, a physical NVIDIA card, no ICD, and a Windows host;
    • explicit rocm / cpu / cuda and force_cpu;
    • gfx1030 keeps ["linux-rocm"].
  • Run base vs this branch: the 13 related installer test files give 2245 passed on the merge base and 2272 passed here, with no failures on either side. The new test file against the merge-base code gives 22 failed / 5 passed; the 5 are the cases that never reach the new helper.

…s when ROCm is installed

With ROCm userspace present, rocminfo sets has_rocm and the Linux ROCm branch finds no
linux-rocm bundle for gfx1010/1011/1012 or gfx803, so setup source-builds HIP (no rocBLAS
kernels for these archs) or, without hipcc, a CPU build. Route these hosts to the Vulkan
prebuilt, as Windows already does (#7357), behind the same guards as the integrated-GPU
preference: no physical NVIDIA, no HIP/ROCR/CUDA or GGML_VK mask, no
HSA_OVERRIDE_GFX_VERSION, every physical gfx uncovered, and an AMD Vulkan ICD present.
An explicit backend still wins.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review 🔄 Running since 2026-10-14T08:55:49.134956Z efc5e55 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T09:00:52.110267Z efc5e55 Manual request
🔒 Security Review ⚠️ Failed 2026-10-14T08:55:52.312068Z efc5e55 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: efc5e55586

ℹ️ 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 8e052d7 into main Oct 14, 2026
@danielhanchen
danielhanchen deleted the r6/linux-amd-no-rocm-vulkan-llama branch October 14, 2026 15:22
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 25, 2026
… kernel-less ROCm wheels (unslothai#15002)

On Linux, a host whose only AMD GPU is gfx90c (the integrated Vega in
Ryzen 4000/5000 APUs: Renoir, Cezanne, Lucienne, Barcelo, e.g. the
5700G) got the generic ROCm PyTorch wheel. With ROCm 7.2 installed,
rocminfo reads `gfx90c`, and `get_torch_index_url` picked
`https://download.pytorch.org/whl/rocm7.2`. Those wheels carry no gfx90c
kernels and ROCm does not support the arch, so the user gets a multi-GB
torch that cannot use the GPU.

gfx90c was only in the mixed-host iGPU table (unslothai#7776). The readable-arch
"no ROCm PyTorch wheels" filter added for RDNA 1 and Polaris (unslothai#8529,
unslothai#13419) did not list it, so a lone gfx90c fell through to the generic
tag.

### Fix
- gfx90c joins the Linux uncovered set everywhere it is mirrored:
`install.sh` (index pick and install summary), `studio/setup.sh`,
`install_python_stack._LINUX_UNCOVERED_AMD_GFX`, and the backend's copy
in `hardware.py`. A lone gfx90c now gets CPU torch and the existing hint
to re-run with `UNSLOTH_LLAMA_CPP_BACKEND=vulkan`.
- llama.cpp: no linux-rocm bundle covers gfx90c either, so
`LINUX_NO_ROCM_GFX_TARGETS` gains it. A lone gfx90c with an AMD Vulkan
driver now gets the Vulkan prebuilt instead of a HIP source build
(unslothai#13694).
- Unchanged: gfx90c beside a supported discrete card (unslothai#7776) still
installs ROCm torch for the discrete card.
`HSA_OVERRIDE_GFX_VERSION=9.0.0` is judged as gfx900 and keeps ROCm.
Windows already sends gfx90c to CPU, because its routing is an
allowlist.
- No TheRock opt-in line for gfx90c: TheRock rates it build-passing
only, and current torch on its multi-arch index declares no
`device-gfx90c` extra.

### Testing
MacBook Pro M5 (macOS), with stubbed probes and no AMD hardware.
- New `tests/studio/install/test_linux_gfx90c_cpu_torch.py` runs the
real `_probe_amd_gfx_arch` against a fake `rocminfo` on PATH. On base it
returns `rocm7.2` for a lone gfx90c; with the fix it returns `/cpu` with
the Vulkan hint. The mixed gfx90c + gfx1100 host and the gfx900 spoof
keep `rocm7.2` on both.
- New and updated install tests: 9 fail on base, all pass with the fix.
At `092e6df` (main merged): 503 passed, 1 skipped across the new tests,
the unslothai#8529 suite and
`studio/backend/tests/test_install_resolve_prebuilt.py`.

### Not tested
A real gfx90c Linux box: real rocminfo output on ROCm 7.2, the CPU-torch
install end to end, llama.cpp picking the Vulkan prebuilt with RADV, and
a real gfx90c + discrete host.

Reported in a Discord help thread.


### Follow-up commits
- The torch 2.11 ROCm wheels this installer picks ship gfx900 kernels
(pytorch `release/2.11` `.ci/docker/manywheel/build.sh`), which a gfx90c
runs under `HSA_OVERRIDE_GFX_VERSION=9.0.0`. The CPU warnings in
`install.sh` (index pick and summary), `studio/setup.sh` and
`install_python_stack.py` now say so for a lone gfx90c, so that route
stays discoverable.
- Re-running `install.sh` recreates the venv and carries only the torch
release across (`torch==2.11.0`, not `+rocm7.2`), so a gfx90c user who
already ran ROCm torch with the override would have been moved to CPU
torch on update. A lone gfx90c whose previous environment ran a `+rocm`
torch now keeps ROCm, with a note to start Studio with the override.
Fresh installs still get CPU torch. `unsloth studio update`, `setup.sh`
and `install_python_stack.py` already keep an existing ROCm build.
- Main merged in.

Tests: `tests/studio/install/test_linux_gfx90c_cpu_torch.py` gains the
hint cases (gfx90c only, not gfx1010 / gfx803) and the rerun cases (an
existing ROCm build keeps ROCm; a CPU or unknown previous torch still
takes CPU; other uncovered arches are not kept). Base vs head: 16 tests
fail on main and pass here, none fail here. The 21 test files touching
the changed lists show the same 3 failures on main and on this branch
(`test_rocm_torch_explicit_request.py`). Staging: ubuntu and macOS
green; the Windows leg fails only in
`test_the_icd_search_dirs_follow_the_xdg_variables`, which fails on main
too and is not touched here.

Related: unslothai#9430 (gfx90c on Fedora, ROCm torch, inference worker SIGSEGV).

---------

Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <[email protected]>
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.

1 participant