Repository navigation
Studio installer (AMD, Linux): Vulkan llama.cpp for RDNA 1 and Polaris when ROCm is installed - #13694
Conversation
…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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… 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]>
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:
rocminfolists the card, sodetect_hostsetshas_rocm.has_amd_gpu_without_rocm, which gates the Linux Vulkan branch, is only probed whenhas_rocmis False.linux-rocmbundle. The current release (b11541-mix-2500203) maps only gfx103X, gfx110X, gfx1150/1151, gfx120X, gfx908 and gfx90a, so the plan is empty.setup.sh already names these cards and tells the user to
export UNSLOTH_LLAMA_CPP_BACKEND=vulkanand 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 persistsauto. It answers True only when all of these hold:has_rocm, and no physical NVIDIA card;LINUX_NO_ROCM_GFX_TARGETS(gfx1010,gfx1011,gfx1012,gfx803; the same set asinstall_python_stack._LINUX_UNCOVERED_AMD_GFXand setup.sh, with a parity test);HIP_VISIBLE_DEVICES,ROCR_VISIBLE_DEVICES,CUDA_VISIBLE_DEVICESorGGML_VK_VISIBLE_DEVICES(the same guards as the integrated-GPU preference);HSA_OVERRIDE_GFX_VERSION, which means the user runs the card on ROCm on purpose;Unchanged:
rocm/cpu/cudabackend, or--force-cpu.Tests
27 new cases in
test_install_resolve_prebuilt.py:[](the source-build path) to["linux-vulkan", "linux-cpu"].HSA_OVERRIDE_GFX_VERSION, a physical NVIDIA card, no ICD, and a Windows host;force_cpu;["linux-rocm"].