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.

Unsloth Studio: refuse picking a hosted FP8/INT8 checkpoint repo as a pipeline before it downloads (#11829)

Leo Borcherdingc7ea18c0a1d3
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py
index 6cdd9e09911..018917bf99a 100644
--- a/studio/backend/core/inference/diffusion.py
+++ b/studio/backend/core/inference/diffusion.py
@@ -59,6 +59,8 @@ from .diffusion_families import (
detect_family_for_pick,
excluded_model_reason,
prefer_ungated_mirror,
+ prequant_only_repo_ids,
+ prequant_repo_role,
resolve_base_repo,
resolve_local_gguf_child,
supported_family_names,
@@ -2569,6 +2571,24 @@ class DiffusionBackend:
f"pass family_override with that family name. (Video models and image models "
f"whose diffusers transformer has no single-file loader are not supported.)"
)
+ # Prequant repos have no model_index.json (a pipeline pick staged GBs, then 404d); a same-named local dir is a real pipeline.
+ if (
+ kind == "pipeline"
+ and repo_id.strip().lower() in prequant_only_repo_ids()
+ and not _is_local_path(repo_id)
+ ):
+ bases, schemes, te_schemes = prequant_repo_role(fam, repo_id)
+ shown = " or ".join(bases) or fam.base_repo
+ knobs = []
+ if schemes:
+ knobs.append(f"the transformer precision to {' or '.join(schemes)}")
+ if te_schemes:
+ knobs.append(f"the text encoder precision to {' or '.join(te_schemes)}")
+ raise ValueError(
+ f"'{repo_id}' hosts pre-quantised checkpoints for {shown} and is not a diffusers pipeline "
+ f"(it has no model_index.json). Pick {shown} and set {' and '.join(knobs) or 'a precision'} "
+ f"instead."
+ )
# Refuse a too-old diffusers here, not deep in the load, but only when this load builds the diffusers
# pipeline: a GGUF this host routes to native sd.cpp never instantiates the class. The picker gate reads the
# same predicate. Imported here, not at module import, because the router imports this module's siblings.
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index a05cfebaead..b05a138f057 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -1696,6 +1696,54 @@ def sd_cpp_companion_only_repo_ids() -> frozenset[str]:
return frozenset(r.strip().lower() for r in companions - loadable if r)
+def prequant_only_repo_ids() -> frozenset[str]:
+ """Repos hosting only prequant checkpoints (no model_index.json), never a base or mirror."""
+ hosted: set[str] = set()
+ bases: set[str] = set()
+ for fam in _FAMILIES:
+ hosted.update(repo for _scheme, repo in fam.prequant_repos)
+ hosted.update(repo for _base, _scheme, repo in fam.prequant_variant_repos)
+ hosted.update(repo for _scheme, _component, repo in fam.te_prequant_repos)
+ bases.add(fam.base_repo)
+ bases.update(fam.train_base_repos)
+ if fam.deploy_base_repo:
+ bases.add(fam.deploy_base_repo)
+ bases.update(rid for pair in _MIRROR_PAIRS for rid in pair)
+ lowered = {b.strip().lower() for b in bases if b}
+ return frozenset(r.strip().lower() for r in hosted if r and r.strip().lower() not in lowered)
+
+
+def prequant_repo_role(
+ fam: DiffusionFamily, repo_id: str
+) -> tuple[tuple[str, ...], tuple[str, ...], tuple[str, ...]]:
+ key = (repo_id or "").strip().lower()
+ known = {
+ b.lower(): b
+ for b in (fam.base_repo, *fam.train_base_repos, fam.deploy_base_repo or "")
+ if b
+ }
+ bases: list[str] = []
+ schemes: list[str] = []
+ for entry_base, scheme, repo in fam.prequant_variant_repos:
+ if repo.strip().lower() == key:
+ bases.append(known.get(entry_base.lower(), entry_base))
+ schemes.append(scheme)
+ for scheme, repo in fam.prequant_repos:
+ if repo.strip().lower() == key:
+ bases.append(fam.base_repo)
+ schemes.append(scheme)
+ te = sorted(
+ {
+ scheme
+ for scheme, _component, repo in fam.te_prequant_repos
+ if repo.strip().lower() == key
+ }
+ )
+ if te and not bases:
+ bases.append(fam.base_repo)
+ return tuple(dict.fromkeys(bases)), tuple(sorted(set(schemes))), tuple(te)
+
+
def sd_cpp_text_encoder_candidates(fam: DiffusionFamily) -> tuple[tuple[str, str, str], ...]:
"""EVERY text-encoder set an sd.cpp load of *fam* could pick, unioned. For the guard, not for a
load: a load reads the GGUF header and picks one, while a guard reconstructing a checkpoint
diff --git a/studio/backend/tests/test_diffusion_backend.py b/studio/backend/tests/test_diffusion_backend.py
index 32a831d953e..4e1e0645e1d 100644
--- a/studio/backend/tests/test_diffusion_backend.py
+++ b/studio/backend/tests/test_diffusion_backend.py
@@ -2073,6 +2073,20 @@ def test_load_pipeline_rejects_non_unsloth_repo(fake_runtime):
backend.load_pipeline("randomorg/Z-Image-bnb-4bit", family_override = "z-image")
+def test_validate_refuses_a_pipeline_pick_of_a_hosted_prequant_repo(fake_runtime):
+ from core.inference.diffusion_families import _FAMILIES, prequant_only_repo_ids
+
+ backend = DiffusionBackend()
+ with pytest.raises(ValueError, match = "Qwen/Qwen-Image-2.1") as excinfo:
+ backend.validate_load_request("unsloth/Qwen-Image-2.1-FP8")
+ message = str(excinfo.value)
+ assert "transformer precision to fp8 or int8" in message
+ assert "text encoder precision to fp8" in message
+ ids = prequant_only_repo_ids()
+ assert "unsloth/qwen-image-2.1-fp8" in ids
+ assert not any(fam.base_repo.lower() in ids for fam in _FAMILIES)
+
+
def test_load_sdxl_rejects_untrusted_repo(fake_runtime):
"""A random non-allowlisted, non-unsloth repo is still rejected for a full pipeline
load even when it detects as SDXL -- the allowlist is exact-match only."""