Repository navigation
Unsloth Studio installer (AMD/Linux): send RDNA 4 cards (RX 9000, R9700) to AMD's gfx120X wheels - #11935
Conversation
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.
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 security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…-all does not serve
|
Codex Review: Didn't find any major issues. 👍 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". |
…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.
|
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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
…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>
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_mmkernel (TheRock #5284). Sostudio/backend/core/training/worker.pyinstalls 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.ps1already 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 thetorch 2.11.0 / torchvision 0.26.0 / torchaudio 2.11.0 +rocm7.13.0trio for Linux cp310 through cp314, inside the installer's_TORCH_CEILINGof 2.12.0. Itstorch/version.pyreadship = '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.UNSLOTH_TORCH_INDEX_URL/UNSLOTH_TORCH_INDEX_FAMILYstill win, as doesUNSLOTH_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, sostudio updateagrees withinstall.sh. A venv already on the gfx120X-all build is left alone and makes no pip call.install.shover an existing venv: the migrated-environment repair only reinstalled below the arch's generic floor (6.4 for RDNA 4), so a venv already ontorch 2.11+rocm7.2kept 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 therocmmeta-package, asinstall_python_stack.pydoes; an unreadable family is left alone). For Strix this is a small widening that matches whatstudio updatealready does; a venv already on the 7.13 build is left alone.install.shandinstall_python_stack.py, as before.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 fakerocminfo/hipconfigon 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:
whl/rocm6.4repo.amd.com/rocm/whl/gfx120X-all/whl/rocm7.2gfx120X-all/whl/rocm7.2gfx120X-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:
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.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.shstill resolves the CPU index in that case, as it does on main.Negative controls:
install.sharm fails only the RDNA 4 shell cases.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. Onellama-serverquarantine test is flaky on both; rerun alone it failed 1 of 2 times on the merge base.What this does not prove
install.ps1already routes RDNA 4 this way.