Repository navigation
Unsloth Studio (AMD/ROCm): warn about, and refuse, a GPU the installed PyTorch has no kernels for - #11571
Conversation
Two discrete AMD cards from different generations look identical in the GPU picker, but the ROCm torch wheel Studio installs carries kernels for one family only. Auto-selection has skipped the uncovered card since unslothai#8792; an explicit pick went straight to the worker, which died on its first tensor with hipErrorInvalidImage ("device kernel image is invalid"). prepare_gpu_selection now runs explicit ids through the same rocm_gpu_ids_without_torch_kernels() gate and raises the ValueError the route already turns into a 400, naming the card, its gfx target and the targets the wheel was built for. The backend-visible inventory stamps each physical row with `torch_kernels`, and the training picker shows "no kernels in this PyTorch build" on such a row and will not switch it on; a saved selection that already names it can still be switched off. Found with an RX 6500 XT (gfx1034) next to an RX 5700 XT (gfx1010) on gfx103X-all wheels. Vulkan rows carry no verdict: those ordinals are llama.cpp's, not torch's.
|
Confirmed that a manual pick in prepare_gpu_selection skips the check automatic selection already applies, so an unsupported second AMD card still gets offered. Will get this reviewed once it is out of draft. |
|
status for review: rebased on current main (has #11615). backend re-checked live on a per-branch Unsloth Studio with the stock gfx103X torch and both cards present: the inventory marks the RX 5700 XT torch_kernels false, a manual pick of it is refused with the message in the description, and the served frontend chunk carries the new label and field. what i have not done is click the greyed-out row in a running app, only read it out of the built bundle, so treat the frontend half as typechecked and bundled rather than clicked. with #11755 in, a box with the multi-arch torch never shows the label, which is the intended outcome. marking ready since the backend half is what changes behaviour. |
LeoBorcherding
left a comment
There was a problem hiding this comment.
Codex findings, via a mirror
Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#14. It looked at 90c4c9e918 there, which is this PR's b9e1ba54b replayed onto main 89ed32d6e. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.
2 findings, inline below where the line is on this diff.
| className="min-w-0 truncate text-ui-12 text-muted-foreground" | ||
| title={ | ||
| d.torchKernels === false | ||
| ? "The installed PyTorch build has no kernels for this card, so a job pinned to it fails on its first tensor. Reinstall Unsloth Studio for this card to use it." |
There was a problem hiding this comment.
P2 Base the GGUF picker on llama.cpp kernel coverage
This picker is rendered only through GgufAdvancedSettings for GGUF loads, so these IDs control llama.cpp rather than PyTorch. The llama backend determines ROCm compatibility independently from the binary's mapped_targets in _installed_llama_gfx_archs; therefore, when the PyTorch wheel omits an architecture that an installed/custom llama.cpp binary supports, this condition falsely labels and disables a usable GPU. Surface coverage for the runtime being configured instead of applying torch_kernels here.
Codex's original comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/14#discussion_r4093054264
| disabled={ | ||
| (isGpuChecked(d.index) && singleGpuInUse) || | ||
| (!isGpuChecked(d.index) && d.torchKernels === false) | ||
| } |
There was a problem hiding this comment.
P2 Prevent leaving a flagged GPU as the sole selection
When selectedGpuIds is null, every device is considered checked and singleGpuInUse is false on a multi-GPU host. With one supported and one flagged card, the user can therefore uncheck the supported card first, committing only the flagged ID; this condition then disables that remaining switch because it is the sole checked device. The resulting load is explicitly pinned to the very card this guard intends to prevent selecting, so the implicit selection must exclude flagged cards or removing the final supported card must be blocked.
Codex's original comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/14#discussion_r4093054273
The picker is only rendered for GGUF loads, which run on llama.cpp and never reach the torch kernel gate, so it greyed out cards llama.cpp can serve. Drop the lock, its label and the inventory stamping that only fed it; explicit torch loads are still refused in prepare_gpu_selection.
|
Review record for #11571, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#84. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1 — reviewed mirror
|
_describe_rocm_gpus read gcnArchName only, so on AMD SDK / Radeon wheels the message dropped the arch the gate had just judged. Share the gate's own attribute fallback so the label and the verdict read the same field.
…kernels for (unslothai#11571) An explicit gpu_ids pick of a ROCm card the installed PyTorch has no kernels for (for example an RX 5700 XT, gfx1010, beside an RX 6500 XT on the gfx103X wheels) went straight to the worker, which died on its first tensor with hipErrorInvalidImage. Auto-selection has skipped such cards since unslothai#8792; prepare_gpu_selection now runs explicit ids through the same gate and raises the ValueError the routes already return as a 400, naming the card, its arch and the arch list the wheel was built for. The gate is unchanged, so every case it fails open on (masked or remapped ordinals, unreadable arch, a build that covers no visible card) still fails open. GGUF and diffusion loads do not go through this path and are unaffected. Fixes unslothai#11569.
fixes #11569
The problem in plain words
On AMD, PyTorch ships its GPU code ("kernels") pre-compiled per card family, and the Unsloth Studio installer picks one family from the card it sees at install time. If a second AMD card from another generation is in the box, the installed PyTorch has no code for it. Unsloth Studio still lists that card like any other ROCm GPU and lets you pick it for training, and the job then dies on its first operation.
This came from an RX 6500 XT (RDNA2,
gfx1034) next to an RX 5700 XT (RDNA1,gfx1010) on thegfx103X-allwheels:Automatic selection is already safe:
rocm_gpu_ids_without_torch_kernels()has dropped such cards since #8792. The manual path never asked it. And with 8 GB free on the 5700 XT against a nearly full 6500 XT, the manual pick is the natural one.What this PR does
Refuses the pick with a real message.
prepare_gpu_selection()runs explicit ids through the same gate and raises theValueErrorthe route already turns into a 400:Tells the UI.
get_backend_visible_gpu_info()stamps each physical GPU row withtorch_kernels: true|false. Vulkan rows get no verdict, those ordinals belong to llama.cpp, not PyTorch.Shows it in the GPU picker. That is the GPUs list in a model's load settings (the panel with GPU Layers; training itself has no picker and always uses automatic selection, which already skips such cards). There the card reads
GPU 1: AMD Radeon RX 5700 XT · 8 GiB · no kernels in this PyTorch build, the tooltip explains it, and the switch will not turn on. If a saved selection already named the card before the wheels changed, it can still be switched off.The gate itself is unchanged, so everything it fails open on (a remapped ordinal space, an unreadable arch, a build that covers nothing) still fails open here. No card is newly hidden; only a card auto-selection already refuses is now refused when picked by hand, with an explanation.
Not in this PR
setup.ps1picks the wheel family from the first enumerated card and only prints a warning when that card is an integrated GPU (Resolve-ShadowingGfxPick). Two discrete cards from different families get no message, so the install log never says the second card is not covered. That is a separate change and is listed in #11569.Tests
New
TestExplicitPickWithoutTorchKernelsintests/test_gpu_selection.py: an uncovered manual pick is rejected with the card and the arch list in the message, a covered pick next to an uncovered card is accepted, a host where everything is covered is untouched, inventory rows carry the flag and Vulkan rows do not, an empty inventory never calls the gate.tests/test_gpu_selection.py+test_gpu_selection_sandbox.pyon this Windows ROCm PC: 114 passed, 10 failed, and the same 10 fail on untouchedmainhere (they assume a mocked host and this one has two real ROCm cards). Frontend:tsc -bshows no errors in the four touched files (the remaining errors are missing optional modules in a borrowednode_modules), eslint is clean on the three hooks, and the pre-existing findings inmodel-config-page.tsxare all outside the changed lines.Run against the real two-card PC with the patched backend on the path:
The picker label is typechecked and present in the served bundle of a branch build, but not yet clicked through in the running app, hence the draft.
Status
Rebased on current main (includes #11615). Backend behaviour re-checked live on a per-branch Unsloth Studio (stock gfx103X torch, both cards present):
get_backend_visible_gpu_info()marks the RX 5700 XTtorch_kernels: false,reject_gpu_ids_without_torch_kernels([1])raises the message quoted above, and the served frontend chunk carries the label and thetorchKernelsfield. Once #11755 lands and a box has the multi-arch torch, both cards are covered and this PR's label never appears there, which is the intended outcome: it only speaks up for a card the installed build genuinely cannot run.