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
Studio: stop listing Bonsai DSpark drafter files as models (#11265)
kevin902ef70dffc2
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex a76e5a24660..a46f2576196 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -3227,7 +3227,8 @@ _IMATRIX_TOKEN_RE = re.compile(r"^imatrix(?:[._\-]|$)|[._\-]imatrix$", re.IGNOREdef _is_companion_gguf_path(path: str) -> bool:"""True for a non-main GGUF: vision mmproj, a calibration imatrix, or a separatedrafter (repo-root ``mtp-*.gguf``, the ``MTP/`` subdir copies for Gemma 4, the ``dspark/``- drafters for DeepSeek V4 Flash, the ``eagle3-*.gguf`` draft heads). Mirrors+ drafters for DeepSeek V4 Flash, the ``<model>-dspark-<quant>.gguf`` drafters for+ prism-ml Bonsai, the ``eagle3-*.gguf`` draft heads). Mirrorshub.utils.gguf so variant resolution never picks a companion as the main model --a Gemma ``Q8_0`` request must not resolve to ``MTP/...-Q8_0-MTP.gguf``, which sortsahead of the real weight.@@ -3243,6 +3244,8 @@ def _is_companion_gguf_path(path: str) -> bool:# holding calibration statistics, so only the name rules it out.if _IMATRIX_TOKEN_RE.search(Path(p).stem):return True+ if _DSPARK_BEFORE_QUANT_RE.search(Path(p).name):+ return Truereturn _drafter_path_kind(path) is not None@@ -3311,6 +3314,11 @@ _GGUF_KNOWN_QUANT_RE = re.compile(r"|BF16|F16|F32)",re.IGNORECASE,)+# Mirrors hub.utils.gguf._DSPARK_BEFORE_QUANT_RE, for _is_companion_gguf_path.+_DSPARK_BEFORE_QUANT_RE = re.compile(+ rf"-dspark-(?:{_GGUF_KNOWN_QUANT_RE.pattern})(?:-[0-9]{{5}}-of-[0-9]{{5}})?\.gguf$",+ re.IGNORECASE,+)def _is_big_endian_gguf_path(path: str, variant_key: str = "") -> bool:diff --git a/studio/backend/hub/utils/gguf.py b/studio/backend/hub/utils/gguf.pyindex 7b775925a14..1cca0f91a20 100644--- a/studio/backend/hub/utils/gguf.py+++ b/studio/backend/hub/utils/gguf.py@@ -108,16 +108,24 @@ _DRAFTER_KINDS = ("mtp", "dspark", "dflash", "eagle3")# Directories only: mtp/ and dspark/ are always a publisher's companion folder, while dflash/ is a family name a user picks for real weights._DRAFTER_DIR_KINDS = ("mtp", "dspark")+# <model>-dspark-<quant>.gguf drafters (prism-ml Bonsai, third-party DSpark GGUFs); a name going on past the quant (DeepSeek-V4-Flash-Dspark-Abliterated-MXFP4-BF16.gguf) is the model.+_DSPARK_BEFORE_QUANT_RE = re.compile(+ rf"-dspark-(?:{_GGUF_QUANT_RE.pattern})(?:-[0-9]{{5}}-of-[0-9]{{5}})?\.gguf$",+ re.IGNORECASE,+)+def is_mtp_drafter_path(path: str) -> bool:- """True for a separate-file drafter, a companion to the main model rather than a selectable quant: the repo-root ``mtp-*.gguf`` (the Q8_0 copy unsloth ships for llama.cpp ``-hf`` auto-discovery), the ``MTP/`` subdir copies (Gemma 4), the ``dspark/`` drafters (DeepSeek V4 Flash) and the ``eagle3-*.gguf`` draft heads (ggml-org gpt-oss). Repos that bake the head into the main GGUF (Qwen) have no such file, so this is False for them. Must be excluded from main-model selection everywhere mmproj is. Matched by basename prefix, or by an exact parent dir for ``_DRAFTER_DIR_KINDS``; never a substring, since the kind names double as family names, so ``Qwen3.6-27B-MTP-Q4_K_M.gguf`` and ``Qwen3.6-35B-A3B-DFlash-Q4_K_M.gguf`` ARE the model. CANONICAL COPY. Two mirrors must change in lockstep: utils/models/model_config.py ``_is_mtp_drafter`` (utils cannot import hub) and core/inference/llama_cpp.py ``_is_companion_gguf_path`` (core avoids hub imports; bundles the mmproj check)."""+ """True for a separate-file drafter, a companion to the main model rather than a selectable quant: the repo-root ``mtp-*.gguf`` (the Q8_0 copy unsloth ships for llama.cpp ``-hf`` auto-discovery), the ``MTP/`` subdir copies (Gemma 4), the ``dspark/`` drafters (DeepSeek V4 Flash), the ``<model>-dspark-<quant>.gguf`` drafters (prism-ml Bonsai) and the ``eagle3-*.gguf`` draft heads (ggml-org gpt-oss). Repos that bake the head into the main GGUF (Qwen) have no such file, so this is False for them. Must be excluded from main-model selection everywhere mmproj is. Matched by basename prefix, by an exact parent dir for ``_DRAFTER_DIR_KINDS``, or by ``_DSPARK_BEFORE_QUANT_RE``; never a bare substring, since the kind names double as family names, so ``Qwen3.6-27B-MTP-Q4_K_M.gguf`` and ``Qwen3.6-35B-A3B-DFlash-Q4_K_M.gguf`` ARE the model. CANONICAL COPY. Two mirrors must change in lockstep: utils/models/model_config.py ``_is_mtp_drafter`` (utils cannot import hub) and core/inference/llama_cpp.py ``_is_companion_gguf_path`` (core avoids hub imports; bundles the mmproj check)."""p = path.replace("\\", "/").lower()if not p.endswith(".gguf"):return Falseparts = [segment for segment in p.split("/") if segment]name, parents = parts[-1], parts[:-1]- return any(name.startswith(f"{kind}-") for kind in _DRAFTER_KINDS) or any(- kind in parents for kind in _DRAFTER_DIR_KINDS+ return (+ any(name.startswith(f"{kind}-") for kind in _DRAFTER_KINDS)+ or any(kind in parents for kind in _DRAFTER_DIR_KINDS)+ or _DSPARK_BEFORE_QUANT_RE.search(name) is not None)@@ -128,8 +136,11 @@ def is_reclaimable_drafter_path(path: str) -> bool:return Falseparts = [segment for segment in p.split("/") if segment]name, parents = parts[-1], parts[:-1]- return any(name.startswith(f"{kind}-") for kind in _DRAFTER_DIR_KINDS) or any(- kind in parents for kind in _DRAFTER_DIR_KINDS+ return (+ any(name.startswith(f"{kind}-") for kind in _DRAFTER_DIR_KINDS)+ or any(kind in parents for kind in _DRAFTER_DIR_KINDS)+ # <model>-dspark-<quant>.gguf: hidden from the menu as a companion, so it goes with the last variant too.+ or _DSPARK_BEFORE_QUANT_RE.search(name) is not None)diff --git a/studio/backend/tests/test_mtp_drafter_companion.py b/studio/backend/tests/test_mtp_drafter_companion.pyindex f52b2ea8b7d..b1ec5a23eee 100644--- a/studio/backend/tests/test_mtp_drafter_companion.py+++ b/studio/backend/tests/test_mtp_drafter_companion.py@@ -91,6 +91,12 @@ DRAFTER_CASES = [("quants/eagle3-gpt-oss-20b-Q8_0.gguf", True),("Llama-3.1-8B-Eagle3-Q4_K_M.gguf", False),("eagle3/Llama-3.1-8B-Eagle3-Q4_K_M.gguf", False),+ # <model>-dspark-<quant>.gguf drafters; a name going on past the kind is the model.+ ("Ternary-Bonsai-27B-dspark-Q4_1.gguf", True),+ ("Bonsai-27B-dspark-bf16.gguf", True),+ ("Qwen3.6-27B-DSpark-Q4_K_M.gguf", True),+ ("model-dspark-Q8_0-00001-of-00002.gguf", True),+ ("DeepSeek-V4-Flash-Dspark-Abliterated-MXFP4-BF16-00001-of-00004.gguf", False),]@@ -180,6 +186,24 @@ def test_eagle3_draft_head_is_not_a_variant_or_the_default():assert plans["mxfp4"].target_filenames == ("gpt-oss-20b-MXFP4.gguf",)+BONSAI_FILES = [+ "Bonsai-27B-F16.gguf",+ "Bonsai-27B-Q1_0.gguf",+ "Bonsai-27B-dspark-Q4_1.gguf",+ "Bonsai-27B-dspark-bf16.gguf",+ "Bonsai-27B-mmproj-BF16.gguf",+]+++def test_bonsai_dspark_drafter_is_not_a_variant():+ # #11259: the drafter was the smallest row, and llama-server cannot load it as a model.+ plans = build_gguf_variant_plans(+ [_sib(name, 1_000, f"sha-{i}") for i, name in enumerate(BONSAI_FILES)]+ )+ assert set(plans) == {"f16", "q1_0"}+ assert plans["q1_0"].main_filenames == frozenset({"Bonsai-27B-Q1_0.gguf"})++def test_baked_in_repo_plans_unchanged():plans = build_gguf_variant_plans([_sib("Qwen3.6-27B-MTP-Q4_K_M.gguf", 4_000, "q4")])assert plans["q4_k_m"].target_filenames == ("Qwen3.6-27B-MTP-Q4_K_M.gguf",)@@ -2790,6 +2814,8 @@ def test_dflash_stays_unreclaimable_even_though_auto_now_launches_it(tmp_path):assert is_reclaimable_drafter_path("dflash-kquant.gguf") is Falseassert is_reclaimable_drafter_path("dspark-model-Q8_0.gguf") is True+ assert is_reclaimable_drafter_path("Ternary-Bonsai-27B-dspark-Q4_1.gguf") is True+ assert is_reclaimable_drafter_path("DeepSeek-V4-Flash-Dspark-Abliterated-MXFP4.gguf") is Falserepo, snap = _cache_repo(tmp_path,@@ -2803,6 +2829,22 @@ def test_dflash_stays_unreclaimable_even_though_auto_now_launches_it(tmp_path):assert not (snap / "dspark-model-Q8_0.gguf").is_symlink()+def test_deleting_the_last_bonsai_variant_reclaims_its_dspark_drafter(tmp_path):+ """The menu hides <model>-dspark-<quant>.gguf as a companion, so once the last real+ variant is deleted nothing could ever launch it; its blob must go too."""+ from hub.services.models.deletion import _delete_gguf_variant_from_repos++ repo, snap = _cache_repo(+ tmp_path,+ "prism-ml/Bonsai-27B-gguf",+ ["Bonsai-27B-Q1_0.gguf", "Bonsai-27B-dspark-Q4_1.gguf"],+ )+ _delete_gguf_variant_from_repos("prism-ml/Bonsai-27B-gguf", "Q1_0", [repo], None, root = tmp_path)++ assert not (snap / "Bonsai-27B-Q1_0.gguf").is_symlink()+ assert not (snap / "Bonsai-27B-dspark-Q4_1.gguf").is_symlink()++def test_detect_dflash_file_skips_a_sidecar_named_for_another_weight(tmp_path):"""A multi-model folder must not attach a foreign drafter.diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.pyindex e32805f3cfe..62158f11957 100644--- a/studio/backend/utils/models/model_config.py+++ b/studio/backend/utils/models/model_config.py@@ -1901,7 +1901,8 @@ _DRAFTER_DIR_KINDS = ("mtp", "dspark")def _is_mtp_drafter(path: str) -> bool:"""True for a separate-file drafter, a companion to the main model ratherthan a selectable quant: the repo-root ``mtp-*.gguf``, the ``MTP/`` subdir- copies (Gemma 4), the ``dspark/`` drafters (DeepSeek V4 Flash) or the+ copies (Gemma 4), the ``dspark/`` drafters (DeepSeek V4 Flash), the+ ``<model>-dspark-<quant>.gguf`` drafters (prism-ml Bonsai) or the``eagle3-*.gguf`` draft heads (ggml-org gpt-oss).Mirrors hub.utils.gguf.is_mtp_drafter_path (utils cannot import hub). Must be@@ -1910,18 +1911,20 @@ def _is_mtp_drafter(path: str) -> bool:resolve to ``MTP/...-Q8_0-MTP.gguf``, which sorts ahead of the real weight,or to ``dspark/dspark-...-Q8_0.gguf``.- Prefix, or an exact directory for ``_DRAFTER_DIR_KINDS``; never a substring,- since the kind names double as family names- (``Qwen3.6-35B-A3B-DFlash-Q4_K_M.gguf`` IS the model, as is anything in a- user's ``dflash/`` folder).+ Prefix, an exact directory for ``_DRAFTER_DIR_KINDS``, or+ ``_DSPARK_BEFORE_QUANT_RE``; never a bare substring, since the kind names+ double as family names (``Qwen3.6-35B-A3B-DFlash-Q4_K_M.gguf`` IS the model,+ as is anything in a user's ``dflash/`` folder)."""p = path.replace("\\", "/").lower()if not p.endswith(".gguf"):return Falseparts = [segment for segment in p.split("/") if segment]name, parents = parts[-1], parts[:-1]- return any(name.startswith(f"{kind}-") for kind in _DRAFTER_KINDS) or any(- kind in parents for kind in _DRAFTER_DIR_KINDS+ return (+ any(name.startswith(f"{kind}-") for kind in _DRAFTER_KINDS)+ or any(kind in parents for kind in _DRAFTER_DIR_KINDS)+ or _DSPARK_BEFORE_QUANT_RE.search(name) is not None)@@ -2806,6 +2809,11 @@ _GGUF_KNOWN_QUANT_RE = re.compile(r"|BF16|F16|F32)",re.IGNORECASE,)+# Mirrors hub.utils.gguf._DSPARK_BEFORE_QUANT_RE, for _is_mtp_drafter.+_DSPARK_BEFORE_QUANT_RE = re.compile(+ rf"-dspark-(?:{_GGUF_KNOWN_QUANT_RE.pattern})(?:-[0-9]{{5}}-of-[0-9]{{5}})?\.gguf$",+ re.IGNORECASE,+)_FLOAT_PRECISION_QUANTS = frozenset({"BF16", "F16", "F32"})