Skip to content

Studio: install prebuilt flash-attn, causal-conv1d and mamba-ssm wheels on Windows and ARM - #13262

Merged
danielhanchen merged 8 commits into
mainfrom
win-prebuilt-wheels-studio
Oct 11, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
win-prebuilt-wheels-studio

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Studio has always skipped flash-attn, causal-conv1d and mamba-ssm on Windows, because no upstream release has ever published a Windows wheel for any of them. #13261 builds win_amd64 wheels for torch 2.13 and 2.14 on prebuilt-wheels-cu13; this PR makes Studio install them, and on Windows on ARM installs NVIDIA's own flash-attn wheels.

What changes

Resolver (studio/backend/utils/wheel_utils.py)

  • unsloth_prebuilt_wheel_url now answers for win_amd64 as well as linux_x86_64: torch 2.13 / 2.14, CUDA 13, cp313 GIL builds only (the only interpreter published), with the same upstream filename template, e.g. flash_attn-2.8.4+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl. Linux still answers for any interpreter, as before.
  • On any win_* platform, direct_wheel_url and flash_attn_wheel_url never build a Dao-AILab or state-spaces name, since none of those releases has a Windows asset and the URL could only 404.
  • ARM, for the cells Build the prebuilt CUDA 13 kernel wheels for Windows and ARM (win_amd64, linux_aarch64, win_arm64) #13261 builds: linux_aarch64 torch 2.13 / 2.14 cp313 resolves all three to our release (upstream's aarch64 wheels stop at torch 2.10), and win_arm64 torch 2.14 on CUDA 13.4+ resolves causal-conv1d and mamba-ssm for cp311 to cp313. flash-attn on win_arm64 stays NVIDIA's.
  • wheel_platform_tag returns win_arm64 on Windows on ARM. flash-attn there resolves to NVIDIA's Flash-Attention-for-WoA release (flash-attn 2.8.4 for torch 2.14 + CUDA 13.4, cp311 to cp314 and cp314t; a CUDA 13.0 torch no longer matches), with each file's sha256 pinned through a #sha256= fragment, taken from the release's asset digests. uv and pip both refuse a mismatched file.
  • probe_torch_wheel_env reports abi_tag so a free-threaded interpreter never gets a GIL wheel, and its Windows opt-in now covers every win_* tag.

Callers

  • Setup (install_python_stack.py): the flash-attn step runs on Windows. Its torch probe is bounded by the same 300 s as the import probe before it, so a wedged driver cannot hang setup. Linux is unchanged.
  • When the Windows torch flavor repair at the end of setup replaces torch, flash-attn is checked again for the new torch, as step 13 already does after the Linux repair.
  • Training worker: long-context flash-attn, the causal-conv1d fast path (eager and the lazy hook) and mamba-ssm run on Windows.
  • Chat (ssm_runtime.py): the blanket win32 causal-conv1d skip is gone.
  • unsloth install-kernels accepts win_*.

Windows is wheel-only

  • A missing, unreachable or rejected wheel on Windows returns straight away and the model keeps its torch fallback. It never falls through to pip install flash-attn or a mamba-ssm source build, which on a machine with MSVC and the CUDA toolkit could run for hours. This also covers _ensure_mamba_ssm, which had no Windows gate at all.
  • A wheel that installs but does not import is uninstalled, as on Linux.
  • mamba_ssm imports Triton at module load, and on Windows that is triton-windows, which the wheel's metadata cannot name. The worker, ssm_runtime and install-kernels all require an importable triton before installing it; a true SSM model without it gets a clear error instead of a crash at load.

Tests

  • New studio/backend/tests/test_wheel_utils_windows_kernels.py (28 tests): every Windows URL shape for all three kernels on torch 2.13 and 2.14; the cells that must resolve to nothing (cp312, cp313t, torch 2.11 / 2.10, cu12, no CUDA, the wrong ABI flag); a sweep showing no Windows URL ever names an upstream release; the 5 NVIDIA win_arm64 URLs and hashes including cp314t; Linux unchanged.
  • Windows cases added to test_ssm_runtime.py, test_training_worker_flash_attn.py, test_kernel_install.py and tests/python/test_flash_attn_install_python_stack.py: each caller is reached on Windows, a published wheel installs, a miss, an unreachable check or a rejected wheel never reaches PyPI, and the Triton gate.
  • New studio/backend/tests/test_wheel_utils_linux_aarch64_kernels.py and win_arm64 cases in test_wheel_utils_windows_kernels.py. A sweep of 2,880 cells (4 platforms, 9 torch minors, CUDA 12 / 13.0 / 13.4 / none, both ABI values, 5 interpreters, GIL and free-threaded) moves exactly 17: the linux_aarch64 and win_arm64 cells above plus NVIDIA's flash-attn on a CUDA 13.0 win_arm64 torch, and none on linux_x86_64 or win_amd64.
  • Linux byte identity: 540 Linux cells (linux_x86_64 and linux_aarch64, 9 torch minors, cu12 / cu13 / none, both ABI values, 5 interpreters) through flash_attn_wheel_url, the causal-conv1d and mamba-ssm resolvers and resolve_wheel_url give the same URLs before and after.
  • The touched suites (test_wheel_utils_windows_kernels.py, test_ssm_runtime.py, test_training_worker_flash_attn.py, test_kernel_install.py, test_flash_attn_install_python_stack.py, test_prebuilt_cuda_wheels.py): 231 + 130 passed. In tests/python and tests/studio/install the same 4 test_rocm_support.py::TestProgressStepCountMatchesTotal cases fail on main and on this branch (uv exits in the test environment); nothing new fails.
  • A windows-2022 install with the Windows wheels on a staging release: a fresh cu130 Python 3.13 install gets flash-attn 2.8.4 and flash_attn_2_cuda imports; unsloth install-kernels causal_conv1d installs the causal-conv1d 1.7.0 wheel and causal_conv1d_cuda imports.
  • The 6 filenames the pipeline builds were checked against the 6 URLs this resolver returns.

Not covered

…ls on Windows

Windows x64 resolves to our win_amd64 builds on prebuilt-wheels-cu13 (upstream
naming, cxx11abiFALSE, cp313, torch 2.13 / 2.14 cu13). Windows on ARM resolves
flash-attn to NVIDIA's Flash-Attention-for-WoA wheel for torch 2.14, pinned by a
#sha256= fragment that uv and pip both verify.

Windows is wheel-only everywhere: no upstream name is ever built (no upstream
release has a Windows asset) and a missing or rejected wheel never falls back to a
PyPI source build. Setup, long-context training, the causal-conv1d fast path and
its lazy hook, SSM inference and install-kernels all take the Windows path;
mamba-ssm on Windows first requires an importable triton. Linux URLs are unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T11:09:29.724544Z d494bca 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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 2cf2df9b83

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

# Conflicts:
#	studio/install_python_stack.py
#	tests/python/test_flash_attn_install_python_stack.py
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: ef5bd25d2a

ℹ️ 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 changed the title Studio: install prebuilt flash-attn, causal-conv1d and mamba-ssm wheels on Windows Studio: install prebuilt flash-attn, causal-conv1d and mamba-ssm wheels on Windows and ARM Oct 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d494bca018

