Skip to content

Build the prebuilt CUDA 13 kernel wheels for Windows and ARM (win_amd64, linux_aarch64, win_arm64) - #13261

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

danielhanchen merged 11 commits into
mainfrom
win-prebuilt-wheels-ci

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Windows has never had prebuilt flash-attn, causal-conv1d or mamba-ssm wheels. Dao-AILab/flash-attention, Dao-AILab/causal-conv1d and state-spaces/mamba have published about 9,400 release assets between them and none is a Windows build, so a Windows user's only option has been a multi-hour local compile with MSVC and the CUDA toolkit installed.

This PR extends prebuilt-cuda-wheels.yml to build the same set we publish for Linux on prebuilt-wheels-cu13 as win_amd64 wheels:

Package torch Python Wheel
flash-attn 2.8.4 2.13, 2.14 cp313 flash_attn-2.8.4+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl
causal-conv1d 1.7.0 2.13, 2.14 cp313 causal_conv1d-1.7.0+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl
mamba-ssm 2.3.2.post1 2.13, 2.14 cp313 mamba_ssm-2.3.2.post1+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl

The names follow each upstream setup.py, which copies torch._C._GLIBCXX_USE_CXX11_ABI into the filename. The Windows cu130 torch 2.13 and 2.14 wheels report it as True, and the build asserts that, so the resolver builds the filename the same way on both platforms.

ARM is opt-in through the same platforms input (linux_aarch64, win_arm64); the default dispatch still plans exactly the 12 x86_64 cells:

Platform Packages torch Python
linux_aarch64 flash-attn, causal-conv1d, mamba-ssm 2.13, 2.14 (cu130) cp313
win_arm64 causal-conv1d, mamba-ssm 2.14.0+cu134 (NVIDIA's) cp313, plus cp311 / cp312 on request

Upstream's aarch64 wheels stop at torch 2.10. On Windows on ARM the only CUDA torch is NVIDIA's 2.14.0+cu134, and NVIDIA already publishes flash-attn for it (Studio resolves that one, see #13262), so only the other two are built here.

What changes

Build plan (prebuilt_wheels.py)

  • A PLATFORMS table (linux_x86_64 on ubuntu-22.04, win_amd64 on windows-2022) and a new allowlisted platforms dispatch input, default both.
  • Linux cells are unchanged apart from added keys (os, platform, runner, pytorch_nvcc, smoke_exclude, smoke_extra); a test compares them against the old matrix.
  • A separate gpu_matrix so the self-hosted GPU job only ever gets Linux wheels.
  • parse_wheel_name accepts both platforms and reads the version from the filename; the release notes list each platform's torch and Python coverage.
  • New sums subcommand for SHA256SUMS.

Windows build steps (warm and build jobs share them)

  • CUDA 13.0.2 from NVIDIA's network installer (the same nvcc 13.0.88 the Linux apt package installs), Authenticode-checked for NVIDIA Corporation, explicit subpackages, installed behind a space-free C:\cuda junction.
  • MSVC 14.44 via vswhere and vcvars64.bat, exported to the job environment, with DISTUTILS_USE_SDK=1 and NVCC_APPEND_FLAGS=-D_USE_MATH_DEFINES (MSVC only defines M_LOG2E and friends with it).
  • ccache 4.14.1 pinned by sha256, in front of nvcc through PYTORCH_NVCC, which is the only way to cache nvcc under torch's cpp_extension on Windows.
  • A 16 to 32 GB page file on D: through al-cheb/configure-pagefile-action (pinned by SHA). windows-2022 ships a fixed 2.9 GB page file, which leaves nvcc almost no commit headroom on the sm_100 flash-attn kernels.
  • MSVC's link.exe is put back in front of Git Bash's coreutils link.exe for the wheel build.
  • flash-attn keeps the Linux layout: 8 warm shards per torch minor, then a build job that merges the shards' ccache and links.

Source patches

  • New patch_mamba_msvc.py: mamba's selective-scan kernels put an #ifndef USE_ROCM block inside a BOOL_SWITCH macro argument, which MSVC's preprocessor rejects. The patch keeps the CUDA branch, which is what a CUDA build preprocesses to anyway. It asserts the exact upstream text and is idempotent, like patch_mamba_cxx20.py.

ARM (linux_aarch64 on ubuntu-22.04-arm, win_arm64 on windows-11-arm)

  • Per-platform torch versions, packages and torch index in PLATFORMS; a request with no buildable cell fails. The x86_64 cells are unchanged (test).
  • linux_aarch64: CUDA 13.0 from NVIDIA's sbsa apt repository, otherwise the x86_64 steps.
  • win_arm64: CUDA 13.4, the first toolkit with a Windows ARM64 nvcc, from NVIDIA's redist archives through a new prebuilt_wheels_cuda_redist.py: the release manifest is pinned by sha256 and every archive is checked against it. MSVC ARM64 via vcvarsarm64.bat, ccache's windows-aarch64 build (sha-pinned), /Zc:preprocessor (CUDA 13.4's CCCL refuses MSVC's traditional preprocessor), and a lib\x64 junction to lib\arm64, which is where torch's cpp_extension looks for cudart.lib. torch comes from pypi.nvidia.com/nvtorch_oot.
  • Every build asserts the interpreter platform (sysconfig.get_platform()), so an emulated x64 Python cannot produce an x64 wheel under an arm64 name, and a new prebuilt_wheels_check_binaries.py reads each extension's ELF / PE machine field and caps Linux at glibc 2.35.
  • The self-hosted GPU smoke job only ever gets linux_x86_64 cells.

Sharding fix

  • prebuilt_wheels_shard.py only kept .o targets and split ninja's output on the first colon, so on Windows (D:/...obj) every shard got an empty list, and an empty list made ninja build every target. It now accepts .obj, splits on the last ": ", fails if no objects are found at all, and exits without running ninja for an empty slice.

Smoke test

  • Windows uses the venv's Scripts/python.exe and removes the CUDA toolkit from PATH, so the extension has to load against torch's own DLLs.
  • For mamba-ssm on Windows, triton, tilelang, apache-tvm-ffi and quack-kernels are left out of the dependency install (none has a Windows wheel at that version) and triton-windows is pinned to the torch minor (3.7.1.post27 for 2.13, 3.8.0.post29 for 2.14). mamba_ssm imports its tilelang and CuTe kernels inside try/except, so the package imports with only Triton.

Publishing

  • The publish job no longer uploads the run's own SHA256SUMS with --clobber. A Windows-only publish would have replaced the Linux entries. It now rebuilds SHA256SUMS over every .whl on the release, using GitHub's per-asset digest and hashing any asset without one, and regenerates the notes from the same list.
  • Artifact names and ccache keys carry the platform.

Results

All runs on a staging fork, publish=false:

Run Result
causal-conv1d, win_amd64, torch 2.13 + 2.14 built (about 25 min per cell), imports in a fresh venv, signed
mamba-ssm, win_amd64, torch 2.13 + 2.14 built, mamba_ssm and selective_scan_cuda import with triton-windows, signed
flash-attn, win_amd64, torch 2.13 + 2.14 16 warm shards (about 1 to 2 h each), then the build job: ccache 96 / 96 hits, linked in about 7 min, 427 MB wheel, flash_attn and flash_attn_2_cuda import, signed
all 3 packages, linux_x86_64, torch 2.13 + 2.14 all 16 shards, all 6 builds and signing pass; wheel names identical to the 6 already on prebuilt-wheels-cu13

The first Windows runs are what found the ABI flag, M_LOG2E, the mamba preprocessor issue, the coreutils link.exe, and Platform=x64 from vcvars shadowing a step's PLATFORM (Windows environment names are case-insensitive, bash is not).

ARM, on the same staging fork:

Run Result
causal-conv1d + mamba-ssm, linux_aarch64, torch 2.13 + 2.14 built, nvcc 13.0.88, newest glibc symbol 2.32, causal_conv1d_cuda / selective_scan_cuda import with mamba's full dependency set
causal-conv1d + mamba-ssm, win_arm64, torch 2.14.0+cu134 built with nvcc 13.4.59, imports with the toolkit off PATH (mamba with triton-windows 3.8.0.post29), signed
flash-attn, linux_aarch64, torch 2.13 + 2.14 in progress

Tests

  • tests/python/test_prebuilt_cuda_wheels_windows.py (new, 70 tests): Windows matrix and names, Linux cells unchanged, shard parsing of real Windows ninja targets and the empty-shard guard, the deadline wrapper, SHA256SUMS over the whole release, the mamba MSVC patch against the pinned upstream files, and the workflow wiring.
  • New tests/python/test_prebuilt_cuda_wheels_arm.py (25 tests): ARM cells and names, refused combinations, x86_64 cells unchanged, GPU matrix x86_64-only, the redist installer (pinned manifest, tampered archive, path escape), the binary check against real x64 and ARM headers, and the workflow wiring.
  • tests/python/test_prebuilt_cuda_wheels.py updated for the new defaults. 190 passed in total.
  • actionlint is clean apart from the existing gpu self-hosted label warning.

Not covered

  • CI proves the wheels compile, link and load; it cannot run the kernels, because GitHub's Windows runners have no GPU. A forward pass on a Windows NVIDIA machine is still needed.
  • No ARM GPU runner either: the ARM wheels are proven to build, link against the right architecture and import, not to run kernels.

Release order

Nothing is published by merging this. After it merges, a dispatch with platforms=win_amd64,linux_aarch64,win_arm64 and publish=true adds the Windows and ARM wheels to prebuilt-wheels-cu13 and leaves the Linux assets in place. The Studio side that installs them is #13262, and the Windows torch 2.13 install route is #13263.

Dao-AILab and state-spaces have never published a Windows wheel of
flash-attn, causal-conv1d or mamba-ssm, so prebuilt-cuda-wheels.yml now
builds win_amd64 cells next to the Linux ones, for the same torch 2.13 /
2.14 cu130 and cp313 set.

- prebuilt_wheels.py: PLATFORMS table and an allowlisted `platforms`
  dispatch input. Windows names follow each upstream setup.py
  (`+cu13torch2.13cxx11abiFALSE-cp313-cp313-win_amd64.whl`). Linux cells
  keep every existing value and only gain keys. gpu_matrix keeps the
  self-hosted GPU job on Linux cells. Release notes describe each
  platform; a new `sums` subcommand writes SHA256SUMS.
- prebuilt_wheels_shard.py: understand Windows `.obj` targets with drive
  letters, fail on an empty object inventory, and never run a
  targetless ninja for an empty slice.
- prebuilt_wheels_timeout.py: deadline wrapper that ends the whole
  process tree (taskkill /T on Windows), used by the Windows legs.
- Workflow: warm and build run on the cell's runner. Windows setup uses
  NVIDIA's CUDA 13.0.2 network installer (Authenticode checked, explicit
  subpackages, C:\cuda junction), vcvars64 via vswhere, a sha256-pinned
  ccache, and a memory/disk report. Artifact names and cache keys carry
  the platform. The Windows smoke test hides the toolkit and installs
  triton-windows pinned to the torch minor for mamba-ssm.
- Publish: SHA256SUMS is rebuilt over every wheel on the release, so a
  one-platform publish no longer drops the other platform's entries.
@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:27:31.104855Z d66f7d0 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[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 27f11721c4

ℹ️ 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 Build the prebuilt CUDA 13 kernel wheels for Windows (win_amd64) Build the prebuilt CUDA 13 kernel wheels for Windows and ARM (win_amd64, linux_aarch64, win_arm64) Oct 11, 2026
@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: d66f7d00cc

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

"label": "",
"pytorch_nvcc": "ccache /usr/local/cuda-13.0/bin/nvcc",
},
"win_amd64": {

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 Wire the new platforms into the wheel resolver

Publishing these cells does not make any of the new wheels reachable through the product's installation paths. studio/backend/utils/wheel_utils.py still rejects every platform except linux_x86_64 in unsloth_prebuilt_wheel_url() (line 144), its kernel callers use probe_torch_wheel_env() with the default that rejects win_amd64, and wheel_platform_tag() does not return win_arm64 at all. Consequently Windows x86_64, Linux aarch64, and Windows ARM64 users still fall back to source builds or nonexistent upstream URLs despite these assets being produced; extend those resolver gates using the same platform/package/torch restrictions as this matrix.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is the companion PR, #13262: it extends unsloth_prebuilt_wheel_url to win_amd64, linux_aarch64 and win_arm64 for exactly the cells this matrix builds, opts the kernel callers into the Windows probe, and makes wheel_platform_tag return win_arm64. This PR only builds and publishes, so it can merge and publish before the resolver ships.

Comment on lines +287 to +289
cuda_nvcc libnvvm cuda_crt cuda_cudart cccl cuda_nvtx cuda_profiler_api `
libcublas libcusparse libcusolver libcurand libcufft cuda_nvrtc libnvjitlink `
cuda_cuobjdump cuda_nvdisasm cuda_nvprune

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Install libnvptxcompiler for the ARM64 CUDA compiler

Every win_arm64 build uses this extracted CUDA 13.4 tree, but the component list omits libnvptxcompiler. CUDA 13 split that library out of the NVCC component, and NVIDIA's CUDA 13.4 package metadata lists libnvptxcompiler-13-4 as a direct dependency of cuda-nvcc-13-4 (NVIDIA package metadata). The manifest provides a windows-arm64 archive for it, so add libnvptxcompiler here; otherwise nvcc --version may succeed while the first actual compilation fails because the compiler backend is absent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Checked on the staging run: with this component list the win_arm64 causal-conv1d and mamba-ssm builds compiled every .cu kernel with nvcc 13.4.59, linked, and imported in a fresh venv with the toolkit off PATH. libnvptxcompiler is the static PTX compiler library for applications that embed the nvPTXCompiler API; the nvcc driver calls ptxas and nvlink from cuda_nvcc and never loads it, which is why the Debian dependency does not show up as a build failure here. Leaving the list as is.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d66f7d00cc

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

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