Skip to content

Studio Windows AMD: pair triton-windows with torch after the dependency stack - #16074

Merged
danielhanchen merged 8 commits into
mainfrom
amd-windows-triton-pair
Oct 30, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
amd-windows-triton-pair

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Summary

On AMD Windows, studio/setup.ps1 gets triton-windows from unsloth's [triton] extra, which is unpinned. The NVIDIA branch already pairs it with torch (Get-TritonWindowsSpec), the ROCm branch does not, so a fresh install now resolves triton-windows 3.9.

Triton 3.9 removed block pointers, which the flex_decoding template in torch 2.11 and 2.12 builds. The first GPT-OSS decode then fails to compile, flex attention runs unfused for the rest of the process, and a 4k prefill takes 6.7 GB of attention memory instead of about 0.1 GB on gfx1151.

This PR:

  • Adds Get-TritonWindowsRocmSpec: torch 2.11 and 2.12 map to triton-windows>=3.8,<3.9; anything else returns nothing (torch 2.13+ flex templates have no block pointers, 3.6 has no HIP headers, older torch is left alone).
  • Runs it after the dependency stack, outside no-torch mode, decided from the venv the stack left.
    • Get-RocmTritonPairing reads the venv as it is now: the torch version, torch.version.hip (read from torch/version.py without importing torch, so an untagged ROCm build counts), the installed triton-windows record, and the imported Triton runtime. No earlier torch tag or ROCm index URL decides, so a fresh install or a CPU / CUDA to ROCm move through a custom index is repaired, and a CUDA, CPU or XPU torch is never touched.
    • The runtime decides, not the metadata. The pair counts as good only when the imported triton is a final 3.8.x release (not a dev or rc build), triton.language is a real package (not a namespace left behind by a removed __init__.py) with its core API, and tl.make_block_ptr is not 3.9's raise-only stub. A dist-info can say 3.8 while the files are 3.9 or half removed, so the record only reports what is installed.
    • The triton-windows lookup is by name, so a ~riton_windows-* backup left by an interrupted pip replacement is not mistaken for the installed package. A 3.8 record wins over a leftover one, and a record without Version is skipped, so neither hides the real one.
    • It repairs when the spec applies and the runtime is not paired (3.9, 3.6, missing, or a 3.8 that a half-failed replacement left broken). A broken 3.8, or a record without a version, already satisfies the pin as far as the installer can tell, so it is reinstalled with --force-reinstall --no-deps.
    • The install runs without inherited UV_OVERRIDE, UV_EXCLUDE, UV_CONSTRAINT and PIP_CONSTRAINT, restored afterwards; otherwise they could drop or replace the pin while uv still reports success.
    • Require-hashes is relaxed for that one install the way the dependency stack already relaxes it: UV_REQUIRE_HASHES is cleared and PIP_REQUIRE_HASHES=0, since the unhashed pin can only fail under hash mode. Both are restored afterwards.
    • The install manifest is set aside until a fresh probe shows a paired runtime, the same way the XPU Triton swap holds it: it is moved, the original is checked to be gone, and if it cannot be moved nothing is installed (setup warns and keeps the current Triton). A probe that cannot read the venv verifies nothing. If the pair is still wrong (including exit 0 with the old version, e.g. a uv config override-dependencies), setup warns and leaves the manifest out, so the next update re-runs the dependency pass. If a triton that worked before (it imported, with a real triton.language and its core API) no longer does, setup fails, as the XPU replacement does, so the installer does not commit a broken venv; the printed repair command quotes the pin so it can be pasted into PowerShell.
    • Under UV_OFFLINE the post-stack repair prints a note and leaves the pair for the next online update, as the fast path does.
    • NVIDIA, CPU, XPU, no-torch mode and a failed stack are unchanged.
  • Repairs installs that skip the dependency pass. A verified install that is up to date never reaches the post-stack step. The fast-path checks call the same probe and send such an install back through the dependency pass when the pair is stale, so the two can never disagree. A non-ROCm torch never reads as stale, so this cannot re-fire on every run. Under UV_OFFLINE it prints a note and keeps the fast path, as the Diffusers check does.
  • Backend hint. The "install Triton" hint in studio/backend/core/_msvc_env.py names triton-windows>=3.8,<3.9 for a ROCm torch 2.11 or 2.12, not the NVIDIA range (<3.7 on 2.11).

