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: skip the DFlash size request when no sidecar is eligible (#15754)

Daniel Hand4e8ae82ff76
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index 7c3877c192e..fb87fce8546 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -20011,6 +20011,16 @@ class LlamaCppBackend:
for name in candidates
if name.lower().endswith(".gguf") and not _is_root_dflash_drafter_path(name)
]
+ eligible = [
+ name
+ for name in candidates
+ if _is_root_dflash_drafter_path(name)
+ and Path(name).name not in rejected
+ # Before ranking, as dflash_plan_files: the fetch refuses a half-listed set, and returning one would end the loop.
+ and split_listing_is_complete(candidates, name)
+ ]
+ if not eligible:
+ return None
# Same size bound as dflash_plan_files: header reads only after download, a drafter is a few layers of its target, and an unlisted size keeps the candidate.
sizes = self._remote_root_gguf_sizes(hf_repo, hf_token)
try:
@@ -20020,13 +20030,9 @@ class LlamaCppBackend:
files = sorted(
(
name
- for name in candidates
- if _is_root_dflash_drafter_path(name)
- and Path(name).name not in rejected
- # Before ranking, as dflash_plan_files: the fetch refuses a half-listed set, and returning one would end the loop.
- and split_listing_is_complete(candidates, name)
+ for name in eligible
# Whole set, not the picked shard: each half of a split weight can sit under the target while the set does not.
- and not (
+ if not (
target_bytes and _drafter_set_bytes(sizes, Path(name).name) >= target_bytes
)
),
diff --git a/studio/backend/tests/test_mtp_drafter_companion.py b/studio/backend/tests/test_mtp_drafter_companion.py
index 07a0bda52ec..b1e4eeec650 100644
--- a/studio/backend/tests/test_mtp_drafter_companion.py
+++ b/studio/backend/tests/test_mtp_drafter_companion.py
@@ -4263,3 +4263,32 @@ def test_forced_dflash_on_an_mrope_vision_load_still_launches_and_warns(monkeypa
)
assert seen["dflash_fetched"] is True
assert any("DFlash forced" in m for m in seen["warnings"])
+
+
+ "listing, sized",
+ [
+ (["model-Q4_K_M.gguf", "mmproj-F16.gguf", "MTP/mtp-model.gguf"], False),
+ (["model-Q4_K_M.gguf", "sub/dflash-model.gguf"], False),
+ (["model-Q4_K_M.gguf", "dflash-model-00001-of-00002.gguf"], False),
+ (["model-Q4_K_M.gguf", "dflash-model.gguf"], True),
+ ],
+)
+def test_download_dflash_asks_the_hub_for_sizes_only_with_a_candidate(
+ monkeypatch, tmp_path, listing, sized
+):
+ """No eligible root sidecar, no model_info(files_metadata=True) call."""
+ from core.inference.llama_cpp import LlamaCppBackend
+
+ weight = tmp_path / "model-Q4_K_M.gguf"
+ weight.write_bytes(b"x" * 10_000)
+ calls = []
+
+ def _sizes(repo, token = None):
+ calls.append(repo)
+ return {}
+
+ monkeypatch.setattr(LlamaCppBackend, "_remote_root_gguf_sizes", staticmethod(_sizes))
+ picked = _dflash_download_pick(monkeypatch, listing = listing, near_path = str(weight))
+ assert picked == ("dflash-model.gguf" if sized else None)
+ assert len(calls) == (1 if sized else 0)