Skip to content

Studio: skip causal-conv1d for Qwen3.5 / 3.6 / Qwen3-Next when unsloth-zoo covers decode - #14148

Merged
danielhanchen merged 33 commits into
mainfrom
gdn-no-causal-conv1d
Oct 20, 2026
Merged

danielhanchen merged 33 commits into
mainfrom
gdn-no-causal-conv1d

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Stacked on #13971. Pairs with unslothai/unsloth-zoo#1857.

Qwen3.5 / Qwen3.6 / Qwen3-Next stop downloading causal-conv1d on demand when the installed unsloth-zoo runs their short conv in Triton for prefill, training and cached decode.

Why

unsloth-zoo#1857 adds a Triton causal_conv1d_update for GatedDeltaNet decode (the prefill / training conv was already Triton). On a Kaggle T4 (Qwen3.5-0.8B fp16) decode with it is within noise of the causal-conv1d package (19.79 vs 19.64 and 19.47 vs 19.20 tok/s, two lanes) at 16.5 us per call against 46-48 us for the package, with identical memory and tokens. The binary is then pure download cost for these models.

Changes

  • ssm_runtime.py: Qwen3.5 / 3.6 / Qwen3-Next request causal-conv1d only when zoo cannot cover them: the installed zoo lacks the decode kernel (read from its source on sys.path, nothing imported), UNSLOTH_DISABLE_TRITON_CAUSAL_CONV1D=1 is set, or the platform cannot run zoo's Triton conv (ROCm, macOS, no triton). The config check runs before the modeling source scan, since those modeling files mention causal_conv1d. Mixed configs and other conv users (LFM2, the Mamba families) still request it.
  • clef_runtime.py: Clef skips the install the same way and keeps the FLA TileLang guard.
  • An already installed causal-conv1d is left alone and still wins inside zoo.

Tests

