Skip to content

Installers (AMD, Linux): let new installs on the generic rocm7.2 index take torch 2.12 to 2.14 - #14350

Open
danielhanchen wants to merge 5 commits into
mainfrom
amd-linux-rocm72-torch214
Open

danielhanchen wants to merge 5 commits into
mainfrom
amd-linux-rocm72-torch214

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Problem

On Linux, AMD hosts that land on the generic pytorch.org rocm7.2 index are capped at torch 2.11 (#9932). That index now serves torch 2.12 through 2.14.1, and the cap is the only reason new installs never get them. It is also why a ROCm 7.14 or 10.x host keeps landing on the oldest build we install.

The 2.11 cap was shared with the AMD per-arch indexes (Strix, RDNA 4, gfx103X, gfx110X), which really do stop at 2.11. Only the generic leaf needs the wider window.

Fix

  • install.sh: the rocm7.2 leaf gets its own arm, torch>=2.11.0,<2.15.0 and torchvision>=0.26.0,<0.30.0. torchaudio stays >=2.11.0,<2.12.0, since 2.11 is its last release and it pairs with all of these (same pairing the cu130 route already ships). The 2.11 floor for the _grouped_mm bug is unchanged.
  • studio/install_python_stack.py: the update and repair path uses the same window for the rocm7.2 tag. The per-arch leaves and the Windows pins move to a separate _ROCM_TORCH211_PKG_SPEC that keeps 2.11 exactly, so they do not change. A UNSLOTH_TORCH_INDEX_FAMILY=rocm7.2 pin now accepts 2.11 to 2.14 instead of repairing a 2.12+ build back down on every update.

Not changed:

  • Windows (multi-arch and per-arch pins), Strix and RDNA 4 per-arch routes, gfx906 (rocm6.3), rocm6.x and rocm7.0/7.1 leaves, CUDA, XPU, CPU.
  • Existing installs. unsloth studio update (and the Desktop update) keeps any working ROCm torch, and an installer re-run keeps the resident release (rocm7.2 still serves 2.11.0). Only Settings > Repair (UNSLOTH_TORCH_UPGRADE=1) moves an existing install to the newest build.

Validation

torch builds on real gfx1151 (Strix Halo) hardware, Linux, each in a fresh venv with Unsloth main, 10 step LoRA SFT on Qwen3-0.6B plus matmul, SDPA forward/backward, _grouped_mm and torch.compile checks:

build result max per step loss diff vs today's build
per-arch 2.11.0+rocm7.13 (today) baseline, no flash / efficient SDPA kernels
2.14.1+rocm7.2 (this PR, generic route) all checks pass, 4-bit LoRA passes, flash and efficient SDPA available 0.8%

The 2.14.1+rocm7.2 wheel also carries gfx1103 kernels, which 2.11 does not.

Real install.sh --local and unsloth studio update --local on a gfx1151 Linux runner (base = main d9aded380, head = this branch), training a 5 step LoRA through POST /api/train/start after each step. The runner is a Strix box, so the generic route is reached with UNSLOTH_TORCH_INDEX_FAMILY=rocm7.2; the last row is the unpinned default.

step torch after log training
main, fresh install 2.11.0+rocm7.2 completed, loss 3.475 to 1.915
this branch, installer re-run over it 2.11.0+rocm7.2 existing install has torch 2.11.0+rocm7.2 -- keeping it
this branch, unsloth studio update 2.11.0+rocm7.2 torch check only, no reinstall completed, loss 3.475 to 1.915
this branch, Repair (UNSLOTH_TORCH_UPGRADE=1) 2.14.1+rocm7.2, torchvision 0.29.1, torchaudio 2.11.0 16 bit completed 3.484 to 1.904, 4 bit completed 3.709 to 2.013
torchaudio on the upgraded install Resample on the GPU works
this branch, fresh install 2.14.1+rocm7.2
then unsloth studio update 2.14.1+rocm7.2 torch check only, no reinstall completed, loss 3.484 to 1.904
this branch, fresh install, no pin (Strix default) 2.11.0+rocm7.13.0 unchanged per-arch route

Timing on the same gfx1151 runner, torch 2.11.0+rocm7.2 (A) vs 2.14.1+rocm7.2 (B), both from the rocm7.2 index with the same Unsloth: ABBA x2, a fresh process per measurement, amd-smi showed no other process on the GPU before or after every run. Unsloth Qwen3-0.6B 16 bit, 580 token prompt, then 25 LoRA steps (median after 5 warmup). Median (min to max) of 4 runs per arm:

metric 2.11.0 2.14.1
TTFT (ms) 33.80 (33.48 to 34.02) 30.09 (29.96 to 30.14)
prefill tok/s 7130 (7084 to 7199) 8010 (7995 to 8045)
decode tok/s 29.91 (29.82 to 29.95) 29.98 (29.97 to 30.00)
train step (ms) 181.4 (180.6 to 182.0) 164.5 (164.2 to 165.4)
peak memory, inference / training (GB) 1.273 / 1.517 1.273 / 1.517

No metric regresses; prefill is about 12% faster, training steps about 9% faster, decode and memory unchanged. Losses track each other step by step (0.487 to 0.043 vs 0.487 to 0.041).

Tests:

  • New tests/sh/test_rocm72_torch_window_9932.sh lifts the real case block out of install.sh: rocm7.2 gets the new window, every per-arch leaf and every other leaf is unchanged, and an existing 2.11.0 or 2.14.1 install keeps its release unless Repair is used.
  • New tests/studio/install/test_rocm72_torch_window_9932.py: the Python spec matches install.sh, per-arch and Windows pins stay on 2.11, and the rocm7.2 pin accepts 2.11 to 2.14 and rejects 2.10, 2.15 and a non rocm7.2 build.
  • Both fail on main (5 Python, 1 shell) and pass here.
  • Existing tests that asserted the old shared spec or the old case text are updated to the new arms (install arch table parity, cross-platform parity, Windows floor, missing-arch routing, ROCm support). The CUDA cap lockstep test now pairs CUDA with the ROCm 2.11 spec, since rocm7.2 is deliberately wider.
  • tests/studio/install + tests/python/test_tokenizers_and_torch_constraint.py: 10095 passed. The same 4 TestProgressStepCountMatchesTotal cases fail on main and here.
  • All tests/sh/*.sh pass, and the related PowerShell pin tests pass.

Fixes #9932 (the torch side for generic route hosts).

@danielhanchen danielhanchen self-assigned this Oct 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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 ⚠️ Failed 2026-10-20T19:33:12.962577Z 3bc07d2 New commits
🔒 Security Review ✅ Completed 2026-10-20T13:42:16.785109Z f662643 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

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: f662643eb1

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f662643eb1

ℹ️ 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

Copy link
Copy Markdown
Member Author

parity (windows-latest) fails on two tests in tests/python/test_cross_platform_parity.py, and they fail the same way on Linux (main passes all 119 tests in that file, this head fails 2):

  • TestGfx211AllowlistParity::test_install_sh_allowlist: install.sh gfx-2.11 allowlist case not found / changed
  • TestKnown211SetParity::test_install_sh_known_211_leaf_is_rocm72_and_gfx_allowlist: install.sh 2.11 floor case (rocm7.2|gfx...) not found / changed

Both find the 2.11 floor with ^\s*(rocm7\.2\|[a-z0-9|.\-]*)\), which needs the combined rocm7.2|gfx120x-all|...) arm. This PR splits that into a rocm7.2) arm and a separate gfx120x-all|gfx1151|gfx1150|gfx1152|gfx103x-all|gfx110x-all) arm, so the regex no longer matches. The split looks intended (rocm7.2 now covers 2.12 to 2.14), so the tests need to move with it. The gfx allowlist check can match the gfx-only arm, and the known-2.11 set check should say what the rocm7.2 arm is now expected to contain.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 2638e23237

ℹ️ 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 that referenced this pull request Oct 20, 2026
)

## Problem


`tests/test_qat_phone_deployment.py::test_fake_quantized_embedding_unpickles_in_fresh_process`,
added in #14376, fails in the CPU `Repo tests (CPU, rest)` shard on
every PR whose merge includes #14376 (for example #14350):

```
File "/home/runner/work/unsloth/unsloth/unsloth/_gpu_init.py", line 245, in <module>
  import unsloth_zoo
...
NotImplementedError: Unsloth cannot find any torch accelerator? You need a GPU.
```

The test pickles the fake-quantized embedding and loads it in a fresh
`python -c` child. That class is defined in `unsloth.models._utils`, so
unpickling imports `unsloth`. With a CPU-only torch, `unsloth` refuses
to import. That refusal is by design, so the product is right and the
test is not. The parent test process gets the CUDA spoof from
`tests/conftest.py`, but the child has no conftest.

## Fix

The child adds `tests/` to `sys.path`. When torch reports no CUDA, it
applies `_zoo_aggressive_cuda_spoof` before unpickling, the same spoof
the CPU CI uses. On a host with a real GPU the branch is skipped, so the
child loads the embedding exactly as before.

## Verification

In a CPU-only venv (torch 2.10.0+cpu, torchao 0.18.0, unsloth-zoo
`e1d0b6d6d4` as CI installs it), with `PYTHONPATH` cleared:

- main: the test fails with the error above.
- This change: `tests/test_qat_phone_deployment.py` 20 passed.
danielhanchen added a commit to unslothai/unsloth-zoo that referenced this pull request Oct 21, 2026
…nstead of clearing them (#1913)

## Problem


`tests/test_fused_forward_fp16_scaler.py::test_fused_forward_fp16_uses_accelerator_scaler`
(added in #1906) fails in the unsloth repo's `Core zoo (HF=default +
TRL=default)` job, which runs this suite with `-n 4 --dist loadfile`. It
fails on unrelated PRs there, for example unslothai/unsloth#14392 and
unslothai/unsloth#14350:

```
tests/test_fused_forward_fp16_scaler.py:45: in test_fused_forward_fp16_uses_accelerator_scaler
    assert fi.install_for_class(LlamaForCausalLM)
E   AssertionError: assert False
```

It passes on its own. It fails whenever
`tests/test_fused_forward_install.py` ran earlier in the same worker:

```
$ pytest tests/test_fused_forward_install.py tests/test_fused_forward_fp16_scaler.py
FAILED tests/test_fused_forward_fp16_scaler.py::test_fused_forward_fp16_uses_accelerator_scaler
1 failed, 34 passed, 11 skipped
```

That file's `fresh_install` fixture clears `_PATCHED`, `_UNMATCHED`,
`_FAILED` and `_CANONICAL_FORWARDS` before and after every test. A class
patched before the file ran keeps its rewritten `forward` but loses its
`_PATCHED` entry. The next `install_for_class` on it then reads
non-stock source and declines. Which file lands on which worker decides
whether this shows up, so it looks intermittent.

## Fix

Test only. The fixture still gives each test empty registries. It now
snapshots the four registries first and puts their contents back
afterwards, instead of clearing them on the way out.

## Verification

Run on CPU (torch 2.10.0+cpu, transformers 5.17.0 as the `Core zoo` job
uses, and 5.18.0), with `UNSLOTH_IS_PRESENT=1` and unsloth main on the
path:

- `pytest tests/test_fused_forward_install.py
tests/test_fused_forward_fp16_scaler.py`
  - before: 1 failed, 34 passed, 11 skipped
  - after: 35 passed, 11 skipped
- `tests/test_fused_forward_fp16_scaler.py` alone: 2 passed, before and
after.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator

tested on two boxes: WSL Ubuntu 24.04 with 2x R9700 (gfx1201, ROCm 7.2.1), and bare-metal Mint 22.1 with an RX 9060 XT (gfx1200). Routing matches the PR on both: base gets 2.11.0, head gets 2.14.1 / 0.29.1 / 2.11.0, a re-run keeps the old release, Repair moves to 2.14.1, and studio update keeps it.

one real problem, on WSL: 2.14.1+rocm7.2 aborts on the first torch.cuda call (Found 0 rocprofiler agents and 3 HSA agents). It bundles librocprofiler-sdk, which can't see GPUs through /dev/dxg, and the installer still exits 0. 2.11 is fine. The fix is three commits on the mirror, 02ac089afa, 7ca02cd307 and cbd04ee944: WSL stays on the 2.11 trio and native Linux keeps the new window, and studio update also repairs an unpinned 2.12+ install on WSL. Tests included, Codex clean, and the Mint run repeated at cbd04ee944 matches this head line for line. Cherry-pick them if they look right.

the two red checks here were main's own reds in that window. Merging main merges cleanly and should clear them. Full table: LeoBorcherding#507

This branch has not been deployed

No deployments
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.

[Feature] AMD: install PyTorch built for ROCm 7.14 or 10, not only ROCm 7.2, and let users pick

2 participants