Skip to content

Unsloth Studio installer (AMD/Linux): send RDNA 4 cards (RX 9000, R9700) to AMD's gfx120X wheels - #11935

Merged
danielhanchen merged 12 commits into
mainfrom
rdna4-amd-arch-index
Sep 26, 2026
Merged

danielhanchen merged 12 commits into
mainfrom
rdna4-amd-arch-index

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Fixes the routing half of #10657.

The problem

A Linux host with an RDNA 4 card (gfx1200 / gfx1201, e.g. the Radeon AI PRO R9700 in #10657) on ROCm 7.14 gets https://download.pytorch.org/whl/rocm7.2. The installer reads 7.14 correctly, but it caps anything past 7.2 to rocm7.2, since that is the newest generic wheel family.

Those wheels report HIP below 7.13, and below 7.13 RDNA 4 has the null HIP _grouped_mm kernel (TheRock #5284). So studio/backend/core/training/worker.py installs its Python CPU fallback for _grouped_mm: a slow path on every MoE layer.

Strix (gfx1150/1151/1152) already avoids this by routing to AMD's per-arch index, and install.ps1 already routes Windows RDNA 4 the same way. Linux RDNA 4 was the one path left on the broken wheels.

AMD's repo.amd.com/rocm/whl/gfx120X-all/ serves the torch 2.11.0 / torchvision 0.26.0 / torchaudio 2.11.0 +rocm7.13.0 trio for Linux cp310 through cp314, inside the installer's _TORCH_CEILING of 2.12.0. Its torch/version.py reads hip = '7.13.99004', so the worker gate stops firing.

The change

  • install.sh: an RDNA 4 arm beside the Strix one. It fires when the runtime target is gfx1200/1201 and the chosen leaf is below 7.13, and sends torch to ${UNSLOTH_AMD_ROCM_MIRROR}/gfx120X-all/ with the same 2.11 constraint set Strix uses.
    • It rewrites the leaf, so the rocm6.4 floor block after it cannot undo the route.
    • It sits inside the existing pin guard, so UNSLOTH_TORCH_INDEX_URL / UNSLOTH_TORCH_INDEX_FAMILY still win, as does UNSLOTH_ROCM_GFX_ARCH=gfx906.
  • install_python_stack.py: the Strix-only set becomes _AMD_ARCH_INDEX_FLOOR_GFX (Strix plus RDNA 4), shared by the reroute and _rocm_compat_reroute_pending, so studio update agrees with install.sh. A venv already on the gfx120X-all build is left alone and makes no pip call.
  • Re-running install.sh over an existing venv: the migrated-environment repair only reinstalled below the arch's generic floor (6.4 for RDNA 4), so a venv already on torch 2.11+rocm7.2 kept the broken wheel. Both per-arch arms (Strix and RDNA 4) now set _amd_arch_index_routed, and the repair reinstalls from the routed index when the venv wheel is below rocm7.13 or was built for another AMD family (read off the rocm meta-package, as install_python_stack.py does; an unreadable family is left alone). For Strix this is a small widening that matches what studio update already does; a venv already on the 7.13 build is left alone.
  • Python 3.9: gfx120X-all has no cp39 wheels, so a 3.9 venv keeps the generic route in both install.sh and install_python_stack.py, as before.
  • Tests: tests that used gfx1200/1201 as an ordinary generic card now use gfx1100/1030/1102, so they keep testing what they did. New tests cover the route at every generic tag, the pending check, the no-churn case, pins winning, and an executed shell route with rocm7.13 and gfx1100 controls.

Before and after

Each case is one process running install.sh's real functions and the block from the pin guard through the reroutes, with fake rocminfo / hipconfig on PATH. The grid is 6 arches x 4 host ROCm versions x 3 pin states, run against the merge base and this branch.

72 cells: 66 identical, 6 moved. All six are gfx1200/1201 with no pin:

host before after
gfx1200 / gfx1201, ROCm 6.4 whl/rocm6.4 repo.amd.com/rocm/whl/gfx120X-all/
gfx1200 / gfx1201, ROCm 7.2 whl/rocm7.2 gfx120X-all/
gfx1200 / gfx1201, ROCm 7.14 whl/rocm7.2 gfx120X-all/

These did not move: every pinned cell, gfx1151 (still gfx1151/), gfx906 (still rocm6.3), gfx1100, gfx1102, and every unreadable-version cell (CPU index on both). Results are the same under bash and dash.

The Python mirror has 144 cells: 128 identical, 16 moved, all gfx1200/1201 with no pin. Two of those behaviours are worth calling out:

  • An RDNA 4 venv already on a generic rocm7.2 wheel is reinstalled from gfx120X-all on the next studio update. That is the fix reaching existing users, who are on the CPU fallback today. Strix already behaves this way. pip resolves and downloads before it uninstalls, so an unreachable repo.amd.com leaves the working torch in place.
  • RDNA 4 with an unreadable ROCm version now gets gfx120X-all from studio update, where it got nothing. This comes from the existing _strix_needs_amd_arch_index, which treats an unreadable version as below every tag. gfx1151 already takes this path on main, and the AMD wheels carry their own ROCm runtime, so this only widens. install.sh still resolves the CPU index in that case, as it does on main.

Negative controls:

  • Removing the install.sh arm fails only the RDNA 4 shell cases.
  • Returning the Python set to Strix-only fails only the new RDNA 4 Python tests.
  • Adding gfx1010 to the RDNA 4 case line fails only the guard test.

Suites run:

  • tests/sh/test_*.sh: 76/76 files pass on both arms, and again after the rebase (965 passed, 1 skipped across the three routing test files after the follow-up changes).
  • tests/studio/install/: failing IDs compared across arms. One test depends on the real host and fails on both. One llama-server quarantine test is flaky on both; rerun alone it failed 1 of 2 times on the merge base.

What this does not prove

The generic pytorch.org ROCm wheels up to rocm7.2 ship the null HIP
_grouped_mm kernel on gfx1200/gfx1201 (TheRock #5284), so the trainer
swaps in a slow Python fallback whenever torch.version.hip is below
7.13. A ROCm 7.14 host is capped to rocm7.2 and always lands there.

AMD's gfx120X-all index serves torch 2.11.0+rocm7.13.0 for cp310-cp314,
the same coverage the Strix reroute already relies on, and install.ps1
already routes Windows RDNA 4 there. Extend the Strix reroute to
gfx1200/gfx1201 in install.sh and install_python_stack.py:

- install.sh rewrites the leaf to gfx120x-all so the rocm6.4 floor block
  below cannot undo it; the floor target flag is still set for the
  migrated venv repair.
- install_python_stack.py shares one set for the reroute and the pending
  check, so a venv already on the AMD build is left alone.
- Explicit UNSLOTH_TORCH_INDEX_URL / _FAMILY pins and the gfx906
  override are unchanged.

Tests move the RDNA 4 expectations from rocm6.4 to gfx120x-all, retarget
cases that used gfx120X as a plain generic arch, and add the new route
with gfx1100 and rocm7.13 controls.
@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-09-25T13:40:19.510766Z 03b5d93 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 Sep 25, 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-09-26T12:21:18.084353Z f0fe171 Manual request
🔒 Security Review ✅ Completed 2026-09-25T16:27:17.068170Z 9e010eb Manual request
ℹ️ 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 security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 9e010ebd23

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@LeoBorcherding LeoBorcherding changed the title Route RDNA 4 to AMD's gfx120X-all wheels on Linux below ROCm 7.13 Unsloth Studio installer (AMD/Linux): send RDNA 4 cards (RX 9000, R9700) to AMD's gfx120X wheels Sep 25, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 3534a4de6a

ℹ️ 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 added a commit to Imagineer99/unsloth that referenced this pull request Sep 26, 2026
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Sep 26, 2026
…kage

With no family given, the stubbed venv left importlib.metadata.requires
unpatched, so on a ROCm host it read the real rocm-sdk-libraries-gfx1151
and reinstalled where the case expects no change.
_ensure_rocm_torch() is a no-op on macOS and aarch64, so on those
runners the pip mocks were never called and the new RDNA 4 routing
tests failed.
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Sep 26, 2026
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Sep 26, 2026
danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 26, 2026
danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 26, 2026
danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 26, 2026
danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 26, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a8c1cc8a3b

ℹ️ 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 self-assigned this Sep 26, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 26, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 26, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 26, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 26, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 26, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f0fe171d64

ℹ️ 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 cc44b7d into main Sep 26, 2026
78 of 79 checks passed
@danielhanchen
danielhanchen deleted the rdna4-amd-arch-index branch September 26, 2026 13:31
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…00) to AMD's gfx120X wheels (unslothai#11935)

* Route RDNA 4 to AMD's gfx120X-all wheels on Linux below ROCm 7.13

The generic pytorch.org ROCm wheels up to rocm7.2 ship the null HIP
_grouped_mm kernel on gfx1200/gfx1201 (TheRock unslothai#5284), so the trainer
swaps in a slow Python fallback whenever torch.version.hip is below
7.13. A ROCm 7.14 host is capped to rocm7.2 and always lands there.

AMD's gfx120X-all index serves torch 2.11.0+rocm7.13.0 for cp310-cp314,
the same coverage the Strix reroute already relies on, and install.ps1
already routes Windows RDNA 4 there. Extend the Strix reroute to
gfx1200/gfx1201 in install.sh and install_python_stack.py:

- install.sh rewrites the leaf to gfx120x-all so the rocm6.4 floor block
  below cannot undo it; the floor target flag is still set for the
  migrated venv repair.
- install_python_stack.py shares one set for the reroute and the pending
  check, so a venv already on the AMD build is left alone.
- Explicit UNSLOTH_TORCH_INDEX_URL / _FAMILY pins and the gfx906
  override are unchanged.

Tests move the RDNA 4 expectations from rocm6.4 to gfx120x-all, retarget
cases that used gfx120X as a plain generic arch, and add the new route
with gfx1100 and rocm7.13 controls.

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

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

* Trim comments in RDNA 4 AMD arch index routing

* Reinstall a migrated sub-7.13 wheel when torch is routed to an AMD per-arch index

* Also reinstall a migrated 7.13 wheel built for another AMD family

* Keep RDNA 4 on the generic wheels in a Python 3.9 venv, which gfx120X-all does not serve

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

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

* Keep the migrated repair test from reading an AMD host's own rocm package

With no family given, the stubbed venv left importlib.metadata.requires
unpatched, so on a ROCm host it read the real rocm-sdk-libraries-gfx1151
and reinstalled where the case expects no change.

* Pin the ROCm repair test helpers to Linux x86_64

_ensure_rocm_torch() is a no-op on macOS and aarch64, so on those
runners the pip mocks were never called and the new RDNA 4 routing
tests failed.

* Trim comments in the RDNA 4 routing change

* Drop comments that restate the RDNA 4 test names

* Expect RDNA 4 to install from the AMD index when the ROCm version is unreadable

---------

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

1 participant