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.

Fix MOSS-Image GGUF discovery in On Device (#15168)

Lee Jackson6f7e26e078c1
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index 6828ed15a19..486ed945454 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -1678,6 +1678,8 @@ def _family_from_content(
vetoed = fam is None and any(
_best_family_match(model_identity(n).lower()) is not None for n in needles
)
+ if fam is None and not vetoed:
+ fam = _family_from_gguf_arch(path)
name, _ = resolve_family_with_content(fam.name if fam else None, path, "image", vetoed)
if name is None:
return None
@@ -1686,6 +1688,21 @@ def _family_from_content(
return detect_family("", override = name)
+def _family_from_gguf_arch(path: str) -> Optional[DiffusionFamily]:
+ """Family of a renamed local GGUF whose arch alone names it; the Images listing already offers it by arch."""
+ if not path.lower().endswith(".gguf"):
+ return None
+ try:
+ from utils.gguf_archs import FAMILY_NAMING_DIFFUSION_GGUF_ARCHS
+ from utils.models.gguf_metadata import read_gguf_architecture
+ arch = (read_gguf_architecture(path) or "").strip().lower()
+ except Exception: # noqa: BLE001 -- an unreadable header leaves the name verdict alone
+ return None
+ if arch not in FAMILY_NAMING_DIFFUSION_GGUF_ARCHS:
+ return None
+ return detect_family("", override = arch)
+
+
def resolve_base_repo(fam: DiffusionFamily, base_repo: Optional[str]) -> str:
"""The companion diffusers repo: caller-supplied if given, else the family fallback."""
base = (base_repo or "").strip()
diff --git a/studio/backend/tests/test_cached_gguf_routes.py b/studio/backend/tests/test_cached_gguf_routes.py
index 5f9354f28d0..a91823a69a3 100644
--- a/studio/backend/tests/test_cached_gguf_routes.py
+++ b/studio/backend/tests/test_cached_gguf_routes.py
@@ -2648,6 +2648,27 @@ def test_krea2_gguf_is_an_image_model_not_chat(monkeypatch):
assert models_route._arch_to_task("qwen_image", ("org/Qwen-Image-GGUF",)) == "text-to-image"
[email protected]("arch", ["moss_image", "MOSS_IMAGE"])
+ "hints",
+ [(), ("custom/renamed-Q4_K_M.gguf",), ("unsloth/MOSS-Image-SFT-GGUF",)],
+)
[email protected]("buildable", [True, False])
+def test_moss_image_gguf_inventory_uses_native_family_support(monkeypatch, arch, hints, buildable):
+ from core.inference import diffusion_engine_router as router
+
+ seen = []
+
+ def can_build(fam, *, model_kind):
+ seen.append((fam.name, model_kind))
+ return buildable
+
+ monkeypatch.setattr(router, "family_buildable_here", can_build)
+ expected = "text-to-image" if buildable else models_route._UNSUPPORTED_DIFFUSION_TASK
+ assert models_route._arch_to_task(arch, hints) == expected
+ assert seen == [("moss-image", "gguf")]
+
+
def test_arch_to_task_hides_unsupported_diffusion_from_chat():
assert models_route._arch_to_task("flux") == "text-to-image"
assert models_route._arch_to_task("z_image") == "text-to-image"
@@ -4782,6 +4803,40 @@ def test_cached_gguf_task_comes_from_the_snapshot_the_row_loads(monkeypatch, tmp
assert row["load_id"] == str(selected)
[email protected]("variant", ["SFT", "Base"])
+def test_cached_moss_gguf_is_listed_for_images(monkeypatch, tmp_path, variant):
+ from core.inference import diffusion_engine_router as router
+ from hub.services.models import cache_inventory
+
+ monkeypatch.setattr(router, "family_buildable_here", lambda fam, **kw: fam.name == "moss-image")
+ active = tmp_path / "hub"
+ repo_id = f"unsloth/MOSS-Image-{variant}-GGUF"
+ repo_dir = active / ("models--" + repo_id.replace("/", "--"))
+ snapshot = repo_dir / "snapshots" / "main-rev"
+ model = _arch_gguf(snapshot / f"MOSS-Image-{variant}-UD-Q4_K_XL.gguf", "moss_image")
+ (repo_dir / "refs").mkdir(parents = True)
+ (repo_dir / "refs" / "main").write_text("main-rev")
+ repo = _snapshot_repo(repo_id, repo_dir, snapshot, [_file(model.name, model.stat().st_size)])
+ [row] = cache_inventory._scan_cached_gguf(
+ cache_scans = [SimpleNamespace(repos = [repo])], active_hub_cache = active
+ )
+ assert row["repo_id"] == repo_id
+ assert row["task"] == "text-to-image"
+ assert row["partial"] is False
+
+
+ ("arch", "family"), [("moss_image", "moss-image"), ("krea2", "krea-2"), ("llama", None)]
+)
+def test_renamed_local_gguf_loads_as_the_family_its_arch_names(tmp_path, arch, family):
+ """The listing offers a renamed family-naming GGUF on Images from its arch alone; the loader must agree."""
+ from core.inference.diffusion_families import detect_family_for_pick
+
+ model = _arch_gguf(tmp_path / "custom" / "renamed-Q4_K_M.gguf", arch)
+ assert getattr(detect_family_for_pick(str(model)), "name", None) == family
+ assert getattr(detect_family_for_pick(str(model.parent), model.name), "name", None) == family
+
+
def test_a_mixed_local_gguf_folder_classifies_the_same_in_either_walk_order(tmp_path, monkeypatch):
"""The local twin, and the half that made an image model unfindable: with the encoder answering
first the folder is tagged ``text-generation``, which drops it out of the Images picker
diff --git a/studio/backend/utils/gguf_archs.py b/studio/backend/utils/gguf_archs.py
index d6d6d388d43..9fbbce5d85c 100644
--- a/studio/backend/utils/gguf_archs.py
+++ b/studio/backend/utils/gguf_archs.py
@@ -53,10 +53,11 @@ DIFFUSION_IMAGE_GGUF_ARCHS = frozenset(
"z_image",
"zimage",
"krea2",
+ "moss_image",
}
)
# Archs that alone name the family. Not "flux" / "qwen_image": several DiTs ship under those (#14474).
-FAMILY_NAMING_DIFFUSION_GGUF_ARCHS = frozenset({"krea2"})
+FAMILY_NAMING_DIFFUSION_GGUF_ARCHS = frozenset({"krea2", "moss_image"})
# Recognised, but no Studio page can run them.
UNSUPPORTED_DIFFUSION_GGUF_ARCHS = frozenset(
{"sd1", "sd3", "sdxl", "aura", "hidream", "cosmos", "hyvid"}