pyproject

The [triton] extra stays as is. An environment marker cannot see the torch version, so a <3.9 cap would hold back pip users on torch 2.13 and later, where 3.9 works. pip users on torch 2.12 or older with Triton 3.9 are covered by the unsloth_zoo guard (companion PR), which sends decode to the main flex kernel and warns once.

Results

Real gfx1151 Windows 11, install.ps1 --local --skip-autostart, each install in its own Studio home, torch 2.11.0+rocm7.14.0. Base is this PR's merge base; head is an earlier commit of this PR (a562f8e); the later commits only change how the pair is verified (damaged 3.8, unreadable probe, unmovable manifest, the runtime check, UV_OFFLINE after the stack).

install setup exit triton-windows kernel with tl.make_block_ptr compiled flex decode, q_len 1 / 16 flex prefill, 256 rows
base, fresh 0 3.9.0.post30 fails ("Block pointers have been removed") fails / fails ok
head, fresh 0 3.8.0.post29 ok ok / ok (max err 7.6e-4 / 1.1e-3) ok
head, second run 0 3.8.0.post29 ok ok / ok ok
head, 3.9 forced into the venv, then setup 0 3.8.0.post29 ok ok / ok ok

With --local every run takes the dependency pass, which resolves unsloth's unpinned triton-windows to 3.9 and then pairs it back to 3.8, so each such update swaps it once; the end state is always 3.8.

The first version of this PR also ran the GPT-OSS flex memory probe on such an install: memory stays flat after a generate (no 6.7 GB prefill).

Tests

  • New tests/studio/test_rocm_triton_windows_pairing.ps1 (74 checks). It takes the helpers and the post-stack block out of setup.ps1 and runs them against stubs whose probe answers from a simulated venv that the install changes.
    • Spec: torch 2.11 and 2.12 get the 3.8 spec; 2.10, 2.13 and an unknown version get none.
    • After the stack: 3.9, 3.6, a missing triton-windows and a 3.8 that no longer imports are replaced; a 3.8 that imports is kept. A ROCm torch is repaired whatever the earlier tag (none, cpu, cu128) and without a ROCm index URL; an untagged build with torch.version.hip set is repaired. A ROCm index URL left behind does not touch a +cu128, +cpu or +xpu torch. Torch 2.13, a failed stack and no-torch mode are left alone.
    • Install isolation and verification: a 3.8 that no longer imports is force-reinstalled, and is not certified if it still does not import; a post-install probe that cannot read the venv is not certified; a manifest that cannot be moved, or a move that leaves the original behind, blocks the replacement; the four inherited variables are cleared for the install and restored; exit 0 that leaves 3.9 is not certified (manifest dropped, setup continues); a replacement that breaks a working triton fails setup, with exit 0 or not; a failed download that leaves a working 3.9, or a missing triton that cannot be installed, warns only.
    • Runtime check: 3.8 metadata over a runtime that is not 3.8 is repaired and not certified until it is; a namespace-only triton.language is neither paired nor counted as a working baseline; a replacement that leaves an importable triton without its API fails setup; a record without a version over a broken payload is force-reinstalled; UV_OFFLINE leaves the post-stack repair alone.
    • Probe code (real Python, hand-made packages): a ~riton_windows backup alone reads as missing; 3.8 metadata over a 3.9 runtime, a make_block_ptr that is the removed stub, a namespace-only triton.language, and 3.8 dev / rc runtimes are stale; a working make_block_ptr that only mentions the removal in its docstring is paired; a versionless record and a leftover 3.9 record do not hide the 3.8 record; torch.version.hip is read from version.py while torch/__init__.py raises on import.
    • Fast path: a stale pair, a missing triton-windows after a failed repair, a 3.8 that no longer imports and an untagged ROCm build force the pass. A paired install, torch 2.13, a CPU, CUDA or XPU torch, an unreadable probe and UV_OFFLINE keep the fast path.
    • Wiring: the block runs after the stack and reads neither the old tag nor the ROCm index URL; the escape sits in the fast-path checks, outside the gfx-detection block, before the dependency gate.
    • Before these changes: against 9130841 the file failed 28 checks (an earlier tag, a left-behind index URL, the extra variables, exit 0 with the old version, a broken replacement, a dist-info without Version); against a562f8e it failed 4 (the forced reinstall, the unreadable probe and both manifest cases); against 0d7b4d7 it fails 20 (all 13 runtime-check, offline, versionless and quoting cases, plus 7 older cases whose stub now answers the runtime probe).
    • Encoding and 5.1: ASCII only, so Windows PowerShell 5.1 parses it (0 parse errors when read as Latin-1). The fixture that runs real Python sets $ErrorActionPreference = "Continue" around the call, since 5.1 turns a redirected stderr line into a terminating error under Stop.
  • CI: the test runs in cross-platform-parity-ci.yml on pwsh (Linux and Windows) and on Windows PowerShell 5.1.
  • studio/backend/tests/test_msvc_env_triton_hint.py: the ROCm cases fail without the _msvc_env.py change. The _msvc_env test files give 444 passed.
  • Unchanged: every Studio.Setup Pester suite (tests/studio_setup_ps1) gives 245 passed, 7 skipped, 0 failed, with and without the latest change (re-run for this commit). The installer Python tests that read setup.ps1 (XPU Triton swap, fast-path guard, manifest, ROCm support, update idempotency, parity, no-torch setup, _msvc_env hint) give 1302 passed with the same 25 failing IDs before and after (pre-existing on this Linux host).

