Skip to content

AMD RDNA1: turn Triton's buffer ops off on gfx101x before Triton loads - #11615

Merged
danielhanchen merged 10 commits into
unslothai:mainfrom
LeoBorcherding:fix/rdna1-triton-buffer-ops
Sep 23, 2026
Merged

danielhanchen merged 10 commits into
unslothai:mainfrom
LeoBorcherding:fix/rdna1-triton-buffer-ops

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #11614 (training on AMD RDNA1).

The problem in plain words

On RDNA1 cards (RX 5700 XT, 5600 XT, 5500 XT, gfx101x) every Triton kernel Unsloth uses launches successfully and does nothing. No error, no crash: the output tensors are simply never written. A training run "works" and learns garbage.

The cause is in Triton's AMD backend: by default it emits buffer_load / buffer_store with a buffer resource descriptor laid out for gfx10.3 and newer, and gfx10.1 reads that descriptor differently, so the accesses go nowhere. Triton has a knob for it, AMDGCN_USE_BUFFER_OPS=0, which switches the same kernels to global loads and stores. Those are correct on RDNA1.

Ten-line repro on an RX 5700 XT (torch 2.12.0+rocm10.2 from AMD's multi-arch index, triton-windows 3.8.0.post28):

import torch, triton, triton.language as tl
@triton.jit
def k(x_ptr, y_ptr, n, BLOCK: tl.constexpr):
    offs = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK); m = offs < n
    tl.store(y_ptr + offs, tl.load(x_ptr + offs, mask = m) * 2, mask = m)
x = torch.arange(1024, device = "cuda", dtype = torch.float32); y = torch.full_like(x, -1)
k[(4,)](x, y, 1024, BLOCK = 256); torch.cuda.synchronize()
print((y == x * 2).sum().item(), "of 1024 correct")
default:                   0 of 1024 correct   (every value still -1, every BLOCK / num_warps tried)
AMDGCN_USE_BUFFER_OPS=0:   1024 of 1024 correct
RX 6500 XT (gfx1034):      1024 of 1024 correct either way

The second half: the knob is not in the compile caches

Triton reads AMDGCN_USE_BUFFER_OPS when it compiles a kernel but does not fold it into the kernel cache key, and Inductor stores the Triton kernels it generates for torch.compile in its own cache (TORCHINDUCTOR_CACHE_DIR) keyed the same blind way. So a kernel compiled once with buffer ops on is reused verbatim after they are turned off. On the box that looked like this:

Qwen3-1.7B 16-bit LoRA on the RX 5700 XT losses
buffer ops on nan nan nan, grad_norm nan from step 1
buffer ops off, caches populated by the run above -inf nan nan
buffer ops off, empty Triton cache, Inductor cache untouched 0.0207428001 0.0207428001 0.0191634577
buffer ops off, empty Triton and Inductor caches 0.0207 0.0207 0.0191
gemma-3-270m 16-bit LoRA on the RX 5700 XT losses
buffer ops on nan at every step
buffer ops off, Triton cache clean, Inductor cache populated by the run above nan at every step
buffer ops off, both caches clean 0.0591 0.0591 0.0548 0.0505 0.0496 0.0487 (finite; the compiled-module curve tracked in #11614)

Setting the knob alone would therefore fix a fresh machine and leave every machine that ever ran without it broken.

What this PR does

  • device_type.arch_lacks_buffer_ops() names the gfx10.1 family (gfx1010, gfx1011, gfx1012, gfx1013). It sits next to arch_lacks_bf16() and the two deliberately disagree on RDNA2: all of gfx10 lacks bf16, only gfx10.1 mishandles the descriptor, so RDNA2 keeps buffer ops.
  • device_type.apply_gfx101x_triton_workaround() sets AMDGCN_USE_BUFFER_OPS=0 and, unless the user chose otherwise, points TRITON_CACHE_DIR at <TRITON_HOME>/cache-no-buffer-ops and TORCHINDUCTOR_CACHE_DIR at <tmp>/torchinductor_<user>_no_buffer_ops, so kernels built with and without buffer ops never share a cache. Everything is setdefault: an explicit user value for any of the three is kept.
  • _gpu_init calls it when such a GPU is visible, before import triton. Triton reads the knob when it compiles a kernel, so this is early enough.

Verified only on gfx1010; the descriptor layout is per ISA generation, which is why the whole gfx101x family is covered rather than one device id.

Tests

tests/test_rdna1_triton_buffer_ops.py, 19 decision-table checks with no GPU needed: gfx101x in all its spellings matches, RDNA2 / RDNA3 / RDNA4 / CDNA do not, an unreadable arch fails open, the bf16 gate and this gate give different answers on RDNA2 so a refactor cannot merge them by accident, the workaround sets the knob and both cache directories, follows TRITON_HOME, and never overrides a value the user set.

On the real box, importing this branch's unsloth with only the 5700 XT visible sets the variable; with only the 6500 XT visible it is left unset.

What this does not fix

RDNA1 also has no dot instructions, so anything with a Triton tl.dot in fp16 still aborts the process in LLVM. That is the fla kernels, i.e. every gated-delta model such as Qwen3.5, and is handled on the zoo side in unslothai/unsloth-zoo#1356. With both in, plus unslothai/unsloth-zoo#1316 for the offload dtype, Qwen3-1.7B and Qwen3.5-0.8B train on an RX 5700 XT.

On gfx10.1 (RX 5700 XT and the rest of RDNA1) Triton's AMD backend
builds buffer resource descriptors in the gfx10.3+ layout, and every
kernel it emits with buffer_load/buffer_store launches with hipSuccess
and touches no memory. A ten-line x * 2 kernel returned 0 of 1024
correct values; unsloth's fused kernels do the same, so a training run
"works" and learns nothing real. With AMDGCN_USE_BUFFER_OPS=0 the same
kernels use global loads and stores and are correct.

arch_lacks_buffer_ops() names the gfx101x family, and _gpu_init sets the
knob (setdefault, so an explicit user value wins) when such a GPU is
visible, ahead of `import triton`, which is when Triton starts reading
it. RDNA2 keeps buffer ops: measured correct on gfx1034, and the two
gates (bf16 is all of gfx10, this is gfx10.1 only) stay separate.

Verified on the box with both cards: importing with only the 5700 XT
visible sets the variable, with only the 6500 XT visible it is left
alone.
LeoBorcherding and others added 4 commits September 22, 2026 18:46
…e cache key

Triton reads AMDGCN_USE_BUFFER_OPS at compile time but does not fold it
into the kernel cache key, so a kernel compiled with buffer ops on is
reused verbatim once they are off. On the RX 5700 XT that turned a run
that trains cleanly with an empty cache (0.02074 0.02074 0.01916) into
`loss -inf` then `nan` as soon as an earlier process had populated
~/.triton/cache with buffer-op kernels.

apply_gfx101x_triton_workaround() now sets the knob and, unless the user
chose a cache directory, points TRITON_CACHE_DIR at a sibling
`cache-no-buffer-ops` under TRITON_HOME (default ~/.triton), so the two
builds never share a cache. An explicit user value for either variable is
left alone.
torch.compile stores the Triton kernels it generates under
TORCHINDUCTOR_CACHE_DIR and keys them without the buffer-ops knob, like
Triton's own cache. gemma-3-270m on the RX 5700 XT went nan on every step
with buffer ops off once a buffer-ops-on run had filled that directory.
The workaround now gives Inductor a sibling directory too, setdefault.
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the gate in device_type.py matches only gfx101x and sets the knob and separate Triton and Inductor cache dirs before Triton loads, which addresses the silent no-write kernels on RDNA1. Could you update the description to mention the cache-dir redirect as well, since it currently only describes the env var?

@danielhanchen danielhanchen self-assigned this Sep 23, 2026
The Inductor redirect never reached torch.compile on a real `import unsloth`:

- `import torch._dynamo` already wrote Inductor's default cache dir into
  os.environ before _gpu_init, so the setdefault skipped it. A value equal
  to torch's default is now treated as unset.
- unsloth_zoo's patch_torch_compile pops TORCHINDUCTOR_CACHE_DIR afterwards.
  models/_utils.py re-applies the workaround right after that call.

Also:

- A user who already exported AMDGCN_USE_BUFFER_OPS=0 (the manual workaround
  from unslothai#11614) now gets the separate caches too; only a value Triton reads as
  on is left alone.
- getpass.getuser() is guarded like torch does, so a container uid without a
  passwd entry cannot break the import.
- TRITON_CACHE_DIR follows Triton's <TRITON_HOME>/.triton layout.
- Comments corrected: current Triton does key its own cache on the knob and is
  already imported by this point; it reads the knob lazily.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 23, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 23, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 23, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #11615, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#70.

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 bb14cd77ae (this PR's bee711450)

chatgpt-codex-connector[bot] (on the mirror)

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

Reviewed commit: bb14cd77ae

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror bb14cd77ae (this PR's bee711450).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen marked this pull request as ready for review September 23, 2026 11:22
@danielhanchen
danielhanchen self-requested a review as a code owner September 23, 2026 11:22
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@danielhanchen
danielhanchen merged commit 41c0d44 into unslothai:main Sep 23, 2026
39 of 40 checks passed
randomkebab pushed a commit to randomkebab/unsloth that referenced this pull request Sep 23, 2026
…e_type (unslothai#11688)

* Give the ROCm bf16 chain test every name _gpu_init imports from device_type

unslothai#11615 added the RDNA1 buffer-op workaround inside the _gpu_init.py block
this test execs, and it calls arch_lacks_buffer_ops, which the test's
hand-built namespace did not have: every hip case failed with a NameError
on main. The namespace is now read from _gpu_init's own
`from .device_type import (...)`, so the next name arrives by itself.

apply_gfx101x_triton_workaround is recorded rather than run, since the real
one writes Triton and Inductor settings into os.environ, and a new test
covers unslothai#11615's gate: gfx101x only, RDNA2 excluded, off hip nothing.

* Give the conftest device_type stub unslothai#11615's names, and pin it to _gpu_init's imports
LeoBorcherding added a commit to LeoBorcherding/unsloth that referenced this pull request Sep 24, 2026
…e nightly

repo.amd.com/rocm/whl-multi-arch publishes the same per-device packaging as the
nightly, on release tags: torch 2.11.0+rocm7.14.1 with the gfx1010/1011/1012 device
packs, torchvision 0.26.0 and torchaudio 2.11.0 on the same tag. Measured on an
RX 5700 XT: resolves in one go, fp16 matmul correct, Triton unchanged (buffer ops
still need unslothai#11615), and the 3-step LoRA/QLoRA rows on Qwen3.5-0.8B and Qwen3-1.7B
match the nightly to the fourth decimal.

So the route pins that release instead of a nightly date: the index also serves
2.12.0, which sits on the <2.12.0 window the rest of the Windows install applies,
so 2.11.0 is the newest release inside it. torchaudio goes back into the trio and
the empty-audio-slot handling ($RocmNoAudio, the trio filter) goes away.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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#12. It looked at e2320b86d9 there, which is this PR's bee711450 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.

Codex found no major issues. Its comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/12#issuecomment-5813113325

vivekvar-dl added a commit to vivekvar-dl/unsloth that referenced this pull request Sep 25, 2026
Resolve the conflict with unslothai#11615: main added arch_lacks_buffer_ops and
apply_gfx101x_triton_workaround to the .device_type import, which this
branch had moved into the NotImplementedError handler. Import all four
names inside the handler and keep the del after it.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
unslothai#11615)

* AMD RDNA1: turn Triton's buffer ops off on gfx101x before Triton loads

On gfx10.1 (RX 5700 XT and the rest of RDNA1) Triton's AMD backend
builds buffer resource descriptors in the gfx10.3+ layout, and every
kernel it emits with buffer_load/buffer_store launches with hipSuccess
and touches no memory. A ten-line x * 2 kernel returned 0 of 1024
correct values; unsloth's fused kernels do the same, so a training run
"works" and learns nothing real. With AMDGCN_USE_BUFFER_OPS=0 the same
kernels use global loads and stores and are correct.

arch_lacks_buffer_ops() names the gfx101x family, and _gpu_init sets the
knob (setdefault, so an explicit user value wins) when such a GPU is
visible, ahead of `import triton`, which is when Triton starts reading
it. RDNA2 keeps buffer ops: measured correct on gfx1034, and the two
gates (bf16 is all of gfx10, this is gfx10.1 only) stay separate.

Verified on the box with both cards: importing with only the 5700 XT
visible sets the variable, with only the 6500 XT visible it is left
alone.

* Keep the gfx101x Triton cache apart: the buffer-ops knob is not in the cache key

Triton reads AMDGCN_USE_BUFFER_OPS at compile time but does not fold it
into the kernel cache key, so a kernel compiled with buffer ops on is
reused verbatim once they are off. On the RX 5700 XT that turned a run
that trains cleanly with an empty cache (0.02074 0.02074 0.01916) into
`loss -inf` then `nan` as soon as an earlier process had populated
~/.triton/cache with buffer-op kernels.

apply_gfx101x_triton_workaround() now sets the knob and, unless the user
chose a cache directory, points TRITON_CACHE_DIR at a sibling
`cache-no-buffer-ops` under TRITON_HOME (default ~/.triton), so the two
builds never share a cache. An explicit user value for either variable is
left alone.

* Wrap two long lines for the formatter

* Also keep Inductor's compiled-kernel cache apart on gfx101x

torch.compile stores the Triton kernels it generates under
TORCHINDUCTOR_CACHE_DIR and keys them without the buffer-ops knob, like
Triton's own cache. gemma-3-270m on the RX 5700 XT went nan on every step
with buffer ops off once a buffer-ops-on run had filled that directory.
The workaround now gives Inductor a sibling directory too, setdefault.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* gfx101x: make the separate Inductor cache actually take effect

The Inductor redirect never reached torch.compile on a real `import unsloth`:

- `import torch._dynamo` already wrote Inductor's default cache dir into
  os.environ before _gpu_init, so the setdefault skipped it. A value equal
  to torch's default is now treated as unset.
- unsloth_zoo's patch_torch_compile pops TORCHINDUCTOR_CACHE_DIR afterwards.
  models/_utils.py re-applies the workaround right after that call.

Also:

- A user who already exported AMDGCN_USE_BUFFER_OPS=0 (the manual workaround
  from unslothai#11614) now gets the separate caches too; only a value Triton reads as
  on is left alone.
- getpass.getuser() is guarded like torch does, so a container uid without a
  passwd entry cannot break the import.
- TRITON_CACHE_DIR follows Triton's <TRITON_HOME>/.triton layout.
- Comments corrected: current Triton does key its own cache on the knob and is
  already imported by this point; it reads the knob lazily.

* Trim comments on the gfx101x Triton workaround

* Use the repo's AGPL-3.0 header on the new test

* Match the SPDX header the other tests use

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han-Chen <[email protected]>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…e_type (unslothai#11688)

* Give the ROCm bf16 chain test every name _gpu_init imports from device_type

unslothai#11615 added the RDNA1 buffer-op workaround inside the _gpu_init.py block
this test execs, and it calls arch_lacks_buffer_ops, which the test's
hand-built namespace did not have: every hip case failed with a NameError
on main. The namespace is now read from _gpu_init's own
`from .device_type import (...)`, so the next name arrives by itself.

apply_gfx101x_triton_workaround is recorded rather than run, since the real
one writes Triton and Inductor settings into os.environ, and a new test
covers unslothai#11615's gate: gfx101x only, RDNA2 excluded, off hip nothing.

* Give the conftest device_type stub unslothai#11615's names, and pin it to _gpu_init's imports
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 29, 2026
…700 XT from AMD's multi-arch index (unslothai#11755)

* Windows installers: route RDNA 1 (gfx1010/1011/1012) to AMD's multi-arch nightly index

RDNA 1 has no family on repo.amd.com, so every Windows installer put an RX 5700 XT
on CPU torch and said so (unslothai#8529). AMD's multi-arch nightly index carries per-card
kernel packs for it: `torch[device-gfx1010]` resolves torch plus the gfx1010 pack.
With that torch, unslothai#11615 and the zoo's #1356 / #1316, the card trains (unslothai#11614).

install_python_stack.py, install.ps1 and setup.ps1 now route gfx1010 / gfx1011 /
gfx1012 to that index, pinned to one tag (a nightly moves), with torchvision on
the same tag and no torchaudio (none is published for it). The three RDNA 1 rows
move from the "not covered" name tables to the routed ones on the Windows copies;
the backend's copy follows. Linux is unchanged: nothing has run that route on
bare-metal Linux, and WSL2's GPU driver refuses RDNA 1 outright.

Tests: the unslothai#8529 suites now exercise the "not covered" wording with Polaris (RX
580, gfx803), which still owns it everywhere; the routing guards keep RDNA 1
banned on Linux and assert the Windows route; the parity test accepts a
multi-arch device as routable on the Windows copies only; a new file pins the
package specs, the index, the name tables and the PowerShell mirrors.

* Expect the RX 5700 XT to resolve in the Windows name tables now that it routes

* Drop a torchaudio built against another torch after the multi-arch install

The multi-arch index publishes no torchaudio, so the one left by an earlier CPU
or per-family pass is linked against a torch that is gone and throws a Windows
"Entry Point Not Found" dialog when anything imports it. Seen on the first fresh
install from this branch: torch 2.12.0+rocm10.2 next to torchaudio
2.11.0+rocm7.13. Remove it after the multi-arch pass; a torchaudio carrying the
pinned tag, should AMD publish one, stays.

* Pin that a lone RDNA 1 host takes the Vulkan llama.cpp route

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Run the stale-torchaudio cleanup on every path that ends with the multi-arch torch

setup.ps1 and install.ps1 install the pair themselves and set the marker that
makes the python repair return early, so the cleanup there never ran on a
fresh install (seen: torchaudio 2.11.0+rocm7.13.0 still present after the
multi-arch pass). Do it in the two PowerShell installers right after their
trio lands, and in the python marker shortcut when the installed torch carries
the multi-arch tag.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Give the Windows final step the last word on torchaudio in a multi-arch venv

The dependency pass re-resolves torchaudio 2.11.0 on every run: torch-stoi and
descript-audiotools require it unconditionally and nothing exists for the pinned
torch (AMD's index lists no torchaudio for the tag, PyPI stops at 2.11.0). The
cleanups that run right after the trio install therefore lose to step 8. Run it
once more at the end of the Windows flow, after every with-deps step.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Stop removing torchaudio: 2.11 works beside the multi-arch torch 2.12

Measured on the RX 5700 XT venv the installer built: torchaudio 2.11.0 next to
torch 2.12.0+rocm10.2 imports, resamples, computes a mel spectrogram and loads
torch-stoi, with no dialog. The dependency pass installs it (torch-stoi and
descript-audiotools require it; PyPI stops at 2.11.0 and AMD's index has none),
and taking it out again only lost audio features. The pinned trio still lists no
torchaudio, which is what the index needs; the rest is left to the resolver.

* RDNA 1 on Windows: install from AMD's stable multi-arch index, not the nightly

repo.amd.com/rocm/whl-multi-arch publishes the same per-device packaging as the
nightly, on release tags: torch 2.11.0+rocm7.14.1 with the gfx1010/1011/1012 device
packs, torchvision 0.26.0 and torchaudio 2.11.0 on the same tag. Measured on an
RX 5700 XT: resolves in one go, fp16 matmul correct, Triton unchanged (buffer ops
still need unslothai#11615), and the 3-step LoRA/QLoRA rows on Qwen3.5-0.8B and Qwen3-1.7B
match the nightly to the fourth decimal.

So the route pins that release instead of a nightly date: the index also serves
2.12.0, which sits on the <2.12.0 window the rest of the Windows install applies,
so 2.11.0 is the newest release inside it. torchaudio goes back into the trio and
the empty-audio-slot handling ($RocmNoAudio, the trio filter) goes away.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Windows AMD trio: pass the three specs plainly again, and anchor the repair tests on the helper

torchaudio is back in the multi-arch trio, so the empty-slot filter on install.ps1's
three ROCm trio commands has nothing to filter; the plain form is what the pr5940
follow-up tests read. The two cuda_repair tests looked for the inline
_WINDOWS_ROCM_TORCH_PKG_SPECS.get in _ensure_rocm_torch, which now calls
_windows_rocm_torch_pkg_specs; they anchor on that call.

* Windows repair site: do not call _bare_gfx() where the function shadows it

_ensure_rocm_torch binds a local named _bare_gfx further down, so the multi-arch
message calling the module helper raised UnboundLocalError on the Windows repair
path for a gfx1010 host with a CPU torch. Inline the bare-arch spelling there and
run that site in a test.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* RDNA 1 route: count it as covered in the two gates outside the route, and move the
wheel-less fixtures to Polaris

The backend's repairability check and setup.ps1's pre-Intel "AMD gets GPU wheels" gate
both read a list that still omitted gfx1010-1012, so a 5700 XT on Windows could not
establish a torch mismatch and lost to an Intel Arc on a mixed host. The backend gains
a Windows-only extension of the supported set (Linux still declines RDNA 1); setup.ps1's
list gains the three arches.

Tests that used the RX 5700 XT / gfx1010 as the card with no Windows wheels move to
Polaris (RX 580 / gfx803); the Linux-only parity tests learn that RDNA 1 names are
unsupported on the Linux copies and routed on the Windows copies.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Trim comments in RDNA 1 multi-arch route

* Drop RDNA 1 from comments that still call it unroutable on Windows

* RDNA 1 route: follow unslothai#11834's gfx1034 specs, strip HIP suffixes from the gfx override, reinstall a per-family build on a now-RDNA 1 host

- test_other_arches_keep_their_specs compares gfx1034 against _WINDOWS_ROCM_TORCH_PKG_SPECS; unslothai#11834 pinned the gfx103X family, so bare names no longer apply.
- setup.ps1 and install.ps1 drop a ":xnack-" style suffix from UNSLOTH_ROCM_GFX_ARCH before routing, as the Python resolver already does.
- A standalone studio update on a venv holding a per-family ROCm torch reinstalls from the multi-arch index when the card is RDNA 1 and its amd-torch-device pack is missing.

* Pin the RDNA 1 repair and override fixes with tests, fix the gfx1034 spec test

The gfx1034 update described in b3efb0c was not in that commit; the test still
expected bare package names that main no longer returns.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Trim comments on the RDNA 1 multi-arch route

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <[email protected]>
danielhanchen added a commit that referenced this pull request Sep 29, 2026
…o 9000 cards from AMD's multi-arch index (#11846)

* Windows installers: route RDNA 1 (gfx1010/1011/1012) to AMD's multi-arch nightly index

RDNA 1 has no family on repo.amd.com, so every Windows installer put an RX 5700 XT
on CPU torch and said so (#8529). AMD's multi-arch nightly index carries per-card
kernel packs for it: `torch[device-gfx1010]` resolves torch plus the gfx1010 pack.
With that torch, #11615 and the zoo's #1356 / #1316, the card trains (#11614).

install_python_stack.py, install.ps1 and setup.ps1 now route gfx1010 / gfx1011 /
gfx1012 to that index, pinned to one tag (a nightly moves), with torchvision on
the same tag and no torchaudio (none is published for it). The three RDNA 1 rows
move from the "not covered" name tables to the routed ones on the Windows copies;
the backend's copy follows. Linux is unchanged: nothing has run that route on
bare-metal Linux, and WSL2's GPU driver refuses RDNA 1 outright.

Tests: the #8529 suites now exercise the "not covered" wording with Polaris (RX
580, gfx803), which still owns it everywhere; the routing guards keep RDNA 1
banned on Linux and assert the Windows route; the parity test accepts a
multi-arch device as routable on the Windows copies only; a new file pins the
package specs, the index, the name tables and the PowerShell mirrors.

* Expect the RX 5700 XT to resolve in the Windows name tables now that it routes

* Drop a torchaudio built against another torch after the multi-arch install

The multi-arch index publishes no torchaudio, so the one left by an earlier CPU
or per-family pass is linked against a torch that is gone and throws a Windows
"Entry Point Not Found" dialog when anything imports it. Seen on the first fresh
install from this branch: torch 2.12.0+rocm10.2 next to torchaudio
2.11.0+rocm7.13. Remove it after the multi-arch pass; a torchaudio carrying the
pinned tag, should AMD publish one, stays.

* Pin that a lone RDNA 1 host takes the Vulkan llama.cpp route

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Run the stale-torchaudio cleanup on every path that ends with the multi-arch torch

setup.ps1 and install.ps1 install the pair themselves and set the marker that
makes the python repair return early, so the cleanup there never ran on a
fresh install (seen: torchaudio 2.11.0+rocm7.13.0 still present after the
multi-arch pass). Do it in the two PowerShell installers right after their
trio lands, and in the python marker shortcut when the installed torch carries
the multi-arch tag.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Give the Windows final step the last word on torchaudio in a multi-arch venv

The dependency pass re-resolves torchaudio 2.11.0 on every run: torch-stoi and
descript-audiotools require it unconditionally and nothing exists for the pinned
torch (AMD's index lists no torchaudio for the tag, PyPI stops at 2.11.0). The
cleanups that run right after the trio install therefore lose to step 8. Run it
once more at the end of the Windows flow, after every with-deps step.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Stop removing torchaudio: 2.11 works beside the multi-arch torch 2.12

Measured on the RX 5700 XT venv the installer built: torchaudio 2.11.0 next to
torch 2.12.0+rocm10.2 imports, resamples, computes a mel spectrogram and loads
torch-stoi, with no dialog. The dependency pass installs it (torch-stoi and
descript-audiotools require it; PyPI stops at 2.11.0 and AMD's index has none),
and taking it out again only lost audio features. The pinned trio still lists no
torchaudio, which is what the index needs; the rest is left to the resolver.

* RDNA 1 on Windows: install from AMD's stable multi-arch index, not the nightly

repo.amd.com/rocm/whl-multi-arch publishes the same per-device packaging as the
nightly, on release tags: torch 2.11.0+rocm7.14.1 with the gfx1010/1011/1012 device
packs, torchvision 0.26.0 and torchaudio 2.11.0 on the same tag. Measured on an
RX 5700 XT: resolves in one go, fp16 matmul correct, Triton unchanged (buffer ops
still need #11615), and the 3-step LoRA/QLoRA rows on Qwen3.5-0.8B and Qwen3-1.7B
match the nightly to the fourth decimal.

So the route pins that release instead of a nightly date: the index also serves
2.12.0, which sits on the <2.12.0 window the rest of the Windows install applies,
so 2.11.0 is the newest release inside it. torchaudio goes back into the trio and
the empty-audio-slot handling ($RocmNoAudio, the trio filter) goes away.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Windows AMD trio: pass the three specs plainly again, and anchor the repair tests on the helper

torchaudio is back in the multi-arch trio, so the empty-slot filter on install.ps1's
three ROCm trio commands has nothing to filter; the plain form is what the pr5940
follow-up tests read. The two cuda_repair tests looked for the inline
_WINDOWS_ROCM_TORCH_PKG_SPECS.get in _ensure_rocm_torch, which now calls
_windows_rocm_torch_pkg_specs; they anchor on that call.

* Windows repair site: do not call _bare_gfx() where the function shadows it

_ensure_rocm_torch binds a local named _bare_gfx further down, so the multi-arch
message calling the module helper raised UnboundLocalError on the Windows repair
path for a gfx1010 host with a CPU torch. Inline the bare-arch spelling there and
run that site in a test.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* RDNA 1 route: count it as covered in the two gates outside the route, and move the
wheel-less fixtures to Polaris

The backend's repairability check and setup.ps1's pre-Intel "AMD gets GPU wheels" gate
both read a list that still omitted gfx1010-1012, so a 5700 XT on Windows could not
establish a torch mismatch and lost to an Intel Arc on a mixed host. The backend gains
a Windows-only extension of the supported set (Linux still declines RDNA 1); setup.ps1's
list gains the three arches.

Tests that used the RX 5700 XT / gfx1010 as the card with no Windows wheels move to
Polaris (RX 580 / gfx803); the Linux-only parity tests learn that RDNA 1 names are
unsupported on the Linux copies and routed on the Windows copies.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Unsloth Studio (AMD/Windows): install every RDNA arch from AMD's stable multi-arch index

repo.amd.com/rocm/whl-multi-arch has a per-device kernel pack for every RDNA arch at
the release tag #11755 pins (2.11.0+rocm7.14.1, torchvision 0.26.0, torchaudio 2.11.0
on the same tag). The per-family Windows indexes stop one ROCm release earlier, an
exact pin has nothing for the kept-release rule to keep (#11814), and per-device packs
are smaller than family bundles. So the RDNA 1 route becomes the route for RDNA 1
through 4 (gfx1153 included, gfx1033 and CDNA stay on their family), in the python
repair and both PowerShell installers.

The family map stays: a host mirroring the family layout (UNSLOTH_ROCM_WINDOWS_MIRROR,
no multi-arch mirror) keeps the family route for arches that have one, and the
stale/mismatch classifiers still read families off the installed runtime. The trio is
derived from the index that was chosen, so it can never name a build the index does
not serve.

Measured on an RX 6500 XT (gfx1034) and, via #11755, an RX 5700 XT (gfx1010).
RDNA 3 / 3.5 / 4 are the same build and shape, unmeasured; draft until someone runs it.

Part of #11815.

* Bundle-coverage test: anchor the family-map regex on its definition line

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tests: expect main's per-arch torch floors on the family route

* Trim comments added by the multi-arch route

* Install torchvision's device pack on the multi-arch route

Bare torchvision from repo.amd.com/rocm/whl-multi-arch carries no GPU
kernels: torchvision.ops.nms raised hipErrorInvalidDeviceFunction on a
gfx1151 (Radeon 8060S, Windows 11). torchvision[device-gfxNNNN] pulls
amd-torchvision-device-gfxNNNN, which resolves for every routed arch.

* Count gfx1153 as a Windows ROCm arch in the backend

The installers route gfx1153 to the multi-arch index, but the backend's
supported set stopped at gfx1152, so a gfx1153 host left on CPU torch
never qualified for the mismatch repair. Add a parity test against
_WINDOWS_MULTIARCH_GFX, and correct the _index_is_multiarch docstring:
explicit unknown-family pins are installed verbatim and never reach it.

* Repair a swapped card on a multi-arch ROCm install

The multi-arch build names no rocm-sdk-libraries family, so the Windows
repair's family comparison reads None and never reinstalls after a card
swap, leaving torch with no kernels for the new GPU. Check the installed
amd-torch-device / amd-torchvision-device packs for the routed arch
instead. Legacy per-family installs are left to the family check.

* Trim comments restating the multi-arch code

* Keep a multi-arch mirror's query token intact

Appending the index slash after the whole URL put it inside a ?token=
query on an authenticated mirror. Split on ? / # first, as
_index_url_join does for the family indexes; plain URLs are unchanged.

* Recognise a query-token multi-arch mirror by its path

_index_is_multiarch compared whole URLs, so https://m/whl-multi-arch?token=x
never matched its own resolved form (.../whl-multi-arch/?token=x) and the
repair installed the trio without device extras. Compare path parts only.

---------

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants