Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Fix main's red CI after #13806, #13899 and recent formatter drift (#13909)
Daniel Han5e5511027887
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex 67c9a52b55f..9bbe43eea85 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -19754,7 +19754,10 @@ class LlamaCppBackend:self._feed_forward_length = max(self._feed_forward_length_by_layer)- elif attr in ("expert_used_count", "expert_feed_forward_length") and val_a:+ elif (+ attr in ("expert_used_count", "expert_feed_forward_length")+ and val_a+ ):# Per-layer on Nemotron 3.5 Bolt; the widest layer sizes the graph.setattr(self, f"_{attr}", max(int(x) for x in val_a))else:diff --git a/studio/backend/core/inference/offload_layout.py b/studio/backend/core/inference/offload_layout.pyindex f6cdd42fd06..9d36726fa61 100644--- a/studio/backend/core/inference/offload_layout.py+++ b/studio/backend/core/inference/offload_layout.py@@ -223,7 +223,11 @@ def _layout_from_readers(readers) -> ModelLayout:# with neither attention nor an FFN; the rest are dense or MoE FFN blocks.heads = [int(h) for h in list(n_kv_head)[:n_layers]]ffn = _field(reader, f"{arch}.feed_forward_length")- ffn = [int(f) for f in list(ffn)[:n_layers]] if isinstance(ffn, (list, tuple)) else [0] * len(heads)+ ffn = (+ [int(f) for f in list(ffn)[:n_layers]]+ if isinstance(ffn, (list, tuple))+ else [0] * len(heads)+ )n_attention = sum(1 for h in heads if h > 0)n_recurrent = sum(1 for h, f in zip(heads, ffn) if h == 0 and f == 0)kv_per_token = sum(heads) * (int(key_len) + int(val_len)) * 2@@ -249,7 +253,9 @@ def _layout_from_readers(readers) -> ModelLayout:n_expert = int(_field(reader, f"{arch}.expert_count") or 0)n_expert_used = _field(reader, f"{arch}.expert_used_count") or 0if nemotron_h and isinstance(n_expert_used, (list, tuple)):- n_expert_used = max((int(n) for n in n_expert_used), default = 0) # per layer on Nemotron 3.5 Bolt+ n_expert_used = max(+ (int(n) for n in n_expert_used), default = 0+ ) # per layer on Nemotron 3.5 Boltn_expert_used = int(n_expert_used)is_moe = bool(n_expert)diff --git a/studio/backend/core/training/drafter.py b/studio/backend/core/training/drafter.pyindex 104eb65015a..83431df3a09 100644--- a/studio/backend/core/training/drafter.py+++ b/studio/backend/core/training/drafter.py@@ -215,6 +215,8 @@ def _probe_capability(model_name: str, hf_token, key) -> dict:env = dict(os.environ)env[_TOKEN_ENV] = "0" if hf_token is False else (hf_token or "")+ # The parent decodes as UTF-8 below, so the child has to write it on every locale.+ env["PYTHONIOENCODING"] = "utf-8"# Every Hub read in the child (config, tensor index) then runs as exactly this caller.apply_token_to_child_env(env, hf_token)result = None@@ -225,6 +227,8 @@ def _probe_capability(model_name: str, hf_token, key) -> dict:env = env,capture_output = True,text = True,+ encoding = "utf-8",+ errors = "replace",timeout = 300,)for line in proc.stdout.splitlines():diff --git a/studio/backend/tests/test_muse_spark.py b/studio/backend/tests/test_muse_spark.pyindex 1ab85d3e467..166d927a588 100644--- a/studio/backend/tests/test_muse_spark.py+++ b/studio/backend/tests/test_muse_spark.py@@ -33,12 +33,17 @@ REPO = "unsloth/Muse-Spark-Open-816B-A42B-GGUF"STEM = "Muse-Spark-Open-816B-A42B"# Shard counts as published._SPLITS = {- "UD-IQ1_S": 5, "UD-IQ1_M": 6, "UD-IQ2_XXS": 6, "UD-IQ2_S": 7,- "UD-IQ3_XXS": 8, "UD-Q2_K_XL": 8, "UD-Q3_K_XL": 10, "UD-Q4_K_XL": 12,+ "UD-IQ1_S": 5,+ "UD-IQ1_M": 6,+ "UD-IQ2_XXS": 6,+ "UD-IQ2_S": 7,+ "UD-IQ3_XXS": 8,+ "UD-Q2_K_XL": 8,+ "UD-Q3_K_XL": 10,+ "UD-Q4_K_XL": 12,}FILES = [".gitattributes", "LICENSE.md", "README.md", "USE_POLICY.md", "imatrix_unsloth.gguf"] + [- f"{q}/{STEM}-{q}-{i:05d}-of-{n:05d}.gguf"- for q, n in _SPLITS.items() for i in range(1, n + 1)+ f"{q}/{STEM}-{q}-{i:05d}-of-{n:05d}.gguf" for q, n in _SPLITS.items() for i in range(1, n + 1)]@@ -73,7 +78,6 @@ MUSE_SPARK_IDS = [@pytest.mark.parametrize("model_id", MUSE_SPARK_IDS)def test_every_id_shape_resolves_to_published_sampling(model_id):from utils.inference.inference_config import load_inference_config-config = load_inference_config(model_id)for key, want in EXPECTED_SAMPLING.items():assert config[key] == want, f"{model_id}: {key} was {config[key]}, expected {want}"@@ -110,7 +114,8 @@ def test_variant_menu_lists_exactly_the_eight_quants(monkeypatch):from utils.models import model_configmonkeypatch.setattr(- model_config, "_hub_model_info_slow_link",+ model_config,+ "_hub_model_info_slow_link",lambda repo, token, files_metadata = True: _model_info(FILES),)variants, has_vision = model_config.list_gguf_variants(REPO)@@ -135,7 +140,10 @@ def test_every_quant_resolves_to_its_first_shard_and_siblings(monkeypatch, quantdef test_imatrix_is_never_picked_as_the_model(tmp_path):from utils.models import model_config- assert model_config._pick_best_gguf([f for f in FILES if f.endswith(".gguf")]) != "imatrix_unsloth.gguf"+ assert (+ model_config._pick_best_gguf([f for f in FILES if f.endswith(".gguf")])+ != "imatrix_unsloth.gguf"+ )(tmp_path / "imatrix_unsloth.gguf").write_bytes(b"GGUF")assert model_config.detect_gguf_model(str(tmp_path / "imatrix_unsloth.gguf")) is Noneassert model_config.detect_gguf_model(str(tmp_path)) is Nonediff --git a/studio/backend/tests/test_nemotron35_bolt_super.py b/studio/backend/tests/test_nemotron35_bolt_super.pyindex 48d97cd4cfa..0acaf9282ae 100644--- a/studio/backend/tests/test_nemotron35_bolt_super.py+++ b/studio/backend/tests/test_nemotron35_bolt_super.py@@ -35,20 +35,39 @@ for _p in (_backend_root, _tests_dir):SUPER_REPO = "unsloth/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-GGUF"SUPER = "NVIDIA-Nemotron-3.5-Super-VL-120B-A12B"_SUPER_SPLITS = {- "NVFP4": 3, "Q8_0": 4, "UD-IQ1_M": 2, "UD-IQ2_M": 3, "UD-IQ2_XXS": 3, "UD-IQ3_XXS": 3,- "UD-Q2_K_XL": 3, "UD-Q3_K_XL": 3, "UD-Q4_K_XL": 3, "UD-Q5_K_XL": 4, "UD-Q6_K_XL": 4,+ "NVFP4": 3,+ "Q8_0": 4,+ "UD-IQ1_M": 2,+ "UD-IQ2_M": 3,+ "UD-IQ2_XXS": 3,+ "UD-IQ3_XXS": 3,+ "UD-Q2_K_XL": 3,+ "UD-Q3_K_XL": 3,+ "UD-Q4_K_XL": 3,+ "UD-Q5_K_XL": 4,+ "UD-Q6_K_XL": 4,}-SUPER_FILES = [".gitattributes", "README.md", "mmproj-BF16.gguf",- f"LiLiCorr/lilicorr-{SUPER}-NVFP4.gguf"] + [+SUPER_FILES = [+ ".gitattributes",+ "README.md",+ "mmproj-BF16.gguf",+ f"LiLiCorr/lilicorr-{SUPER}-NVFP4.gguf",+] + [f"{q}/{SUPER}-{q}-{i:05d}-of-{n:05d}.gguf"- for q, n in _SUPER_SPLITS.items() for i in range(1, n + 1)+ for q, n in _SUPER_SPLITS.items()+ for i in range(1, n + 1)]BOLT_REPO = "unsloth/NVIDIA-Nemotron-3.5-Bolt-74B-A9B-GGUF"BOLT = "NVIDIA-Nemotron-3.5-Bolt-74B-A9B"# NVIDIA's QAD IQ2_XXS, its LiLiCorr drafter (GGUF arch dflash, named for llama.cpp's dflash- sibling lookup) and mmproj.-BOLT_FILES = [".gitattributes", "README.md", "mmproj-BF16.gguf", f"{BOLT}-IQ2_XXS.gguf",- f"dflash-{BOLT}-NVFP4.gguf"]+BOLT_FILES = [+ ".gitattributes",+ "README.md",+ "mmproj-BF16.gguf",+ f"{BOLT}-IQ2_XXS.gguf",+ f"dflash-{BOLT}-NVFP4.gguf",+]def _model_info(files):@@ -98,7 +117,8 @@ def test_super_variant_menu_lists_exactly_the_real_quants(monkeypatch):from utils.models import model_configmonkeypatch.setattr(- model_config, "_hub_model_info_slow_link",+ model_config,+ "_hub_model_info_slow_link",lambda repo, token, files_metadata = True: _model_info(SUPER_FILES),)variants, has_vision = model_config.list_gguf_variants(SUPER_REPO)@@ -110,7 +130,8 @@ def test_bolt_variant_menu_is_the_single_iq2_xxs(monkeypatch):from utils.models import model_configmonkeypatch.setattr(- model_config, "_hub_model_info_slow_link",+ model_config,+ "_hub_model_info_slow_link",lambda repo, token, files_metadata = True: _model_info(BOLT_FILES),)variants, has_vision = model_config.list_gguf_variants(BOLT_REPO)@@ -157,7 +178,6 @@ NEMOTRON35_IDS = [@pytest.mark.parametrize("model_id", NEMOTRON35_IDS)def test_nemotron35_sampling_defaults(model_id):from utils.inference.inference_config import load_inference_config-config = load_inference_config(model_id)for key, want in EXPECTED_SAMPLING.items():assert config[key] == want, f"{model_id}: {key} was {config[key]}, expected {want}"@@ -165,5 +185,4 @@ def test_nemotron35_sampling_defaults(model_id):def test_older_nemotrons_keep_their_sampling():from utils.inference.inference_config import load_inference_config-assert load_inference_config("unsloth/Nemotron-3-Nano-30B-A3B-GGUF")["top_p"] == 1.0diff --git a/studio/backend/tests/test_nemotron35_planner.py b/studio/backend/tests/test_nemotron35_planner.pyindex 5322fa169de..59586f06e12 100644--- a/studio/backend/tests/test_nemotron35_planner.py+++ b/studio/backend/tests/test_nemotron35_planner.py@@ -59,7 +59,12 @@ _FFN = [0, 1536, 0, 0, 2048, 0, 0, 2304]_SSM = {"inner_size": 8192, "state_size": 128, "group_count": 8, "conv_kernel": 4}-def _nemotron_fields(arch = "nemotron_h_moe", heads = _HEADS, used = (0, 9, 0, 0, 9, 0, 0, 9), **extra):+def _nemotron_fields(+ arch = "nemotron_h_moe",+ heads = _HEADS,+ used = (0, 9, 0, 0, 9, 0, 0, 9),+ **extra,+):fields = {"general.architecture": arch,f"{arch}.block_count": len(heads),@@ -160,8 +165,13 @@ def _backend(**dims):def test_latent_moe_width_uses_the_latent_size():- common = dict(embedding_length = 4096, expert_used_count = 22, expert_feed_forward_length = 2688,- expert_shared_feed_forward_length = 5376, n_experts = 512)+ common = dict(+ embedding_length = 4096,+ expert_used_count = 22,+ expert_feed_forward_length = 2688,+ expert_shared_feed_forward_length = 5376,+ n_experts = 512,+ )latent = _backend(moe_latent_size = 1024, **common)._compute_activation_width()assert latent == 22 * (2 * 1024 + 3 * 2688) + 3 * 5376# No latent key: the formula every other MoE arch gets, unchanged.@@ -191,14 +201,19 @@ def test_per_layer_expert_dims_and_latent_size_are_read(tmp_path):path = tmp_path / "bolt.gguf"a = "nemotron_h_moe"- _write_gguf(path, a, {- f"{a}.block_count": 4,- f"{a}.embedding_length": 64,- f"{a}.expert_count": 8,- f"{a}.expert_used_count": [0, 9, 0, 9],- f"{a}.expert_feed_forward_length": [0, 1536, 0, 2560],- f"{a}.moe_latent_size": 16,- }, [("blk.0.attn_norm.weight", 64)])+ _write_gguf(+ path,+ a,+ {+ f"{a}.block_count": 4,+ f"{a}.embedding_length": 64,+ f"{a}.expert_count": 8,+ f"{a}.expert_used_count": [0, 9, 0, 9],+ f"{a}.expert_feed_forward_length": [0, 1536, 0, 2560],+ f"{a}.moe_latent_size": 16,+ },+ [("blk.0.attn_norm.weight", 64)],+ )b = LlamaCppBackend(manages_processes = False)b._read_gguf_metadata(str(path))assert b._expert_used_count == 9@@ -211,13 +226,18 @@ def _nextn_gguf(tmp_path, arch, nextn):kv = {f"{arch}.block_count": 3, f"{arch}.embedding_length": 64}if nextn:kv[f"{arch}.nextn_predict_layers"] = nextn- _write_gguf(path, arch, kv, [- ("token_embd.weight", 256),- ("blk.0.attn_norm.weight", 64),- ("blk.1.ffn_up_exps.weight", 512),- ("blk.2.nextn.eh_proj.weight", 1024),- ("blk.2.ffn_up_exps.weight", 2048),- ])+ _write_gguf(+ path,+ arch,+ kv,+ [+ ("token_embd.weight", 256),+ ("blk.0.attn_norm.weight", 64),+ ("blk.1.ffn_up_exps.weight", 512),+ ("blk.2.nextn.eh_proj.weight", 1024),+ ("blk.2.ffn_up_exps.weight", 2048),+ ],+ )return str(path)@@ -285,7 +305,9 @@ def test_dflash_compute_reserve_covers_the_measurement_without_double_counting(d(572 MiB) priced Bolt + LiLiCorr 224 MiB over what llama.cpp allocates."""from core.inference.llama_cpp import LlamaCppBackend- reserve = (LlamaCppBackend._MTP_DRAFT_COMPUTE_BYTES + LlamaCppBackend._DFLASH_DRAFT_COMPUTE_BYTES) / MIB+ reserve = (+ LlamaCppBackend._MTP_DRAFT_COMPUTE_BYTES + LlamaCppBackend._DFLASH_DRAFT_COMPUTE_BYTES+ ) / MIBmeasured = _DFLASH_MEASURED_COMPUTE_MIB[drafter]assert reserve >= measuredassert reserve - max(_DFLASH_MEASURED_COMPUTE_MIB.values()) < 8diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex 486f5e71dad..30bd31e5f2f 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -2777,6 +2777,20 @@ def test_model_config_keeps_storage_and_load_identities_separate():assert "model_path: target.id," in config_page+def _python_regex_source(source: str, name: str) -> str:+ """The pattern string a module compiles into `name`, adjacent literals joined as Python joins them."""+ for node in ast.walk(ast.parse(source)):+ if (+ isinstance(node, ast.Assign)+ and any(isinstance(t, ast.Name) and t.id == name for t in node.targets)+ and isinstance(node.value, ast.Call)+ and node.value.args+ and isinstance(node.value.args[0], ast.Constant)+ ):+ return node.value.args[0].value+ raise AssertionError(f"{name} is no longer a re.compile of a literal pattern")++def test_backfill_splits_a_quant_suffix_the_way_the_backend_does():"""Split quant suffixes the way the backend does: a colon in a path is not a quant separator."""identity = " ".join(_read("features/model-picker/model-config/model-identity.ts").split())@@ -2794,9 +2808,23 @@ def test_backfill_splits_a_quant_suffix_the_way_the_backend_does():assert "def split_quant_suffix(" in backend, "the rule this mirrors"assert "_BPW_SUFFIX" in backend and "bpw" in identityassert "extract_quant_label(filename).casefold()" in backend, "the label rule"- quants = _read_backend("core/inference/llama_cpp.py")- for token in ("MXFP", "IQ", "TQ", "BF16", "F16", "F32"):- assert token in quants and token in identity, token+ # The known-quant pattern itself, not tokens from it: #13899 widened MXFP to (?:MX|NV)FP in all+ # three places, which a literal "MXFP" check read as a drift. What has to hold is that the+ # frontend, the hub scanner and the llama.cpp backend spell one pattern, and that it still+ # recognises each quant family.+ patterns = {+ "llama_cpp.py": _python_regex_source(+ _read_backend("core/inference/llama_cpp.py"), "_GGUF_KNOWN_QUANT_RE"+ ),+ "gguf.py": _python_regex_source(_read_backend("hub/utils/gguf.py"), "_GGUF_QUANT_RE"),+ "model-identity.ts": re.search(r'const QUANT_TOKEN_SOURCE =\s*"([^"]+)";', identity).group(+ 1+ ),+ }+ assert len(set(patterns.values())) == 1, patterns+ known = re.compile(f"^(?:{patterns['gguf.py']})$", re.IGNORECASE)+ for quant in ("MXFP4", "NVFP4", "IQ4_XS", "TQ1_0", "Q4_K_M", "Q8_0", "BF16", "F16", "F32"):+ assert known.match(quant), quantgguf = _read_backend("hub/utils/gguf.py")assert "def extract_quant_label(" in gguf and "def _gguf_stem(" in ggufassert "function ggufQuantLabel(" in identity and "function ggufStem(" in identitydiff --git a/tests/test_norm_fast_launch.py b/tests/test_norm_fast_launch.pyindex 3fcbcee3904..8bf9c3829d9 100644--- a/tests/test_norm_fast_launch.py+++ b/tests/test_norm_fast_launch.py@@ -37,9 +37,17 @@ CASES = []-def _module(kind, width, train, device = "cuda", bias = True):+def _module(+ kind,+ width,+ train,+ device = "cuda",+ bias = True,+):g = torch.Generator().manual_seed(width)- weight = torch.nn.Parameter(torch.randn(width, generator = g).to(device, DTYPE), requires_grad = train)+ weight = torch.nn.Parameter(+ torch.randn(width, generator = g).to(device, DTYPE), requires_grad = train+ )b = torch.nn.Parameter(torch.randn(width, generator = g).to(device, DTYPE), requires_grad = train)return weight, (b if kind == "ln" and bias else None)@@ -61,7 +69,12 @@ def _clear(weight, bias):p.grad = None-def _inputs(width, rows = 300, device = "cuda", seed = 0):+def _inputs(+ width,+ rows = 300,+ device = "cuda",+ seed = 0,+):g = torch.Generator().manual_seed(seed)return (torch.randn(2, rows, width, generator = g).to(device, DTYPE),@@ -80,7 +93,9 @@ def test_warm_eager_call_skips_triton_dispatch(monkeypatch, kind, width, gemma,calls = []run = triton.runtime.jit.JITFunction.runmonkeypatch.setattr(- triton.runtime.jit.JITFunction, "run", lambda self, *a, **k: calls.append(self) or run(self, *a, **k)+ triton.runtime.jit.JITFunction,+ "run",+ lambda self, *a, **k: calls.append(self) or run(self, *a, **k),)got = _step(kind, gemma, x, weight, bias, dy)assert calls == [], [c.__name__ for c in calls]@@ -89,12 +104,16 @@ def test_warm_eager_call_skips_triton_dispatch(monkeypatch, kind, width, gemma,@pytest.mark.skipif(not getattr(torch.library, "triton_op", None), reason = "needs triton_op")[email protected]("kind,width,gemma", [("rms", 128, False), ("rms", 4096, True), ("ln", 1000, False)])+ "kind,width,gemma", [("rms", 128, False), ("rms", 4096, True), ("ln", 1000, False)]+)def test_compiled_calls_never_use_fast_launch(monkeypatch, kind, width, gemma):calls = []for module in (rms_layernorm, layernorm):real = module.launch- monkeypatch.setattr(module, "launch", lambda *a, real = real, **k: calls.append(a[0]) or real(*a, **k))+ monkeypatch.setattr(+ module, "launch", lambda *a, real = real, **k: calls.append(a[0]) or real(*a, **k)+ )# fp32: T4 cannot trace bf16 Triton.weight = torch.nn.Parameter(torch.randn(width, device = "cuda"))bias = torch.nn.Parameter(torch.randn(width, device = "cuda"))diff --git a/tests/test_remote_code_class_and_expert_submodules.py b/tests/test_remote_code_class_and_expert_submodules.pyindex 20befc542b9..5cc746a70e1 100644--- a/tests/test_remote_code_class_and_expert_submodules.py+++ b/tests/test_remote_code_class_and_expert_submodules.py@@ -615,7 +615,9 @@ def _native_qwen3_moe_4x_model(with_visual = False, dense_first = False):class _Body(torch.nn.Module):def __init__(self):super().__init__()- self.layers = torch.nn.ModuleList([_DecoderLayer(dense_first and i == 0) for i in range(2)])+ self.layers = torch.nn.ModuleList(+ [_DecoderLayer(dense_first and i == 0) for i in range(2)]+ )class _Qwen3Moe(torch.nn.Module):def __init__(self):@@ -761,7 +763,9 @@ def test_explicit_leaf_list_keeps_mixtral_names_and_the_gate_up_shorthand():model, regex, leaves, auto_regex = True, explicit_leaves = True)assert found == ["w1", "w2", "w3"]- assert {n for n in names if re.fullmatch(widened, n)} == {n for n in names if n.rpartition(".")[2] in leaves}+ assert {n for n in names if re.fullmatch(widened, n)} == {+ n for n in names if n.rpartition(".")[2] in leaves+ }model = _native_qwen3_moe_4x_model()names = [n for n, m in model.named_modules() if isinstance(m, torch.nn.Linear)]@@ -771,7 +775,9 @@ def test_explicit_leaf_list_keeps_mixtral_names_and_the_gate_up_shorthand():)assert found == ["gate_proj", "up_proj"]matched = {n for n in names if re.fullmatch(widened, n) and ".experts." in n}- assert matched == {n for n in names if ".experts." in n and n.endswith((".gate_proj", ".up_proj"))}+ assert matched == {+ n for n in names if ".experts." in n and n.endswith((".gate_proj", ".up_proj"))+ }def test_expert_only_mixtral_list_falls_back_to_the_decoders_experts():@@ -782,7 +788,9 @@ def test_expert_only_mixtral_list_falls_back_to_the_decoders_experts():with pytest.raises(RuntimeError):_explicit_list_regex(model, ["w1", "w2", "w3"])regex = U.native_expert_only_regex(model, ["w1", "w2", "w3"])- assert {n for n in names if re.fullmatch(regex, n)} == {n for n in names if n.endswith((".w1", ".w2", ".w3"))}+ assert {n for n in names if re.fullmatch(regex, n)} == {+ n for n in names if n.endswith((".w1", ".w2", ".w3"))+ }assert U.native_expert_only_regex(model, ["q_proj"]) is Noneregex = U.native_expert_only_regex(model, ["w1", "w2", "w3", "gate"])want = {n for n in names if n.endswith((".w1", ".w2", ".w3", ".gate"))}@@ -790,7 +798,9 @@ def test_expert_only_mixtral_list_falls_back_to_the_decoders_experts():assert {n for n in names if re.fullmatch(regex, n)} == want# Zoo already dropped the other families (finetune_attention_modules=False).regex = U.native_expert_only_regex(model, ["q_proj", "w1", "w2", "w3"])- assert {n for n in names if re.fullmatch(regex, n)} == {n for n in names if n.endswith((".w1", ".w2", ".w3"))}+ assert {n for n in names if re.fullmatch(regex, n)} == {+ n for n in names if n.endswith((".w1", ".w2", ".w3"))+ }model = _native_qwen3_moe_4x_model()model.get_decoder = lambda: model.modelnames = [n for n, m in model.named_modules() if isinstance(m, torch.nn.Linear)]diff --git a/tests/test_triton_fp_fusion.py b/tests/test_triton_fp_fusion.pyindex 16c9fcd625a..4413790175c 100644--- a/tests/test_triton_fp_fusion.py+++ b/tests/test_triton_fp_fusion.py@@ -42,7 +42,11 @@ def _launch_sites():continuefor node in ast.walk(ast.parse(src)):helper = _LAUNCH_HELPERS.get(path.name)- if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id == helper:+ if (+ isinstance(node, ast.Call)+ and isinstance(node.func, ast.Name)+ and node.func.id == helper+ ):yield f"{rel}:{node.lineno}:{helper}", nodeif isinstance(node, ast.Call) and isinstance(node.func, ast.Subscript):name = ast.get_source_segment(src, node.func.value)diff --git a/unsloth/kernels/layernorm.py b/unsloth/kernels/layernorm.pyindex de5fde44044..66b63d98674 100644--- a/unsloth/kernels/layernorm.py+++ b/unsloth/kernels/layernorm.py@@ -299,9 +299,7 @@ class Fast_Layernorm(torch.autograd.Function):programs, rows_per_program = _dw_programs(device, n_rows, ctx.num_warps)# Every program stores its partial row, so empty suffices unless nothing launches.alloc = torch.empty if n_rows > 0 else torch.zeros- partials = alloc(- (train_w + train_b, programs, n_cols), dtype = torch.float32, device = device- )+ partials = alloc((train_w + train_b, programs, n_cols), dtype = torch.float32, device = device)dW = torch.empty(n_cols, dtype = W.dtype, device = device) if train_w else NonedB = torch.empty(n_cols, dtype = b.dtype, device = device) if train_b else Noneouts = [t for t in (dW, dB) if t is not None]diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex 80e94a425ef..43cd60adf32 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -9233,7 +9233,9 @@ def _native_expert_parents(model, target_modules, requested):if key not in in_scope:layer = parent.rpartition(".")[0]# Mixtral's block_sparse_moe has no MLP keyword; this keeps vision towers out.- in_scope[key] = any(pattern.fullmatch(f"{parent}.{t}") for t in requested | {leaf}) or bool(+ in_scope[key] = any(+ pattern.fullmatch(f"{parent}.{t}") for t in requested | {leaf}+ ) or bool(layer and any(r == layer or r.startswith(layer + ".") for r in reached_layers))if not in_scope[key]:@@ -9261,6 +9263,7 @@ def native_expert_only_regex(model, target_modules):requested = {t for t in target_modules if isinstance(t, str) and "." not in t}if "gate_up_proj" in requested: # the shorthand reaches split gate / up experts toorequested |= {"gate_proj", "up_proj"}+def generic(path):return r"\.".join(r"\d+" if part.isdigit() else re.escape(part) for part in path.split("."))