Not covered

  • On real Windows AMD hardware: the non---local fast path (it uses the setup.ps1 shipped in the package), the forced reinstall of a damaged 3.8, an unmovable manifest, the no-torch gate, and NVIDIA / CPU / XPU venvs. These are covered by the PowerShell test only.

  • The runtime check itself has not run on real Windows AMD hardware yet (the table above predates it).

  • Pre-existing XPU gaps, left for a follow-up: the XPU Triton replacement and its fallback install do not clear inherited uv inputs or verify the result, and both XPU Triton lookups can count a ~riton pip backup as installed.

  • The dependency pass itself is not constrained, so the 3.9 to 3.8 swap repeats on updates that run it.

  • Windows PowerShell 5.1 itself was not run here; the parse check decodes the file as Windows-1252, and the CI step runs it on the Windows runner.

  • Torch 2.12 ROCm on Windows was not installed; the mapping treats it like 2.11 because its flex_decoding template has the same block pointers.

…cy stack

The stack resolves unsloth's unpinned triton-windows, which is now 3.9. 3.9 removed the
block pointers torch 2.11 / 2.12's flex_decoding template builds, so the first decode
fails to compile and flex attention runs unfused for the rest of the process (gpt-oss
4k prefill 0.1 -> 6.7 GB on gfx1151). 3.6 has no HIP headers; pin the verified 3.8.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-10-30T12:44:51.778277Z f34dffb 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 1ad27eb82b

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

…air it on the fast path

- No-torch mode never installs or replaces Triton in the post-stack pairing.
- A verified install (or one whose pairing failed with a warning last run) skips the dependency pass, so the pairing
  never ran: the AMD fast-path checks now send a ROCm torch 2.11 / 2.12 with a non-3.8 triton-windows back through the
  pass (not under UV_OFFLINE, not for a CPU torch, which the pass would not repair).
- The backend's 'install Triton' hint names 3.8 for ROCm torch 2.11 / 2.12, not the NVIDIA range.
- Test: ASCII only (Windows PowerShell 5.1 reads it in the ANSI code page), covers no-torch mode and the fast-path
  escape, and runs in the parity CI on pwsh and Windows PowerShell 5.1.

[skip ci]
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d34c63a233

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

…repair custom ROCm indexes, clear UV_OVERRIDE

- The fast-path retry runs for any ROCm torch, not only inside the gfx-detection checks, so a pinned ROCm index or a
  hybrid host with no detected gfx is repaired too; only a ROCm torch is probed.
