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: route krea2 GGUFs to Images instead of opening them as chat models (#14477)

Indrajit swain5ff3fa4bf601
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index 09644a72e00..916c8e30bc6 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -22052,6 +22052,8 @@ class LlamaCppBackend:
"qwen_image",
"qwen_image21",
"flux",
+ # Krea 2 GGUFs from some converters (molbal/krea2-gguf), #14474.
+ "krea2",
)
)
# Archs shared by more than one family, so the header alone does NOT say whether the
@@ -22145,11 +22147,19 @@ class LlamaCppBackend:
return True
@staticmethod
- def _image_arch_is_pickable(gguf_path: Optional[str], model_identifier: Optional[str]) -> bool:
+ def _image_arch_is_pickable(
+ gguf_path: Optional[str],
+ model_identifier: Optional[str],
+ arch: Optional[str] = None,
+ ) -> bool:
"""The Images picker's fail-open buildability gate (Qwen-Image-2.1 needs diffusers 0.41)."""
try:
- from routes.models import _gguf_family_buildable
- return _gguf_family_buildable((model_identifier, os.path.basename(gguf_path or "")))
+ from routes.models import _diffusion_gguf_family_hints, _gguf_family_buildable
+ return _gguf_family_buildable(
+ _diffusion_gguf_family_hints(
+ arch, (model_identifier, os.path.basename(gguf_path or ""))
+ )
+ )
except Exception as e: # noqa: BLE001 -- never lose the page over a probe failure
logger.debug("Family probe failed for image arch: %s", e)
return True
@@ -22262,7 +22272,7 @@ class LlamaCppBackend:
"from a GGUF, so the Video page does not list it either."
)
if arch in self._IMAGE_ARCHES:
- if self._image_arch_is_pickable(gguf_path, self._model_identifier):
+ if self._image_arch_is_pickable(gguf_path, self._model_identifier, arch):
return (
f"This is an image-generation GGUF (architecture '{arch}'), which "
"cannot run as a chat model. Open it from the Images page instead."
@@ -23082,7 +23092,7 @@ class LlamaCppBackend:
)
if (
arch in LlamaCppBackend._IMAGE_ARCHES
- and LlamaCppBackend._image_arch_is_pickable(gguf_path, model_identifier)
+ and LlamaCppBackend._image_arch_is_pickable(gguf_path, model_identifier, arch)
) or (
arch in LlamaCppBackend._AMBIGUOUS_IMAGE_ARCHES
and LlamaCppBackend._ambiguous_image_arch_is_pickable(gguf_path, model_identifier)
diff --git a/studio/backend/hub/services/models/catalog_classification.py b/studio/backend/hub/services/models/catalog_classification.py
index 30d3b7afbd1..60eb39022dd 100644
--- a/studio/backend/hub/services/models/catalog_classification.py
+++ b/studio/backend/hub/services/models/catalog_classification.py
@@ -25,8 +25,20 @@ from utils.paths.path_utils import file_contents_available_locally
_DIFFUSION_GGUF_ARCHS = frozenset(
- {"flux", "flux2", "qwen_image", "qwenimage", "qwen_image21", "qwenimage21", "z_image", "zimage"}
+ {
+ "flux",
+ "flux2",
+ "qwen_image",
+ "qwenimage",
+ "qwen_image21",
+ "qwenimage21",
+ "z_image",
+ "zimage",
+ "krea2",
+ }
)
+# Archs that alone name the family. Not "flux" / "qwen_image": several DiTs ship under those (#14474).
+_FAMILY_NAMING_DIFFUSION_GGUF_ARCHS = frozenset({"krea2"})
_UNSUPPORTED_DIFFUSION_GGUF_ARCHS = frozenset(
{"sd1", "sd3", "sdxl", "aura", "hidream", "cosmos", "hyvid"}
)
@@ -117,6 +129,16 @@ def _gguf_family_buildable(name_hints: tuple[Optional[str], ...]) -> bool:
return True
+def _diffusion_gguf_family_hints(
+ arch: Optional[str], name_hints: tuple[Optional[str], ...]
+) -> tuple[Optional[str], ...]:
+ """``name_hints`` led by the architecture when it alone names the family."""
+ normalized = (arch or "").strip().lower()
+ if normalized in _FAMILY_NAMING_DIFFUSION_GGUF_ARCHS:
+ return (normalized, *name_hints)
+ return tuple(name_hints)
+
+
def _video_family_buildable(family) -> bool:
try:
from core.inference.diffusion_families import family_pipeline_available
@@ -302,7 +324,9 @@ def _arch_to_task(arch: Optional[str], name_hints: tuple[Optional[str], ...] = (
return _SPEECH_TASK
if normalized in _DIFFUSION_GGUF_ARCHS:
return (
- "text-to-image" if _gguf_family_buildable(name_hints) else _UNSUPPORTED_DIFFUSION_TASK
+ "text-to-image"
+ if _gguf_family_buildable(_diffusion_gguf_family_hints(normalized, name_hints))
+ else _UNSUPPORTED_DIFFUSION_TASK
)
if normalized in _VIDEO_GGUF_ARCHS:
from core.inference.video_families import detect_video_family
diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py
index 9b85dd5bd48..c6a93e288c6 100644
--- a/studio/backend/routes/models.py
+++ b/studio/backend/routes/models.py
@@ -68,6 +68,7 @@ _MAX_TASK_CLASSIFY_GGUFS = _catalog_classification._MAX_TASK_CLASSIFY_GGUFS
_PLACEHOLDER_DIFFUSION_GGUF_ARCHS = _catalog_classification._PLACEHOLDER_DIFFUSION_GGUF_ARCHS
_TASK_CLASSIFY_READ_SECONDS = _catalog_classification._TASK_CLASSIFY_READ_SECONDS
_gguf_family_buildable = _catalog_classification._gguf_family_buildable
+_diffusion_gguf_family_hints = _catalog_classification._diffusion_gguf_family_hints
_is_h3_bundle_gguf_hint = _catalog_classification._is_h3_bundle_gguf_hint
SPEECH_GGUF_ARCHS = _gguf_archs.SPEECH_GGUF_ARCHS
is_speech_gguf_architecture = _gguf_archs.is_speech_gguf_architecture
diff --git a/studio/backend/tests/test_cached_gguf_routes.py b/studio/backend/tests/test_cached_gguf_routes.py
index e247f2292f7..8795dfb90d6 100644
--- a/studio/backend/tests/test_cached_gguf_routes.py
+++ b/studio/backend/tests/test_cached_gguf_routes.py
@@ -2683,6 +2683,34 @@ def test_legacy_delete_delegates_to_shared_service(monkeypatch):
assert calls == [("org/repo", None, "token", "/data/hf/hub")]
+def test_krea2_gguf_is_an_image_model_not_chat(monkeypatch):
+ """krea2-arch GGUFs (molbal/krea2-gguf) are images, not chat RUN (#14474)."""
+ for hints in (
+ (),
+ ("custom/my-mix-Q4_K_M.gguf",),
+ ("molbal/krea2-gguf", "krea2_turbo-Q4_0.gguf"),
+ ):
+ assert models_route._arch_to_task("krea2", hints) == "text-to-image"
+ assert models_route._arch_to_task("KREA2", hints) == "text-to-image"
+
+ # The arch alone names the family, so an unbuildable host hides even an uninformative name.
+ import core.inference.diffusion_engine_router as router
+
+ seen = []
+
+ def buildable(fam, *, model_kind):
+ seen.append((fam.name, model_kind))
+ return fam.name != "krea-2"
+
+ monkeypatch.setattr(router, "family_buildable_here", buildable)
+ assert models_route._arch_to_task("krea2", ("custom/my-mix-Q4_K_M.gguf",)) == (
+ models_route._UNSUPPORTED_DIFFUSION_TASK
+ )
+ assert seen == [("krea-2", "gguf")]
+ assert models_route._arch_to_task("flux", ("custom/my-mix-Q4_K_M.gguf",)) == "text-to-image"
+ assert models_route._arch_to_task("qwen_image", ("org/Qwen-Image-GGUF",)) == "text-to-image"
+
+
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"
diff --git a/studio/backend/tests/test_llama_cpp_non_chat_gguf_preflight.py b/studio/backend/tests/test_llama_cpp_non_chat_gguf_preflight.py
index bed693bbce2..64eedd64e82 100644
--- a/studio/backend/tests/test_llama_cpp_non_chat_gguf_preflight.py
+++ b/studio/backend/tests/test_llama_cpp_non_chat_gguf_preflight.py
@@ -459,3 +459,32 @@ def test_an_image_arch_this_host_cannot_build_promises_no_page(tmp_path, monkeyp
identifier = "unsloth/Qwen-Image-2.1-GGUF",
)
assert "Open it from the Images page" in message
+
+
[email protected]("name", ["krea2_turbo-Q4_0.gguf", "my-custom-mix-Q8_0.gguf"])
+def test_a_krea2_gguf_names_the_images_page(tmp_path, name):
+ # Was "does not recognise this GGUF's model architecture ('krea2')" from llama-server (#14474).
+ _, message = _refusal(tmp_path, arch = "krea2", name = name)
+ assert message is not None
+ assert "Open it from the Images page" in message
+ assert "Video page" not in message
+
+
+def test_a_krea2_gguf_this_host_cannot_build_promises_no_page(tmp_path, monkeypatch):
+ import core.inference.diffusion_engine_router as router
+
+ monkeypatch.setattr(
+ router, "family_buildable_here", lambda fam, *, model_kind: fam.name != "krea-2"
+ )
+ _, message = _refusal(tmp_path, arch = "krea2", name = "my-custom-mix-Q8_0.gguf")
+ assert message is not None
+ assert "cannot run as a chat model" in message
+ assert "Open it from the Images page" not in message
+ text = LlamaCppBackend._classify_start_failure_text(
+ "error loading model: unknown model architecture: 'krea2'",
+ str(tmp_path / "my-custom-mix-Q8_0.gguf"),
+ None,
+ )
+ assert "krea2" in text
+ assert "Use Unsloth's Images page to generate" not in text
+ assert "does not list it either" in text