From 11450bcf7b9c97c9c5d55701f2ced53f526f5045 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 4 Jul 2026 04:42:29 +0000 Subject: [PATCH 1/5] Note the bundled flash-linear-attention kernels for gated-deltanet models Unsloth Zoo now bundles the flash-linear-attention (fla) gated-delta Triton kernels and injects them automatically, so gated-deltanet models (Qwen3-Next, Qwen3.5, Kimi-Linear) get the fast path with no pip install. Replace the old install advisory with a one-time note that fires only when the bundled kernels could not be enabled on the current setup (no CUDA, or torch < 2.7 / triton < 3.3), i.e. exactly when transformers falls back to the slow pure PyTorch path. --- unsloth/models/loader.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index 5ba9b54ce1..9c485af1b5 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -206,6 +206,42 @@ DISABLE_COMPILE_MODEL_NAMES = [ "granite,llava_next", # Granite-vision 3 ] +# Architectures with gated-deltanet (linear attention) layers. Unsloth bundles the +# flash-linear-attention (fla) Triton kernels (unsloth_zoo/_vendored/fla) and injects +# them automatically, so no `pip install flash-linear-attention` is needed. Transformers +# only falls back to the several-times-slower pure PyTorch path when those bundled kernels +# cannot be enabled on the current setup. +FLA_MODEL_TYPE_PREFIXES = ("qwen3_next", "qwen3_5", "kimi_linear") +_fla_advised = False + + +def _maybe_advise_fla_install(model_types): + """One-time note when a gated-deltanet model loads without the fast kernels. + + The kernels ship with Unsloth (no install needed); this fires only when they + could not be enabled on this platform (e.g. no CUDA, torch < 2.7 or + triton < 3.3), i.e. exactly when transformers uses the slow pure PyTorch path. + """ + global _fla_advised + if _fla_advised: + return + try: + if not any( + isinstance(t, str) and t.startswith(FLA_MODEL_TYPE_PREFIXES) for t in model_types + ): + return + from transformers.utils.import_utils import is_flash_linear_attention_available + if is_flash_linear_attention_available(): + return # bundled (or user-installed) fast kernels are active + except Exception: + return + _fla_advised = True + print( + "Unsloth: This model uses gated-deltanet linear attention layers. Unsloth\n" + "bundles the flash-linear-attention kernels, but they could not be enabled\n" + "on this setup (they need CUDA with torch >= 2.7 and triton >= 3.3), so\n" + "transformers will use a slower pure PyTorch path." + ) def _fix_rope_inv_freq(model): """Fix inv_freq corruption caused by transformers v5 meta-device loading. @@ -1304,6 +1340,7 @@ class FastModel(FastBaseModel): trust_remote_code = trust_remote_code, ) model_types_all = ",".join(model_types) + "," + _maybe_advise_fla_install(model_types) # ---- Text-diffusion models (e.g. DiffusionGemma) take a transformers-only slow path. ---- # These use a custom block-diffusion `generate` and a novel backbone, so we skip Unsloth's From f8b28b00241f69fcbcd47892dec7adc5f0f7ba6c Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 4 Jul 2026 12:57:50 +0000 Subject: [PATCH 2/5] Tighten comments --- unsloth/models/loader.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index 9c485af1b5..d60a3f02bd 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -207,10 +207,8 @@ DISABLE_COMPILE_MODEL_NAMES = [ ] # Architectures with gated-deltanet (linear attention) layers. Unsloth bundles the -# flash-linear-attention (fla) Triton kernels (unsloth_zoo/_vendored/fla) and injects -# them automatically, so no `pip install flash-linear-attention` is needed. Transformers -# only falls back to the several-times-slower pure PyTorch path when those bundled kernels -# cannot be enabled on the current setup. +# flash-linear-attention Triton kernels (unsloth_zoo/_vendored/fla), so no install is +# needed; transformers uses the much slower pure PyTorch path only when they can't be enabled. FLA_MODEL_TYPE_PREFIXES = ("qwen3_next", "qwen3_5", "kimi_linear") _fla_advised = False From a7d453175ae7a00e8082d3598283686e04a76c3d Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 4 Jul 2026 13:37:55 +0000 Subject: [PATCH 3/5] Normalize model_types in fla install advisory for None and single string --- unsloth/models/loader.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index d60a3f02bd..cd4c13aff5 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -223,6 +223,10 @@ def _maybe_advise_fla_install(model_types): global _fla_advised if _fla_advised: return + if model_types is None: + return + if isinstance(model_types, str): + model_types = [model_types] # a lone string would otherwise iterate chars try: if not any( isinstance(t, str) and t.startswith(FLA_MODEL_TYPE_PREFIXES) for t in model_types From bf974da5cd248ad52d15b62bb1636c00a204bd42 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 5 Jul 2026 00:44:18 +0000 Subject: [PATCH 4/5] Cover olmo_hybrid in the gated-deltanet fla advisory --- unsloth/models/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index cd4c13aff5..ba23197861 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -209,7 +209,7 @@ DISABLE_COMPILE_MODEL_NAMES = [ # Architectures with gated-deltanet (linear attention) layers. Unsloth bundles the # flash-linear-attention Triton kernels (unsloth_zoo/_vendored/fla), so no install is # needed; transformers uses the much slower pure PyTorch path only when they can't be enabled. -FLA_MODEL_TYPE_PREFIXES = ("qwen3_next", "qwen3_5", "kimi_linear") +FLA_MODEL_TYPE_PREFIXES = ("qwen3_next", "qwen3_5", "kimi_linear", "olmo_hybrid") _fla_advised = False From ceaa706efa99de20fab812f4e061907d07ca3e0c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jul 2026 12:50:39 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unsloth/models/loader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index ba23197861..a56638837f 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -245,6 +245,7 @@ def _maybe_advise_fla_install(model_types): "transformers will use a slower pure PyTorch path." ) + def _fix_rope_inv_freq(model): """Fix inv_freq corruption caused by transformers v5 meta-device loading.