- The post-stack repair and the escape share one ROCm torch rule (Test-RocmTorchInstalled), so a custom pinned index
  that leaves ROCmIndexUrl unset is repaired instead of forcing a dependency pass on every update.
- An inherited UV_OVERRIDE is cleared around the pairing install and restored after it.
- The metadata probe looks triton-windows up by name, which skips the ~riton_windows backup an interrupted pip
  replacement leaves.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 913084169e

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

Comment thread studio/setup.ps1 Outdated
Comment on lines +8478 to +8480
if ($stackExit -eq 0 -and -not $NoTorchMode -and ($ROCmIndexUrl -or ($installedTorchTag -match '^(rocm|gfx)'))) {
$_rocmPair = Get-RocmTritonPairing
$_rocmTorch = $ROCmIndexUrl -or (Test-RocmTorchInstalled -Torch $_rocmPair.Torch -InstalledTorchTag $installedTorchTag)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate pairing on the newly installed torch flavor

When setup installs ROCm torch from a custom pinned index such as .../rocm7.2-private into a fresh or previously CPU/CUDA venv, this condition skips the repair entirely. The custom leaf does not set $ROCmIndexUrl, and $installedTorchTag still describes the venv before the direct torch installation, so it is null or non-ROCm even when the stack finishes with 2.11.0+rocm.... The install consequently retains the incompatible Triton version this change is intended to replace. Read the post-stack torch metadata before applying the ROCm gate and use that current flavor to decide whether pairing is needed.

Useful? React with 👍 / 👎.

danielhanchen added a commit that referenced this pull request Oct 30, 2026
…#16088)

`Repo tests (CPU, rest-2)` is red on main since #16062 (MXFP4 torch
decode fallback: run ldexp on the operands' GPU). It fails on unrelated
PRs such as #16085 and #16074:

```
tests/test_mxfp4_compressed_linear.py::test_torch_fallback_runs_ldexp_on_the_operands_gpu[dtype0..2]
unsloth/models/mxfp4_compressed_linear.py:99: in _dequantize_torch_impl
    out[..., 0::2] = lut[(blocks & 0x0F).long()]
RuntimeError: PyTorch is not linked with support for cuda devices
```

The test builds its operands on `cuda:1` inside `FakeTensorMode`. That
works on any CUDA-linked torch, with or without a GPU, but a CPU-only
build cannot dispatch a fake CUDA tensor. The CPU shards install
CPU-only torch. I checked the same few lines on both builds:
`2.13.0+cu130` with no visible GPU runs them, and `2.10.0+cpu` raises
the error above. The product's device guard is fine; the test assumed a
CUDA build.

## Changes

- `test_torch_fallback_runs_ldexp_on_the_operands_gpu` now skips when
`torch.backends.cuda.is_built()` is false. It still runs on CUDA builds,
GPU or not.
- New `test_the_torch_decode_runs_inside_its_operands_device_guard` runs
on any build, so the CPU shards keep covering the guard. It checks three
things: `_dequantize_torch` decodes with the operand's device current,
puts the previous device back, and leaves the current device alone for a
CPU operand or an index-less `cuda` operand.
- The fake `torch.cuda.device` guard is shared by both tests.

## Verification

- CPU-only torch 2.10: the file has 20 passed and 38 skipped, and the
fake-tensor test skips with the reason above. On main it had 3 failures.
- CUDA torch 2.13 with no visible GPU: the three fake-tensor cases and
the new test pass (4 passed).
- Sabotage: dropping `_operand_device_guard` from `_dequantize_torch`
fails the new test on CPU-only torch.
…and verify the repair

The repair and the fast-path check now read the venv as it is (torch version, torch.version.hip from
torch/version.py, triton-windows, whether triton.language imports), never an earlier torch tag or the ROCm
index URL. A fresh install through a custom index is repaired and a CUDA / CPU / XPU torch is never touched.
The install runs without inherited UV_OVERRIDE / UV_EXCLUDE / UV_CONSTRAINT / PIP_CONSTRAINT, the manifest is
set aside until the pair is verified, and a replacement that breaks a working triton fails setup.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a562f8eb7f

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

Comment thread studio/setup.ps1 Outdated
Remove-Item "Env:$_n" -ErrorAction SilentlyContinue
}
try {
$_rocmTritonOut = Fast-Install $_rocmPair.Spec | Out-String

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Force reinstallation when the installed 3.8 package cannot import

When a half-failed replacement leaves 3.8 metadata installed but triton.language missing, Get-RocmTritonPairing marks it stale, but this installation still considers the existing version satisfactory and does not restore its files. Fast-Install forwards these arguments directly to uv/pip without adding a reinstall flag. Their help explicitly distinguishes this behavior: uv's --reinstall reinstalls packages “regardless of whether they're already installed,” and pip's --force-reinstall reinstalls packages “even if they are already up-to-date.” Consequently, this advertised repair path leaves Triton broken, drops the manifest, and repeats on subsequent updates; the new test misses this because its Fast-Install stub always replaces the simulated package. Force reinstallation when repairing an installed but unusable 3.8.

Useful? React with 👍 / 👎.

…ify only a readable probe, hold the manifest like the XPU swap
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 0d7b4d7846

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

…me, honour UV_OFFLINE after the stack, quote the repair command

[skip ci]
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 272b963bc4

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: fb7fa1cb00

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

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: f34dffbb5f

ℹ️ 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 pushed a commit to NilayYadav/unsloth that referenced this pull request Nov 20, 2026
unslothai#18527)

## Problem

On Windows with an AMD GPU, Unsloth Desktop can get stuck in a state
where it refuses to start Studio, and its built-in repair does not help.
This was reported on Desktop 0.1.920-beta:

- Desktop said the install was incomplete (`studio_install_incomplete`).
- Repair ran `unsloth studio update`, then the bundled installer. Both
finished with exit code 0.
- Desktop still refused to start Studio: "Repair finished, but Unsloth
install is still not desktop-ready."

## Why it happens

Two pieces of code disagree about what a failed Triton swap means.

**Desktop needs the install manifest.** Setup writes
`unsloth_install_manifest.json` into the venv when an install finishes.
Desktop only starts Studio if this file is there. If it is missing,
Desktop calls the install incomplete.

**On AMD, setup can delete the manifest and still report success.**
unslothai#16074 added a step that runs after the dependencies are installed. When
ROCm torch 2.11 or 2.12 ends up next to Triton 3.9, this step replaces
it with Triton 3.8, because 3.9 breaks fused flex attention decode with
those torch versions. The step works like this:

1. Move the manifest aside, so an interrupted swap is never marked as
finished.
2. Install Triton 3.8.
3. Check what is installed now.
4. If 3.8 is in place, put the manifest back.
5. If not, print a warning ("flex attention decode may run unfused"),
delete the manifest, and let setup exit 0. Setup only fails here if the
swap broke a Triton that worked before.

Step 5 is the bug. Setup reports success, but Desktop now sees an
incomplete install. Repair runs setup again, which reaches the same
step, fails the same way, and deletes the manifest again. On a machine
where the swap keeps failing, Desktop never recovers.

The swap can fail for several reasons: the install fails, the check
after it fails or times out, or a uv `override-dependencies` setting
keeps 3.9 while the install still exits 0. The report does not show
which one the reporter hit.

**Desktop also hid the reason.** Its check after repair returned only
yes or no, so the error message never said why the install was not
ready.

## Fix

**`studio/setup.ps1`:** when the swap ends with only a warning, put the
manifest back instead of deleting it.

This is safe because a warning means Triton is no worse than before the
step:

- If Triton 3.9 still works, the cost is unfused flex attention decode.
- If Triton was missing or broken before, it still is, and the backend
keeps `torch.compile` turned off, as it already did
(`gate_torch_compile_on_windows`).

In both cases Studio can still start. The swap is also retried on the
next update, even with the manifest in place, because the update's fast
path checks the installed Triton directly
(`Test-RocmTritonPairingNeedsPass`). The old code comment said the
manifest had to go so that the next update would retry; that is not
needed.

Setup still fails, as before, when the swap breaks a Triton that worked.
It now also fails if it cannot put the manifest back, instead of
reporting success without one.

**Desktop (`studio/src-tauri`):** when repair ends with the install
still not ready, the error names the reason, for example:

```
Repair finished, but Unsloth install is still not desktop-ready (studio_install_incomplete).
```

The log line written when repair falls back from the update to the
installer includes the reason too.

**Tests (`tests/studio/test_rocm_triton_windows_pairing.ps1`):** cases
where the swap only warns now expect the manifest to be kept. A new case
checks that setup fails when the manifest cannot be put back.

## Testing

### Live A/B on Windows AMD hardware

Both versions ran on AMD Strix Halo machines (Windows 11, Radeon 8060S,
Python 3.13, torch `2.11.0+rocm7.14.0`). "Main" is the base commit and
"fix" is the same commit plus this change.

To make the swap fail on purpose, a uv config set `override-dependencies
= ["triton-windows==3.9.0.post30"]`. With that in place, installing
Triton 3.8 exits 0 but leaves 3.9 installed.

Each version ran three commands. After each one, the table shows whether
the manifest exists and what `unsloth studio desktop-capabilities
--json` reports for `studio_install_ok`. That value is what Desktop
checks before it starts Studio. Every command exited 0.

| Command | Main | Fix |
|---|---|---|
| 1. `install.ps1 --local --python 3.13`, swap forced to fail | Manifest
missing, `false` | Manifest kept, `true` |
| 2. `unsloth studio update` (the update Desktop's repair runs), swap
still forced to fail | Manifest deleted again, `false` | Swap retried,
manifest kept, `true` |
| 3. `unsloth studio update --local`, override removed | Triton 3.8
installed, `true` | Triton 3.8 installed, `true` |

Rows 1 and 2 reproduce the reported failure on main and show the fix.
Row 3 shows that both versions install Triton 3.8 once the cause is
gone.

Logs:
[main](https://github.com/oobabooga/unsloth/actions/runs/44585530606/job/135777305749),
[fix](https://github.com/oobabooga/unsloth/actions/runs/44585530606/job/135777305355).
The "Evidence after ..." steps print what the table is based on: exit
code, the swap messages from the setup log, whether the manifest exists,
the torch and Triton versions, and the `desktop-capabilities` answer.
Harness:
[workflow](https://github.com/oobabooga/unsloth/blob/2636b6485613da72731aaa684b3de37533e250c1/.github/workflows/rocm-triton-manifest-ab.yml),
[evidence
script](https://github.com/oobabooga/unsloth/blob/2636b6485613da72731aaa684b3de37533e250c1/evidence.ps1).

The main job's last step (Verdict) is red because of a harness problem
unrelated to the results above. That job also tried to run the updated
unit tests against main, but the test file was not swapped in, so it ran
main's own tests. The likely cause is that the runner checked out the
patch with CRLF line endings. The unit comparison was rerun separately,
below.

### Unit tests

- Pairing tests on Windows PowerShell 5.1: all pass with the fix. The
same tests against main fail 8 checks, which are the warning cases and
the new restore-failure case. Logs:
[main](https://github.com/oobabooga/unsloth/actions/runs/44586993985/job/135782513765),
[fix](https://github.com/oobabooga/unsloth/actions/runs/44586993985/job/135782513147),
[workflow](https://github.com/oobabooga/unsloth/blob/4901ba61be2384885c875f1ad67d6c163f50eaef/.github/workflows/rocm-triton-manifest-unit.yml).
The main job is red because those 8 failures are the expected result;
its log ends with `MATCH`.
- Pairing tests on Linux PowerShell 7.7: 78 of 78 pass.
- `cargo test` in `studio/src-tauri` on Linux: 872 of 872 pass,
including two new tests for the repair error. In one of three full runs,
an unrelated timing-sensitive test
(`shell_path::tests::a_job_writing_nonstop_does_not_hold_launch`) failed
once and then passed on its own.

### Not tested

I did not run the Desktop app itself on Windows. The live test checks
the same `desktop-capabilities` answer that Desktop reads before it
starts Studio.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant