Repository navigation
Build the prebuilt CUDA 13 kernel wheels for Windows and ARM (win_amd64, linux_aarch64, win_arm64) - #13261
Conversation
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.
…OCM block, verbose ccache stats
…k in the build step
…ATFORM case-insensitively
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 Review: Didn't find any major issues. Hooray! 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". |
…4 CCCL requires it)
…4 path torch uses
|
@codex review |
There was a problem hiding this comment.
💡 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": { |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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". |
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.ymlto build the same set we publish for Linux onprebuilt-wheels-cu13aswin_amd64wheels:flash_attn-2.8.4+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whlcausal_conv1d-1.7.0+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whlmamba_ssm-2.3.2.post1+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whlThe names follow each upstream
setup.py, which copiestorch._C._GLIBCXX_USE_CXX11_ABIinto 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
platformsinput (linux_aarch64,win_arm64); the default dispatch still plans exactly the 12 x86_64 cells: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)PLATFORMStable (linux_x86_64on ubuntu-22.04,win_amd64on windows-2022) and a new allowlistedplatformsdispatch input, default both.os,platform,runner,pytorch_nvcc,smoke_exclude,smoke_extra); a test compares them against the old matrix.gpu_matrixso the self-hosted GPU job only ever gets Linux wheels.parse_wheel_nameaccepts both platforms and reads the version from the filename; the release notes list each platform's torch and Python coverage.sumssubcommand for SHA256SUMS.Windows build steps (warm and build jobs share them)
C:\cudajunction.vcvars64.bat, exported to the job environment, withDISTUTILS_USE_SDK=1andNVCC_APPEND_FLAGS=-D_USE_MATH_DEFINES(MSVC only definesM_LOG2Eand friends with it).PYTORCH_NVCC, which is the only way to cache nvcc under torch's cpp_extension on Windows.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.link.exeis put back in front of Git Bash's coreutilslink.exefor the wheel build.Source patches
patch_mamba_msvc.py: mamba's selective-scan kernels put an#ifndef USE_ROCMblock inside aBOOL_SWITCHmacro 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, likepatch_mamba_cxx20.py.ARM (
linux_aarch64on ubuntu-22.04-arm,win_arm64on windows-11-arm)PLATFORMS; a request with no buildable cell fails. The x86_64 cells are unchanged (test).sbsaapt repository, otherwise the x86_64 steps.prebuilt_wheels_cuda_redist.py: the release manifest is pinned by sha256 and every archive is checked against it. MSVC ARM64 viavcvarsarm64.bat, ccache's windows-aarch64 build (sha-pinned),/Zc:preprocessor(CUDA 13.4's CCCL refuses MSVC's traditional preprocessor), and alib\x64junction tolib\arm64, which is where torch's cpp_extension looks forcudart.lib. torch comes frompypi.nvidia.com/nvtorch_oot.sysconfig.get_platform()), so an emulated x64 Python cannot produce an x64 wheel under an arm64 name, and a newprebuilt_wheels_check_binaries.pyreads each extension's ELF / PE machine field and caps Linux at glibc 2.35.linux_x86_64cells.Sharding fix
prebuilt_wheels_shard.pyonly kept.otargets 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
Scripts/python.exeand removes the CUDA toolkit from PATH, so the extension has to load against torch's own DLLs.triton,tilelang,apache-tvm-ffiandquack-kernelsare left out of the dependency install (none has a Windows wheel at that version) andtriton-windowsis 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
--clobber. A Windows-only publish would have replaced the Linux entries. It now rebuilds SHA256SUMS over every.whlon the release, using GitHub's per-asset digest and hashing any asset without one, and regenerates the notes from the same list.Results
All runs on a staging fork,
publish=false:mamba_ssmandselective_scan_cudaimport with triton-windows, signedflash_attnandflash_attn_2_cudaimport, signedprebuilt-wheels-cu13The first Windows runs are what found the ABI flag,
M_LOG2E, the mamba preprocessor issue, the coreutilslink.exe, andPlatform=x64from vcvars shadowing a step'sPLATFORM(Windows environment names are case-insensitive, bash is not).ARM, on the same staging fork:
causal_conv1d_cuda/selective_scan_cudaimport with mamba's full dependency setTests
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.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.pyupdated for the new defaults. 190 passed in total.gpuself-hosted label warning.Not covered
Release order
Nothing is published by merging this. After it merges, a dispatch with
platforms=win_amd64,linux_aarch64,win_arm64andpublish=trueadds the Windows and ARM wheels toprebuilt-wheels-cu13and leaves the Linux assets in place. The Studio side that installs them is #13262, and the Windows torch 2.13 install route is #13263.