Repository navigation
Studio: Windows torch 2.12 kernels from our prebuilt wheels - #13808
Merged
Merged
Conversation
Windows installs on torch 2.12 (cu130) got no flash-attn, causal-conv1d or mamba-ssm wheel: Linux reuses upstream's torch2.10 wheels on 2.12, and those are Linux only. Point win_amd64 torch 2.12 on Python 3.11-3.13 at the prebuilt-wheels-cu13 release, like 2.10 and 2.11.
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. |
danielhanchen
added a commit
that referenced
this pull request
Oct 19, 2026
… provision SSM kernels in export (#13971) Follow up to #13861 and #13808. An audit of the merged on demand SSM kernel change plus a T4 benchmark found a few gaps, fixed here. ## Why - On a Kaggle T4 (sm75, torch 2.11 cu130, fp16, Qwen3.5-0.8B), Studio chat decode was 4.4% slower without causal-conv1d (19.10 vs 19.95 tok/s, 6 alternating repeats, slower in all 9 pairs). Training speed, losses and peak memory were unchanged. The zoo Triton conv covers `causal_conv1d_fn` only, so single token decode fell back to the torch update path. Training with trainable conv weights also allocates an fp32 dW scratch in the Triton backward, and packed `seq_idx` is not accepted by the zoo dispatcher under transformers 5.20. - Mamba-family models that have a working transformers torch path (mamba, mamba2, falcon_mamba, jamba, zamba, zamba2, bamba) were made fatal when mamba-ssm could not be installed. - Export, local LoRA continuation, and inference model switching did not provision or pick up kernels correctly once setup stopped installing them. - Setup on pre-Ampere GPUs (T4) downloaded flash-attn even though Unsloth only enables FA2 at sm80+. ## Changes 1. Qwen3.5 / Qwen3.6 / Qwen3-Next request causal-conv1d on demand again in training, inference and Clef (same as before #13861, minus the setup time install). The zoo Triton platform probe is removed. 2. A missing mamba-ssm is fatal only for `nemotron_h`, `falcon_h1`, `granitemoehybrid`. Other Mamba families install best effort and continue on the torch path with a status message. 3. Local LoRA folders (`adapter_config.json`, no `config.json`) resolve kernel needs from `base_model_name_or_path`; the training `adapter_base_pin` wins when set. 4. The export worker provisions SSM kernels before importing Unsloth / the export backend, with the same required vs optional split. 5. Inference re-enables the modeling source scan by reading `transformers/models/<type>/modeling_*.py` as text, without importing transformers. 6. If a kernel is newly installed after the model's `transformers.models.<type>` module was already imported, the inference worker asks for a restart and the orchestrator respawns it once. 7. Torch repair removes causal-conv1d / mamba-ssm whose compiled extension no longer imports (never installs anything new). A hung import check keeps the package. 8. Setup and the long context runtime install skip flash-attn below sm80 (and remove a stale copy at setup). No visible GPU and ROCm keep current behavior. ## Tests New and updated tests fail on main and pass here (`test_ssm_runtime.py`, `test_ssm_restart_respawn.py`, `test_export_ssm_kernels.py`, `test_clef_fast_paths.py`, `test_kernel_install.py`, `test_training_worker_flash_attn.py`, `test_ssm_kernels_install_python_stack.py`, `test_flash_attn_install_python_stack.py`, `test_windows_torch_flavor_invariant.py`). With `test_install_python_stack.py` and `test_cuda_repair.py`: 966 passed after merging current main. ## Hardening (second commit) - Stale SSM kernel removal after torch repair needs proof: torch must import first, and only an ImportError / OSError from the extension itself removes the package. Signals, hangs, launch errors and a broken torch keep it. - `unsloth install-kernels --without-gpu` (or `UNSLOTH_INSTALL_KERNELS_WITHOUT_GPU=1`) installs GPU gated kernels on a GPU-less image builder. An already working kernel counts as success before any skip, skipped kernels are listed, and the exit code is unchanged (0) unless `--strict` is passed. The CLI respects `UV_OFFLINE` / HF offline variables and never falls back from uv to pip offline. - Inference respawn refuses to spawn while the old worker survives shutdown. SSM restart and the Xet fallback each get their own one-use retry (3 spawns max). - Restart detection only counts native `modeling_*` modules and the selected checkpoint's remote code modules from its `auto_map`, matched on the exact `transformers_modules` namespace. - Export provisions SSM kernels inside the existing transformers activation window (no extra Hub reachability probe), and skips provisioning on macOS and for the MLX / CPU export backends. - `UV_OFFLINE` counts as offline for on-demand installs (no URL probes, source builds, or uv to pip fallback). - Long context flash-attn install returns early when flash_attn already imports, reuses the worker's own torch for the capability check, and never applies the sm80 floor on ROCm. ## Install robustness (platform matrix review) - A wheel is downloaded whenever its HEAD check is not a definite 404 (proxies that refuse HEAD no longer push required hybrids into a failure), then import-verified; fallback only after a real failure. - A failed install is remembered for the worker process (keyed by kernel, torch, toolchain), so preflight and load share one attempt. Optional Mamba families get mamba-ssm only as a prebuilt wheel, never a source build. ROCm source builds get an 1800 s deadline and CUDA source builds 7200 s (`UNSLOTH_SOURCE_BUILD_TIMEOUT` overrides); a timeout kills the whole build tree. - A runtime install whose extension does not import is uninstalled, so transformers never finds a broken package. - One cross-process lock per kernel and environment covers check, install, verify and cleanup (training and runtime), with a recheck after acquiring it. - Only a CUDA or ROCm torch provisions anything; CPU, XPU, MPS and unknown torch builds skip (export included). - Optional mamba-ssm follows setup's sm80 floor (sm75 with Triton 3.4+); the required hybrids keep the previous behavior. - The resolver only returns URLs for cells that are actually published (Unsloth release: torch 2.13/2.14 cp313, win_amd64 torch 2.10 to 2.12 cp311 to cp313; upstream causal-conv1d / mamba-ssm release cells), and there is no source build of the pinned 1.6.1 / 2.3.1 sources on torch 2.13+, which need C++20. - Training stays best effort for mamba-ssm, as before #13861. - Export runs the malware and remote code consent gates before any kernel provisioning. - The extension is probed again after the install lock is acquired, so a concurrent replacement is not treated as broken. - The automatic HF offline window (Hub unreachable) no longer blocks package installs; only user set offline variables do. - `unsloth install-kernels --dry-run` prints the resolved URL while offline. - A Mamba model whose code needs mamba-ssm fails with a clear error on a torch build without CUDA or ROCm. ## GPU checks (merge base vs head 4a6429a) Kaggle T4, torch 2.11.0+cu130, Qwen3.5-0.8B fp16: | | base | head | |---|---|---| | causal-conv1d on demand | not installed | installed, `causal_conv1d_update_kernel` engaged | | decode tok/s (6 alternating repeats) | 18.70 | 19.41 (+3.8%, 6/6 pairs) | | decode peak alloc | 1.748 GB | 1.748 GB | | LoRA step time (3 repeats) | 1975.5 ms | 1970.7 ms (inside spread) | | LoRA peak alloc | 2.338 GB | 2.338 GB | | flash-attn at setup on sm75 | downloaded | skipped | AMD gfx1151 (torch 2.11.0+rocm7.13.0): Qwen3.5 LoRA losses within 1.2e-4 relative (head vs merge commit bit identical), peak 2.389 GB both, backend suites 262/262 and 275/275 passing. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Studio on Windows x64 with torch 2.12 now installs flash-attn, causal-conv1d and mamba-ssm from our prebuilt wheels, as it does for 2.10 and 2.11.
Follows #13807 (the workflow change that builds them). Merge after the torch 2.12
win_amd64wheels are published onprebuilt-wheels-cu13; before that, these URLs would 404.What changes
studio/backend/utils/wheel_utils.py:("win_amd64", "2.12")joins the extra published cells, for cp311, cp312 and cp313, e.g.flash_attn-2.8.4+cu13torch2.12cxx11abiTRUE-cp312-cp312-win_amd64.whl.Unchanged: Linux 2.12 keeps reusing upstream's torch 2.10 wheels; Windows 2.10 / 2.11 / 2.13 / 2.14 as before; Windows 2.9, CUDA 12 builds, free-threaded builds, other interpreters and
win_arm64resolve to nothing.Tests
The cases that used Windows 2.12 as "no wheel" move to 2.9; Windows 2.12 resolution for each interpreter and kernel, plus
kernel_install; the workflow/resolver agreement check covers all 27 extra cells. The resolver, kernel_install and prebuilt wheel test files pass (388).