test_ssm_runtime.py, test_clef_fast_paths.py (new cases fail on #13971's head and pass here), with conftest.py pinning the older-zoo answer so the suite does not depend on the host's zoo. 453 passed across the SSM, clef, export, training worker and install stack tests.

…rovision SSM kernels in export

- Request causal-conv1d on demand again for Qwen3.5/3.6/Qwen3-Next in training, inference and Clef
- mamba-ssm stays required only for nemotron_h, falcon_h1 and granitemoehybrid; newer SSM families continue on the torch path
- Resolve local adapter bases and the adapter base pin before deciding kernels
- Export worker provisions SSM kernels before importing Unsloth
- Inference re-reads modeling sources without importing transformers and respawns the worker once after a fresh install
- Setup removes causal-conv1d / mamba-ssm builds that no longer import after a torch change
- Skip flash-attn downloads below sm80 at setup and for long-context training
- Stale kernel removal needs proof: torch imports, then the extension import completes with an
  ImportError / OSError; a broken torch, a signal, a hang or an unrelated exit keeps the kernel
- unsloth install-kernels --without-gpu (or UNSLOTH_INSTALL_KERNELS_WITHOUT_GPU=1) provisions
  GPU-gated kernels in a GPU-less image build; skipped kernels are listed, and a named kernel
  that was skipped exits non-zero
- Inference respawn never spawns over a worker that survived shutdown
- SSM restart and Xet fallback each get their own one-use retry, at most three spawns, with an
  accurate stall message
- Restart only for imported modeling modules, including the selected remote-code model's
- Export skips SSM provisioning on macOS, MLX and CPU
- UV_OFFLINE counts as offline for on-demand kernel installs
- Long-context flash-attn: no probe when already importable, reuse the worker's torch, never
  apply the sm80 floor on ROCm
… matching

- install-kernels checks an already-working extension before the wheel, GPU and offline skips
  (a ROCm source build or a GPU-hidden builder's install is success); skipped kernels are listed
  and exit 0 as before, --strict opts into exit 2
- install-kernels installs nothing offline (UV_OFFLINE, HF_HUB_OFFLINE, TRANSFORMERS_OFFLINE), and
  install_wheel never falls back from an offline uv to pip
- Restart detection takes the implementation modules from the config's auto_map (any module
  name) and matches transformers_modules.<checkpoint namespace> exactly, both spellings
- Export decides the CPU / MLX / macOS bypass before the connectivity window
… up, lock

- A wheel whose HEAD check is unanswered is still downloaded and verified (as setup did); only a
  real download / import failure falls back, in inference, export and training
- A failed install is not retried in the same process (keyed by kernel, torch and toolchain), so
  a load's preflight and _handle_load share one attempt; configs are read once per process
- Optional mamba-ssm families (mamba, mamba2, falcon_mamba, jamba, zamba, zamba2, bamba) get a
  prebuilt wheel only, never a source build, and are skipped below setup's sm80 / sm75 + Triton
  3.4 floor; Nemotron-H, Falcon-H1 and Granite-4.0-H keep the source fallback and no floor
- CUDA source builds get the 1800 s deadline ROCm had, and a timeout stops the whole build tree
- A failed runtime install removes the distribution whose extension does not import
- One cross-process lock per kernel and environment covers precheck, install, verify and cleanup,
  rechecks after acquiring, reports while waiting and gives up after a bound
- Only a CUDA or ROCm torch provisions kernels; export provisions only for a CUDA / ROCm backend
…source builds

- The Unsloth prebuilt resolver answers only for (platform, torch, interpreter) cells the release
  carries: torch 2.13 / 2.14 are cp313 on every platform, so linux_x86_64 cp310-cp312 and
  win_arm64 cp311 / cp312 no longer get a URL that 404s; no upstream URL for torch 2.13+ either
- No source build of the pinned causal-conv1d 1.6.1 / mamba-ssm 2.3.1 on torch 2.13+ (C++17
  sources against C++20 torch headers): the prebuilt wheel or the torch path, in inference,
  export and training
- Training stops with the inference error when Nemotron-H, Falcon-H1 or Granite-4.0-H cannot get
  mamba-ssm on a CUDA / ROCm torch, including Windows without triton-windows
- The MLX training-worker test stubs the wheel_utils names the worker now imports
The pinned upstream releases (causal-conv1d v1.6.1.post4, mamba-ssm v2.3.1) publish CUDA 11 / 12
/ 13 Linux wheels for a fixed set of torch minors and cp310-cp313 only; CUDA 13 before torch 2.9,
aarch64 before 2.7 and abiFALSE after 2.6 were URLs that 404 in front of the source fallback.
The cells are now a table read from the two asset lists, and a test ties every URL the resolver
can emit to it.
Nemotron-H, Falcon-H1 and Granite-4.0-H keep the source fallback, but a failed install or a
Windows torch without triton-windows no longer stops the run: their native transformers path can
run without mamba-ssm, so training reports it and continues, as it did before.
Nemotron-H, Falcon-H1 and Granite-4.0-H still try mamba-ssm first (source build included), but a
failed install now refuses the chat or export load only when that load imports code that cannot
run without it: remote modeling code (auto_map, under trust_remote_code or with no native class)
that imports mamba_ssm unconditionally, or a model type the installed transformers has no native
implementation of. Their native transformers models run without it, so otherwise the load goes
ahead on the torch path with a warning, as before #13861 (a Nemotron-H checkpoint on Windows
ROCm was refused).
…nel builds

- Training's eager causal-conv1d install and its fast-path hook share the runtime's failed-attempt
  memo (same key), so a failed CUDA / HIP build is never repeated in one worker
- Only successful config reads are cached; a miss is read again next time
- A kernel a peer installed while this worker waited counts as new here, so inference refreshes
  or restarts its already-imported modeling modules
- The install lock lives beside the environment (else one per environment in the temp folder),
  and every mutating entry point takes it: Studio workers, setup's stale-kernel removal and
  unsloth install-kernels. A lock that cannot be opened or taken skips the install instead of
  racing unguarded; optional accelerations wait at most 120 s for a peer, required ones 2400 s