ℹ️ 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 14ad75e into main Oct 11, 2026
@danielhanchen
danielhanchen deleted the win-prebuilt-wheels-studio branch October 11, 2026 12:19
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Oct 20, 2026
Addresses the Windows update hang reported on Reddit ([Reddit r/unsloth:
"Update install
failing"](https://www.reddit.com/r/unsloth/comments/1x7n5jq/update_install_failing/)):
it halves the prebuilt-wheel download and shows that the install is
still running. A slow connection can still take a while.

## Problem

Since unslothai#13262, Studio setup on Windows installs a 427 MB prebuilt
flash-attn wheel at step `6/17 flash-attn`. Users reported that the step
hangs, and one killed it after 30 minutes. Reporters blamed the torchao
fallback warning printed just before the step, but that warning is
unrelated: it prints on every Windows CUDA install.

Our reproduction completed, but slowly and silently. To install a wheel
from a URL, uv normally fetches only the wheel's metadata, using HTTP
range requests. For GitHub release assets those range requests fail, so
uv downloads the whole wheel just to read its metadata, discards it, and
downloads it again to install (related: astral-sh/uv#18998).
`install_wheel` captures uv's output, so the progress bar shows nothing
for the whole 2 x 427 MB. At 256 KiB/s on `windows-latest`, step 6/17
took about 60 minutes
([job](https://github.com/oobabooga/unsloth/actions/runs/38959270916/job/117169940368)).

## Fix

- `install_wheel` (`studio/backend/utils/wheel_utils.py`) supplies the
wheel's metadata to uv up front, so uv skips the metadata fetch and
downloads the wheel once. It writes the package name and version, taken
from the wheel filename, into a `uv.toml` (`[[dependency-metadata]]`) in
a temp dir, and points uv at it with `--project`. uv still installs from
the URL into its own cache, so a later reinstall reuses the cached copy.
The user's and system uv configs still apply, and relative paths such as
`UV_CACHE_DIR` still resolve against the working directory.
- `_ensure_flash_attn` (`studio/install_python_stack.py`) shows that the
install is still running. On a terminal the progress bar shows the
elapsed time; when output is captured, a `still installing flash-attn (N
min)` note is printed each minute.

Every caller of `install_wheel` gets the single download: setup,
`unsloth install-kernels`, the on-demand causal-conv1d / mamba-ssm
installs, and the training worker.

## What the user sees

In a terminal, the progress line now counts up in place, once a second,
until the install finishes:

```
  deps           [=======-------------]  6/17  flash-attn 0:03
```

When output is captured, from the Windows A/B below at 1 MiB/s. The `[
Ns]` prefix is the CI wrapper's elapsed-time stamp.

Before, nothing for 21 minutes:

```
[    18s]   deps           [======--------------]  6/18  dependency overrides
[    22s]                  torch 2.13.0+cu130 detected -- installing torchao==0.18.0 from
[    22s]                  https://download.pytorch.org/whl/cu130
[    22s]                  https://download.pytorch.org/whl/cu130 did not serve torchao==0.18.0 -- retrying
[    22s]                  from the default index; its kernels may be skipped
[ 1,289s]   deps           [=======-------------]  7/18  flash-attn
[ 1,289s]   deps           [========------------]  8/18  Unsloth Studio deps
```

After:

```
[    16s]   deps           [======--------------]  6/18  dependency overrides
[    18s]                  torch 2.13.0+cu130 detected -- installing torchao==0.18.0 from
[    18s]                  https://download.pytorch.org/whl/cu130
[    18s]                  https://download.pytorch.org/whl/cu130 did not serve torchao==0.18.0 -- retrying
[    18s]                  from the default index; its kernels may be skipped
[    81s]   deps           [=======-------------]  7/18  flash-attn
[    81s]                  still installing flash-attn (1 min)
[   141s]                  still installing flash-attn (2 min)
[   201s]                  still installing flash-attn (3 min)
[...]
[   621s]                  still installing flash-attn (10 min)
[   644s]   deps           [========------------]  8/18  Unsloth Studio deps
```

(The update has 18 steps instead of 17 because it adds a base-packages
step. Captured output is block-buffered, so the `7/18` line appears with
the first note.)

## Behavior boundaries

- uv runs as before when a project config would apply from the working
directory (`uv.toml`, or `pyproject.toml` with `[tool.uv`), or when
`UV_PROJECT` selects a project, because pointing `--project` elsewhere
would make uv ignore that config. It also runs as before when
`UV_CONFIG_FILE` or `UV_NO_CONFIG` is set, or when the URL has no
parseable wheel filename.
- The pip fallback is unchanged; pip already downloads once.

## Verification

Windows A/B on `windows-latest`: arm A
([run](https://github.com/oobabooga/unsloth/actions/runs/38972789221))
and two copies of arm B
([run](https://github.com/oobabooga/unsloth/actions/runs/38980373037)).
Each installs with the public one-liner, then runs `unsloth studio
update` twice, with GitHub downloads throttled to 1 MiB/s. Arm B applies
this diff first.

- Cold update: flash-attn and the Studio uv cache are deleted first, so
the update starts like a fresh install.
- Warm update: flash-attn is deleted again but the cache is kept, to
check that a reinstall still reuses uv's cached copy.

| | Cold update | Warm update |
|---|---|---|
| A, before
([job](https://github.com/oobabooga/unsloth/actions/runs/38972789221/job/117214948654))
| 856,182,074 B (2 downloads), 1,314 s, silent | 13,105 B, 44 s |
| B1, this PR
([job](https://github.com/oobabooga/unsloth/actions/runs/38980373037/job/117239567781))
| 428,140,611 B (1 download), 698 s, a note each minute | 6,938 B, 30 s
|
| B2, this PR
([job](https://github.com/oobabooga/unsloth/actions/runs/38980373037/job/117239567498))
| 428,192,144 B (1 download), 667 s, a note each minute | 6,938 B, 40 s
|

In arm B a single `uv --project <temp dir> pip install` process held the
wheel URL. One earlier arm B run of the same code
([job](https://github.com/oobabooga/unsloth/actions/runs/38977254602/job/117229573031))
moved 357 MB and then 428 MB: the download was cut off partway and uv
retried it from the start. It was not the metadata pass, because the
wheel's `METADATA` sits in its last 20 KB.

flash-attn imports afterwards in both arms.

Tests:

- New `studio/backend/tests/test_wheel_download.py` covers when the
metadata file is written and how uv and pip are invoked. It also runs
real uv against a local server that, like GitHub, does not answer range
requests: 2 downloads before, 1 after, none on reinstall, with a
relative `UV_CACHE_DIR` that must stay in the working directory. Another
checks that a project chosen with `UV_PROJECT` still applies its config.
Both pass with uv 0.11.16 and 0.13.1.
- `tests/python/test_install_python_stack.py` covers the progress output
on a terminal and when captured.
- The installer and `wheel_utils` suites pass, and `ruff check` and
`scripts/run_ruff_format.py` are clean.

---------

Co-authored-by: Daniel Han <[email protected]>
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.

1 participant