Repository navigation
Prebuilt wheels: drop -lineinfo, unreachable SASS and flash-attn PTX; add extension-free mamba-ssm - #14142
Conversation
…attn PTX causal-conv1d and mamba-ssm build with -lineinfo, which changes no SASS (checked with cuobjdump -sass) and is more than half of every cubin. Their SASS for sm_87, sm_110 and sm_121 targets integrated Arm GPUs, so the x86 wheels drop it while the Arm wheels keep the full list. flash-attn's compute_120 PTX can only JIT for GPUs newer than sm_120, so it goes too. A new targets-gate step checks each built wheel with cuobjdump: every requested SASS present, nothing else, no PTX. Size gates are lowered to the new expected sizes and the ccache tag changes with the target list.
cuobjdump only reads its host's object format, so a Linux cuobjdump reports a Windows .pyd as having no device code, and it names PTX entries sm_XX.ptx, which the compute_XX.ptx pattern never matched. Scan the embedded fatbin containers directly instead: the same answer on ELF and PE, no toolkit binary needed. Checked against cuobjdump on the published flash-attn 2.8.4 Linux wheel (96 x sm_80/90/100/120 SASS plus compute_120 PTX) and on the Windows causal-conv1d wheel (nine SASS targets).
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 review |
|
@codex security review |
|
@codex review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
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". |
Mamba-2 hybrids on transformers 5 only need mamba_ssm's Triton ops plus a causal conv, which unsloth-zoo runs in Triton, so one py3-none-any mamba_ssm wheel (224 KB) serves every torch, Python and OS. Whenever a run builds mamba-ssm, a CPU-only job builds it from the same pin with MAMBA_KEEP_CUDA_BUILD unset, gates it (exact name, no compiled code, pure WHEEL tag), imports the Triton ops from a --no-deps install on Linux and on Windows with triton-windows, and hands it to the existing sign and publish steps. SOURCE_DATE_EPOCH comes from the pinned commit, so rebuilds are byte identical. Runs without mamba-ssm skip it.
|
@codex review |
1 similar comment
|
@codex 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". |
…nsloth-zoo runs their conv on Triton (#14160) Stacked on #13971. Pairs with unslothai/unsloth-zoo#1865 and the extension-free mamba-ssm wheel added in #14142. Mamba-2 hybrids (Nemotron-H, Falcon-H1, Granite-4.0-H, Bamba, Zamba2, Mamba2) install a 224 KB mamba-ssm wheel without its CUDA extension instead of the 230 to 594 MB mamba-ssm + causal-conv1d CUDA wheels, when unsloth-zoo can run their causal conv on Triton. ## Why On transformers 5.x these models only use mamba-ssm's Triton ops, never `selective_scan_cuda`. With unsloth-zoo#1865 the causal conv runs on Triton too. On a Colab T4 (torch 2.10, Falcon-H1-0.5B fp16 LoRA, three interleaved rounds) that route matches the CUDA wheels: train step +1.4% (inside the CUDA arm's own spread), decode +1.7% / +1.9%, prefill +0.7%, identical peak memory. ## Changes - `ssm_runtime.py` / training worker / export: the pure wheel is used, and causal-conv1d skipped, only when the config resolves to one of those six model types, no remote code is needed, torch is a CUDA build with Triton, transformers is 5.15 or newer, and the installed unsloth-zoo source carries the Triton drop-ins. `UNSLOTH_MAMBA_CUDA_KERNELS=1` keeps the CUDA wheels. - No source build on that route. If the pure wheel is unusable (definite 404, install failure, import failure), the load falls back to today's CUDA route (causal-conv1d, then CUDA mamba-ssm with the existing resolver and source build policy). The failure memo is keyed per wheel source, so a failed pure attempt never blocks the CUDA wheel, and both routes take the per-env lock one after the other. - `wheel_utils.mamba_ssm_pure_wheel_url()`. ## Tests `test_ssm_mamba2_triton.py` (24 tests; the fallback ones exercise the real `_install_kernel` with lock, memo and cleanup, only network and pip faked). 509 passed across the clef, export, kernel_install, SSM and training worker suites. Not covered: ROCm and macOS stay on the existing route by design; Windows triton-windows untested on a GPU; Mamba-1 models and transformers older than 5.15 keep the CUDA wheels. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Shrinks the prebuilt causal-conv1d, mamba-ssm and flash-attn wheels further without changing the machine code any GPU runs.
Why
After fatbin compression the wheels are still larger than they need to be:
-lineinfo. It only feeds profilers a source line table;cuobjdump -sassshows identical instructions without it, and it is more than half of every cubin.Changes
.github/scripts/patch_cuda_targets.py: edits each package's setup.py by asserting on exact text (likepatch_mamba_cxx20.py): removes-lineinfo, keeps only the requested SASS, removes flash-attn's PTX line. Unknown or missing targets fail loudly; running it twice is a no-op.prebuilt_wheels.py: x86 wheels keep sm 75;80;90;100;103;120, linux_aarch64 and win_arm64 keep the full upstream list. flash-attn keeps sm 80;90;100;120.targets-gatestep after the size gate reads the fatbin headers in every built.so/.pyd(ELF and PE, no cuobjdump needed): every requested SASS present, nothing else, no PTX. Checked against cuobjdump on the published flash-attn Linux wheel and on the Windows causal-conv1d wheel; both current wheels fail the new gate as expected.Expected sizes (installed, extrapolated from compiled translation units)
Per translation unit (MB, nvcc 13.1, compression on):
Tests
tests/python/test_prebuilt_cuda_wheels_targets.py(new) plus the existing prebuilt suites: 230 passed. The patch was also run against the real pinned setup.py files.After merge, the release needs one republish (Windows torch 2.10 to 2.12, then all platforms for 2.13 / 2.14). A machine code diff of old vs new wheels per kept arch and a T4 / L4 kernel A/B follow the build.
Extension-free mamba-ssm wheel
When a run builds mamba-ssm, a CPU-only job also builds
mamba_ssm-2.3.2.post1-py3-none-any.whlfrom the same pinned commit without its CUDA extension (about 224 KB, one file for every OS / torch / Python). Mamba-2 hybrids need only its Triton ops once unsloth-zoo runs their causal conv on Triton (unslothai/unsloth-zoo#1865); Mamba-1 models keep the CUDA wheel.pure-gate: exact filename, no.so/.pyd/.dll/.dylib,Root-Is-Purelib: true,Tag: py3-none-any, then--no-depsinstall and import ofmamba_ssm,mamba_chunk_scan_combinedandselective_state_updatein a fresh venv; the same import on windows-latest with triton-windows.Measured on real builds (linux_x86_64, cp313, torch 2.13.0+cu130)
Built locally from this branch exactly as the workflow does (nvcc 13.1 here; runners use 13.0):
flash-attn was not built locally (6 to 8 hours); its change is the PTX drop only, checked by the targets-gate in the workflow.