- Force-terminating a training run first stops the processes its worker started, including a
  source build in its own session
- A runtime install whose installer cannot even start still removes a broken copy and is
  remembered as failed
- Tests never take the environment's real install locks
…amba / Zamba / Bamba

_ensure_mamba_ssm defaulted essential to True, so a caller that left it out (the ROCm hardware
probe on gfx1151) compiled mamba-ssm from source for a Mamba2 model for 60 s. Unspecified now
means the name decides: only Nemotron-H, Falcon-H1 and Granite-4.0-H may build it.
…n CUDA build deadline

- Export worker: run the malware and remote-code consent gates (transformers-free,
  no load-subdir scan) before provisioning SSM kernels, at startup and on each
  "load" command, so a blocked checkpoint never triggers a kernel build.
  _handle_load keeps its authoritative re-check through the shared helper.
- Export offline window: mark an HF offline set only because the Hub was
  unreachable; package_installs_offline() and package_installs_offline_env()
  then honour only UV_OFFLINE, so required kernels can still come from GitHub /
  PyPI. An operator-set HF offline still blocks installs.
- install_python_stack: re-probe a stale SSM extension while holding the kernel
  install lock and remove it only if it still fails the same way.
- unsloth install-kernels --dry-run prints the wheel URL even offline.
- ssm_runtime: a model that cannot load without mamba-ssm now fails clearly on a
  CPU / XPU torch instead of falling through to a torch path that cannot work.
- CUDA source builds get their own 7200 s deadline (UNSLOTH_SOURCE_BUILD_TIMEOUT
  overrides); HIP keeps 1800 s; KERNEL_LOCK_WAIT covers the longer of the two.
…h-zoo covers decode

unsloth-zoo now runs the GatedDeltaNet short conv in Triton for prefill, training and cached
decode (causal_conv1d_update), so these models no longer need the causal-conv1d binary on a
CUDA torch with Triton. The request comes back when the installed zoo lacks the decode kernel
(read from its source, nothing imported), the zoo kill switch is set, or the platform cannot run
Triton (ROCm, macOS, no triton). Clef skips the install the same way.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 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 ⚠️ Failed 2026-10-20T11:20:51.344902Z 3f84ebd New commits
🔒 Security Review ⚠️ Failed 2026-10-18T18:07:11.544449Z 54ae857 PR opened
ℹ️ 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 54ae857456

ℹ️ 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 commented Oct 18, 2026 •

Copy link
Copy Markdown
Member Author

Most of the red here comes from the base branch, not from this PR's own diff. This PR targets studio-ssm-on-demand-followups (#13971), and the base it ran against (7c90c5bd) fails the loader lint by itself:

tests/security/test_lint_risky_loaders.py::test_the_tree_matches_the_baseline
AssertionError: 1 risky loader call site(s) not in the baseline:
    studio/backend/core/export/worker.py:330  [trust-remote-code] keyword

studio/backend/core/export/worker.py is not in this PR's diff. The new trust_remote_code call site comes from #13971's export changes (gate exports before SSM kernels). On main the same test gives 46 passed. That one finding is what fails Repo tests (CPU, rest), the Workflow guard suites step of workflow-trigger lint, and the No new risky loader call sites step of Source lint.

The fix belongs on #13971. Either:

  • add the call site to the risky-loader baseline with the consent gate it sits behind as the reason, or
  • route the load through the existing consent-checked helper so the lint sees it as covered.

This PR should go green once its base carries that.

Separately, Repo tests (CPU, studio) fails on test_diffusion_capability_labeled_image_video_gen. That test went stale on main after #14083 and was fixed there by #14138. The studio-ssm-on-demand-followups branch does not have that fix yet, so merging main into #13971 clears it here too.

Base automatically changed from studio-ssm-on-demand-followups to main October 19, 2026 11:32
@danielhanchen
danielhanchen merged commit 670d9b8 into main Oct 20, 2026
@danielhanchen
danielhanchen deleted the gdn-no-causal-conv1d branch October 20, 2026 15:00
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