Skip to content

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.

Studio: filter DSpark/DFlash drafters out of the GGUF quant picker (#7811)

Daniel Han5ec9a599ee42
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index 8909a381612..d6c4c05bf2d 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -1116,21 +1116,52 @@ def _is_mtp_model_name(model_identifier: Optional[str], gguf_path: Optional[str]
return False
+# Mirrors hub.utils.gguf._DRAFTER_KINDS / _DRAFTER_DIR_KINDS.
+_DRAFTER_KINDS = ("mtp", "dspark", "dflash")
+_DRAFTER_DIR_KINDS = ("mtp", "dspark")
+
+
+def _drafter_path_kind(path: str) -> Optional[str]:
+ """Drafter kind naming *path*: basename prefix, or exact parent dir for
+ ``_DRAFTER_DIR_KINDS``. Never a substring: the kind names double as family
+ names, so ``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 None
+ parts = [segment for segment in p.split("/") if segment]
+ name, parents = parts[-1], parts[:-1]
+ for kind in _DRAFTER_KINDS:
+ if name.startswith(f"{kind}-"):
+ return kind
+ for kind in _DRAFTER_DIR_KINDS:
+ if kind in parents:
+ return kind
+ return None
+
+
def _is_companion_gguf_path(path: str) -> bool:
- """True for a non-main GGUF: vision mmproj or a separate MTP drafter
- (repo-root ``mtp-*.gguf`` or the ``MTP/`` subdir copies, Gemma 4).
+ """True for a non-main GGUF: vision mmproj, or a separate drafter (repo-root
+ ``mtp-*.gguf``, the ``MTP/`` subdir copies for Gemma 4, the ``dspark/``
+ drafters for DeepSeek V4 Flash). Mirrors hub.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 sorts ahead of the real weight.
- Mirrors hub.utils.gguf so variant resolution never picks a companion as
- the main model -- e.g. a Gemma ``Q8_0`` request must not resolve to the
- ``MTP/...-Q8_0-MTP.gguf`` drafter, which sorts ahead of the real weight.
+ EXCLUSION ONLY. Use ``_is_mtp_only_drafter_path`` to pick a drafter to launch.
"""
p = path.lower()
if not p.endswith(".gguf"):
return False
if "mmproj" in p:
return True
- name = p.rsplit("/", 1)[-1]
- return name.startswith("mtp-") or "/mtp/" in f"/{p}"
+ return _drafter_path_kind(path) is not None
+
+
+def _is_mtp_only_drafter_path(path: str) -> bool:
+ """MTP only, the one kind Studio launches today (``--spec-type draft-mtp``).
+ DSpark needs ``draft-dspark`` plus ``--fit off``, so drafter discovery must
+ narrow to MTP rather than reuse the broad companion predicate."""
+ return _drafter_path_kind(path) == "mtp"
_BIG_ENDIAN_GGUF_FILENAME_RE = re.compile(r"(^|[-_])be(?:[._-]|$)", re.IGNORECASE)
@@ -7169,7 +7200,9 @@ class LlamaCppBackend:
)
for snap in snapshots: # newest first
for f in sorted(_gguf_snapshot_files(snap)):
- if _is_companion_gguf_path(f) and "mmproj" not in f.lower():
+ # MTP only: a DSpark drafter needs --spec-type draft-dspark,
+ # so it must never be launched as an MTP one.
+ if _is_mtp_only_drafter_path(f):
(roots if "/" not in f else subdirs).append(snap / f)
# Keep snapshot order (newest first), root before any MTP/ copy, so a
# newer main GGUF pairs with the newest cached drafter, not a stale one.
diff --git a/studio/backend/hub/services/models/deletion.py b/studio/backend/hub/services/models/deletion.py
index d48632f29fa..e0892e8c485 100644
--- a/studio/backend/hub/services/models/deletion.py
+++ b/studio/backend/hub/services/models/deletion.py
@@ -16,7 +16,11 @@ from loggers import get_logger
from hub.utils import download_manifest
from hub.utils import download_registry
from hub.utils import inventory_scan as hf_cache_scan
-from hub.utils.gguf import extract_quant_label, extract_quant_token
+from hub.utils.gguf import (
+ extract_quant_label,
+ extract_quant_token,
+ is_mtp_only_drafter_path as _is_mtp_only_drafter_path,
+)
from hub.utils.hf_cache_state import (
INCOMPLETE_SUFFIX,
iter_repo_cache_dirs,
@@ -35,7 +39,6 @@ from hub.services.models.common import (
_is_gguf_filename,
_is_main_gguf_filename,
_is_mmproj_filename,
- _is_mtp_drafter_path,
)
logger = get_logger(__name__)
@@ -216,8 +219,10 @@ def _delete_gguf_variant_from_repos(
target_repo,
# Companions: mmproj and the MTP drafter -- downloaded with
# every variant, so the last variant's delete reclaims them.
+ # MTP only: DSpark is opt-in and in no variant plan, so Studio
+ # never fetched it and must not reclaim it.
lambda name: _is_gguf_filename(name)
- and (_is_mmproj_filename(name) or _is_mtp_drafter_path(name)),
+ and (_is_mmproj_filename(name) or _is_mtp_only_drafter_path(name)),
)
for snap, _blob, name in companion_matches:
try:
diff --git a/studio/backend/hub/tests/test_model_services.py b/studio/backend/hub/tests/test_model_services.py
index e39b2fc4e70..187fce6cb41 100644
--- a/studio/backend/hub/tests/test_model_services.py
+++ b/studio/backend/hub/tests/test_model_services.py
@@ -135,6 +135,20 @@ def test_custom_inventory_filters_mtp_companions_at_registered_root(tmp_path, mo
}
+def test_custom_inventory_filters_dspark_companions_at_registered_root(tmp_path):
+ # Registering dspark/ as the scan root strips it from every relative path,
+ # so the dspark- basename prefix has to carry the exclusion.
+ root = tmp_path / "dspark"
+ root.mkdir()
+ for name in (
+ "dspark-DeepSeek-V4-Flash-0731-BF16.gguf",
+ "dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf",
+ ):
+ (root / name).write_bytes(b"x")
+
+ assert local_inventory._scan_custom_folder(root) == []
+
+
def test_unregistered_variant_identity_stays_scan_relative(tmp_path):
from utils.models.model_config import list_local_gguf_variants
diff --git a/studio/backend/hub/utils/gguf.py b/studio/backend/hub/utils/gguf.py
index 0af79c85cc6..7728163ae7e 100644
--- a/studio/backend/hub/utils/gguf.py
+++ b/studio/backend/hub/utils/gguf.py
@@ -83,26 +83,53 @@ def is_mmproj_filename(filename: str) -> bool:
return "mmproj" in filename.lower()
+# Separate-file drafter kinds. dspark and dflash are the same DeepSeek V4 Flash
+# drafter: the folder it ships in and the architecture it reports.
+_DRAFTER_KINDS = ("mtp", "dspark", "dflash")
+
+# 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")
+
+
def is_mtp_drafter_path(path: str) -> bool:
- """True for a separate-file MTP drafter (speculative head), a companion to
- the main model rather than a selectable quant.
-
- Covers the repo-root ``mtp-*.gguf`` (the Q8_0 copy unsloth ships for
- llama.cpp ``-hf`` auto-discovery) and the ``MTP/`` subdir copies (Gemma 4).
- 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.
-
- CANONICAL COPY. Layering keeps two mirrors that 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)
+ and the ``dspark/`` drafters (DeepSeek V4 Flash). 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).
"""
- p = path.lower()
+ p = path.replace("\\", "/").lower()
+ if not p.endswith(".gguf"):
+ return False
+ parts = [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
+ )
+
+
+def is_mtp_only_drafter_path(path: str) -> bool:
+ """MTP drafters only, for the delete path rather than selection. Studio fetches
+ the root ``mtp-*.gguf`` with every variant, so a variant delete may reclaim it.
+ DSpark and DFlash are opt-in and in no variant plan, so sweeping them up would
+ destroy a file Studio never downloaded."""
+ p = path.replace("\\", "/").lower()
if not p.endswith(".gguf"):
return False
- name = p.rsplit("/", 1)[-1]
- return name.startswith("mtp-") or "/mtp/" in f"/{p}"
+ parts = [segment for segment in p.split("/") if segment]
+ return parts[-1].startswith("mtp-") or "mtp" in parts[:-1]
def is_gguf_filename(filename: str) -> bool:
diff --git a/studio/backend/tests/test_mtp_drafter_companion.py b/studio/backend/tests/test_mtp_drafter_companion.py
index 8c857656d57..a22a7c0053d 100644
--- a/studio/backend/tests/test_mtp_drafter_companion.py
+++ b/studio/backend/tests/test_mtp_drafter_companion.py
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-"""Separate-file MTP drafter (Gemma 4) contracts.
+"""Separate-file drafter contracts: MTP (Gemma 4) and DSpark (DeepSeek V4 Flash).
Pins: the drafter-path predicate and its two layering mirrors, Gemma
effective-size extraction, companion classification in variant plans
@@ -58,6 +58,31 @@ DRAFTER_CASES = [
("prompt-mtp-test.gguf", False),
("smtp/model.gguf", False),
("mtp-readme.txt", False),
+ # DSpark drafters (DeepSeek V4 Flash). Their BF16/Q8_0 tokens make them the
+ # two smallest, most pickable entries in a repo whose real quants are 87 GB+.
+ ("dspark/dspark-DeepSeek-V4-Flash-0731-BF16.gguf", True),
+ ("dspark/dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf", True),
+ ("DSPARK/dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf", True),
+ ("dspark/whatever.gguf", True),
+ ("dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf", True),
+ # Local scans can hand the predicate a Windows path.
+ ("dspark\\dspark-DeepSeek-V4-Flash-0731-BF16.gguf", True),
+ # Same drafter under its general.architecture name; the prefix carries it,
+ # e.g. ggml-org/Qwen3.6-27B-GGUF ships one at the repo root.
+ ("dflash/dflash-model-Q8_0.gguf", True),
+ ("dflash-model.gguf", True),
+ ("dflash-Qwen3.6-27B-BF16.gguf", True),
+ # ...but dflash is a family name, so the DIRECTORY is not a drafter marker:
+ # no published repo uses a dflash/ companion folder, while users do name a
+ # local folder after the family they downloaded.
+ ("dflash/Qwen3.6-35B-A3B-DFlash-Q4_K_M.gguf", False),
+ ("foo/dflash/bar.gguf", False),
+ # Real Hub filenames where dflash/dspark is the family name: each IS the model.
+ ("Qwen3.6-35B-A3B-DFlash-Q4_K_M.gguf", False),
+ ("qwen36-35b-a3b-dflash-Q8_0.gguf", False),
+ ("laguna-xs21-dflash-q4.gguf", False),
+ ("xdspark/model.gguf", False),
+ ("dspark/README.md", False),
]
@@ -880,3 +905,153 @@ def test_companion_search_root_keeps_non_quant_directories(tmp_path):
weight = directory / "model.gguf"
weight.write_bytes(b"x")
assert _local_gguf_companion_search_root(str(directory), str(weight)) == str(directory)
+
+
+# ── DSpark drafters (DeepSeek V4 Flash) ──────────────────────────────
+
+DEEPSEEK_SIBLINGS = [
+ _sib("UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00001-of-00002.gguf", 9_000, "q4-1"),
+ _sib("UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00002-of-00002.gguf", 8_000, "q4-2"),
+ _sib("UD-IQ1_S/DeepSeek-V4-Flash-0731-UD-IQ1_S-00001-of-00002.gguf", 5_000, "iq1-1"),
+ _sib("dspark/dspark-DeepSeek-V4-Flash-0731-BF16.gguf", 1_100, "dspark-bf16"),
+ _sib("dspark/dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf", 1_000, "dspark-q8"),
+]
+
+
+def test_dspark_drafters_are_not_quants_and_are_not_auto_fetched():
+ plans = build_gguf_variant_plans(DEEPSEEK_SIBLINGS)
+
+ # The drafters carry BF16/Q8_0 tokens; neither may become a quant. They were
+ # also the two smallest entries, so the fit heuristic used to promote them in
+ # a repo whose real quants are 87 GB+.
+ assert set(plans) == {"ud-q4_k_xl", "ud-iq1_s"}
+
+ # DSpark is opt-in and ~11 GB per file, so unlike the root mtp-*.gguf it must
+ # not be folded into every plan.
+ for plan in plans.values():
+ assert not any(name.startswith("dspark/") for name in plan.target_filenames)
+ assert plan.companion_hashes == frozenset()
+
+ q4 = plans["ud-q4_k_xl"]
+ assert q4.main_size_bytes == 17_000
+ assert q4.download_size_bytes == 17_000
+
+
+def test_a_root_dflash_drafter_is_not_a_quant():
+ """ggml-org/Qwen3.6-27B-GGUF ships a 3 GB dflash- drafter beside the real
+ 54 GB BF16; merging them hands llama.cpp the drafter as the model."""
+ plans = build_gguf_variant_plans(
+ [
+ _sib("Qwen3.6-27B-BF16.gguf", 54_000, "bf16"),
+ _sib("dflash-Qwen3.6-27B-BF16.gguf", 3_000, "dflash"),
+ ]
+ )
+ assert set(plans) == {"bf16"}
+ assert plans["bf16"].main_filenames == frozenset({"Qwen3.6-27B-BF16.gguf"})
+ assert plans["bf16"].main_size_bytes == 54_000
+
+
+def test_gemma_mtp_is_still_auto_downloaded():
+ """Filtering only removes drafters from the quant list; the root mtp-*.gguf
+ is still fetched with every variant so MTP speculative decoding works."""
+ plans = build_gguf_variant_plans(GEMMA_SIBLINGS)
+ for plan in plans.values():
+ assert "mtp-gemma-4-12b-it.gguf" in plan.target_filenames
+
+
+def test_a_cached_dspark_drafter_is_never_launched_as_an_mtp_drafter(tmp_path, monkeypatch):
+ """_cached_repo_mtp_drafter uses the predicate inversely, to pick a drafter to
+ launch with --spec-type draft-mtp. DSpark needs draft-dspark plus --fit off,
+ so broadening that predicate must not widen what is launched."""
+ import core.inference.llama_cpp as llama_cpp_module
+
+ def _snapshot(files):
+ snap = tmp_path / f"snap{len(list(tmp_path.iterdir()))}"
+ for rel in files:
+ path = snap / rel
+ path.parent.mkdir(parents = True, exist_ok = True)
+ path.write_bytes(b"x")
+ return snap
+
+ dspark_only = _snapshot(["dspark/dspark-model-Q8_0.gguf", "model-Q4_K_M.gguf"])
+ with_mtp = _snapshot(["mtp-model.gguf", "model-Q4_K_M.gguf"])
+
+ backend = llama_cpp_module.LlamaCppBackend.__new__(llama_cpp_module.LlamaCppBackend)
+ snapshots: list[Path] = []
+ monkeypatch.setattr(
+ "utils.models.model_config._iter_hf_cache_snapshots",
+ lambda *a, **k: list(snapshots),
+ )
+
+ snapshots[:] = [dspark_only]
+ assert backend._cached_repo_mtp_drafter("some/repo") is None
+
+ snapshots[:] = [with_mtp, dspark_only]
+ found = backend._cached_repo_mtp_drafter("some/repo")
+ assert found is not None and found.endswith("mtp-model.gguf")
+
+
+# ── Deletion: only auto-fetched companions are reclaimed ─────────────
+
+
+def _cache_repo(tmp_path: Path, repo_id: str, names: list[str]):
+ """An HF cache repo: snapshot symlinks pointing at blobs."""
+ repo_dir = tmp_path / f"models--{repo_id.replace('/', '--')}"
+ snap = repo_dir / "snapshots" / "rev1"
+ blobs = repo_dir / "blobs"
+ snap.mkdir(parents = True)
+ blobs.mkdir(parents = True)
+ files = []
+ for index, name in enumerate(names):
+ blob = blobs / f"sha{index}"
+ blob.write_bytes(b"x" * 64)
+ link = snap / name
+ link.parent.mkdir(parents = True, exist_ok = True)
+ link.symlink_to(blob)
+ files.append(
+ SimpleNamespace(
+ file_name = name,
+ file_path = str(link),
+ blob_path = str(blob),
+ size_on_disk = 64,
+ )
+ )
+ return SimpleNamespace(
+ repo_id = repo_id,
+ repo_type = "model",
+ repo_path = repo_dir,
+ revisions = [SimpleNamespace(files = files, snapshot_path = str(snap))],
+ ), snap
+
+
+def test_deleting_a_variant_keeps_an_opt_in_dspark_drafter(tmp_path):
+ """DSpark is in no variant plan, so Studio never downloaded it with the quant
+ and must not reclaim it: that would destroy an ~11 GB file the user fetched
+ deliberately."""
+ from hub.services.models.deletion import _delete_gguf_variant_from_repos
+
+ repo, snap = _cache_repo(
+ tmp_path,
+ "unsloth/DeepSeek-V4-Flash-0731-GGUF",
+ ["model-Q4_K_M.gguf", "dspark/dspark-DeepSeek-V4-Flash-0731-BF16.gguf"],
+ )
+ _delete_gguf_variant_from_repos(
+ "unsloth/DeepSeek-V4-Flash-0731-GGUF", "Q4_K_M", [repo], None, root = tmp_path
+ )
+
+ assert not (snap / "model-Q4_K_M.gguf").is_symlink()
+ assert (snap / "dspark" / "dspark-DeepSeek-V4-Flash-0731-BF16.gguf").is_symlink()
+
+
+def test_deleting_the_last_variant_still_reclaims_mtp_and_mmproj(tmp_path):
+ """Positive control: those ARE fetched with every variant, so they still go."""
+ from hub.services.models.deletion import _delete_gguf_variant_from_repos
+
+ repo, snap = _cache_repo(
+ tmp_path, "org/Model-GGUF", ["model-Q4_K_M.gguf", "mtp-model.gguf", "mmproj-F16.gguf"]
+ )
+ _delete_gguf_variant_from_repos("org/Model-GGUF", "Q4_K_M", [repo], None, root = tmp_path)
+
+ assert not (snap / "model-Q4_K_M.gguf").is_symlink()
+ assert not (snap / "mtp-model.gguf").is_symlink()
+ assert not (snap / "mmproj-F16.gguf").is_symlink()
diff --git a/studio/backend/tests/test_picker_service.py b/studio/backend/tests/test_picker_service.py
index 30b117f6239..d3919914597 100644
--- a/studio/backend/tests/test_picker_service.py
+++ b/studio/backend/tests/test_picker_service.py
@@ -20,11 +20,15 @@ from picker.service import (
def test_iter_ggufs_skips_gguf_companions(tmp_path):
mtp_dir = tmp_path / "MTP"
mtp_dir.mkdir()
+ dspark_dir = tmp_path / "dspark"
+ dspark_dir.mkdir()
main = tmp_path / "model-Q8_0.gguf"
main.write_bytes(b"")
(tmp_path / "mmproj-F16.gguf").write_bytes(b"")
(tmp_path / "mtp-model-Q8_0.gguf").write_bytes(b"")
(mtp_dir / "model-Q8_0-MTP.gguf").write_bytes(b"")
+ # A DSpark drafter has its own chat template; probing it reads the wrong one.
+ (dspark_dir / "dspark-model-Q8_0.gguf").write_bytes(b"")
(tmp_path / "model-Q8_0-be.gguf").write_bytes(b"")
assert _iter_ggufs(tmp_path) == [main]
diff --git a/studio/backend/tests/test_resolve_quant_gguf.py b/studio/backend/tests/test_resolve_quant_gguf.py
index a137237e80f..f112fc19d6a 100644
--- a/studio/backend/tests/test_resolve_quant_gguf.py
+++ b/studio/backend/tests/test_resolve_quant_gguf.py
@@ -67,6 +67,18 @@ def test_skips_mtp_drafter_for_main_weights(tmp_path):
assert total == 100
+def test_skips_dspark_drafter_for_main_weights(tmp_path):
+ # Same contract for a DSpark drafter, whose filename carries a Q8_0 token.
+ root = tmp_path / "repo"
+ main = _write(root / "model-Q8_0.gguf", 100)
+ _write(root / "dspark" / "dspark-model-Q8_0.gguf", 50)
+
+ path, total = models_route._resolve_quant_gguf(str(root), "Q8_0", is_local = True)
+
+ assert path == str(main)
+ assert total == 100
+
+
def test_prefers_the_complete_snapshot(tmp_path, monkeypatch):
cache = tmp_path / "hub"
snaps = cache / "models--org--repo" / "snapshots"
diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.py
index 25a091bb748..aec0ed2b973 100644
--- a/studio/backend/utils/models/model_config.py
+++ b/studio/backend/utils/models/model_config.py
@@ -1233,22 +1233,36 @@ def _is_mmproj(filename: str) -> bool:
return "mmproj" in filename.lower()
+# Mirrors hub.utils.gguf._DRAFTER_KINDS / _DRAFTER_DIR_KINDS. A dflash/ folder
+# holds real weights, so dflash is a drafter by prefix only.
+_DRAFTER_KINDS = ("mtp", "dspark", "dflash")
+_DRAFTER_DIR_KINDS = ("mtp", "dspark")
+
+
def _is_mtp_drafter(path: str) -> bool:
- """True for a separate-file MTP drafter (speculative head), a companion
- to the main model rather than a selectable quant: the repo-root
- ``mtp-*.gguf`` or the ``MTP/`` subdir copies (Gemma 4).
-
- Mirrors hub.utils.gguf.is_mtp_drafter_path (utils cannot import hub).
- Must be excluded everywhere mmproj is, or the drafter leaks into variant
- menus (a phantom quant) and quant-matched file lookups -- e.g. a ``Q8_0``
- request must not resolve to ``MTP/...-Q8_0-MTP.gguf``, which sorts ahead
- of the real weight.
+ """True for a separate-file drafter, a companion to the main model rather
+ than a selectable quant: the repo-root ``mtp-*.gguf``, the ``MTP/`` subdir
+ copies (Gemma 4) or the ``dspark/`` drafters (DeepSeek V4 Flash).
+
+ Mirrors hub.utils.gguf.is_mtp_drafter_path (utils cannot import hub). Must be
+ excluded everywhere mmproj is, or the drafter leaks into variant menus (a
+ phantom quant) and quant-matched file lookups -- a ``Q8_0`` request must not
+ 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).
"""
- p = path.lower()
+ p = path.replace("\\", "/").lower()
if not p.endswith(".gguf"):
return False
- name = p.rsplit("/", 1)[-1]
- return name.startswith("mtp-") or "/mtp/" in f"/{p}"
+ parts = [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
+ )
# Family tokens for #5347's filename fallback. Lowercase; order irrelevant.