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: classify qwen_image21 GGUFs as text-to-image (#13333)

Abhishek Acharyaa4b9c624d647
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index f998caaab3d..8904e2e8954 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -21058,6 +21058,7 @@ class LlamaCppBackend:
_IMAGE_ARCHES = frozenset(
(
"qwen_image",
+ "qwen_image21",
"flux",
)
)
@@ -21151,6 +21152,16 @@ class LlamaCppBackend:
logger.debug("Family probe failed for video arch: %s", e)
return True
+ @staticmethod
+ def _image_arch_is_pickable(gguf_path: Optional[str], model_identifier: Optional[str]) -> 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 "")))
+ 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
+
@staticmethod
def _ambiguous_image_arch_is_pickable(
gguf_path: Optional[str], model_identifier: Optional[str]
@@ -21259,9 +21270,16 @@ 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):
+ return (
+ f"This is an image-generation GGUF (architecture '{arch}'), which "
+ "cannot run as a chat model. Open it from the Images page instead."
+ )
return (
f"This is an image-generation GGUF (architecture '{arch}'), which "
- "cannot run as a chat model. Open it from the Images page instead."
+ "cannot run as a chat model. No image engine installed here can build "
+ "this model family, so the Images page does not list it either. "
+ "Updating Unsloth may add support for it."
)
if arch in self._AMBIGUOUS_IMAGE_ARCHES:
if self._ambiguous_image_arch_is_pickable(gguf_path, self._model_identifier):
@@ -22070,7 +22088,10 @@ class LlamaCppBackend:
"a chat/completion model. Unsloth cannot assemble this particular "
"model from a GGUF, so the Video page does not list it either."
)
- if arch in LlamaCppBackend._IMAGE_ARCHES or (
+ if (
+ arch in LlamaCppBackend._IMAGE_ARCHES
+ and LlamaCppBackend._image_arch_is_pickable(gguf_path, model_identifier)
+ ) or (
arch in LlamaCppBackend._AMBIGUOUS_IMAGE_ARCHES
and LlamaCppBackend._ambiguous_image_arch_is_pickable(gguf_path, model_identifier)
):
@@ -22080,6 +22101,13 @@ class LlamaCppBackend:
"Unsloth's Images page to generate with local diffusion "
"GGUFs such as FLUX and Qwen-Image."
)
+ if arch in LlamaCppBackend._IMAGE_ARCHES:
+ return (
+ f"'{arch}' is a diffusion (image-generation) GGUF, which "
+ "llama-server cannot run as a chat/completion model. No image engine "
+ "installed here can build this model family, so Unsloth's Images page "
+ "does not list it either. Updating Unsloth may add support for it."
+ )
if arch in LlamaCppBackend._AMBIGUOUS_IMAGE_ARCHES:
# Same shared-arch resolution as the pre-launch refusal: unresolved means
# the Images picker tags it image-diffusion-unsupported and hides the row.
diff --git a/studio/backend/hub/services/models/catalog_classification.py b/studio/backend/hub/services/models/catalog_classification.py
index 57d33f5357d..30d3b7afbd1 100644
--- a/studio/backend/hub/services/models/catalog_classification.py
+++ b/studio/backend/hub/services/models/catalog_classification.py
@@ -24,7 +24,9 @@ from utils.gguf_archs import (
from utils.paths.path_utils import file_contents_available_locally
-_DIFFUSION_GGUF_ARCHS = frozenset({"flux", "flux2", "qwen_image", "qwenimage", "z_image", "zimage"})
+_DIFFUSION_GGUF_ARCHS = frozenset(
+ {"flux", "flux2", "qwen_image", "qwenimage", "qwen_image21", "qwenimage21", "z_image", "zimage"}
+)
_UNSUPPORTED_DIFFUSION_GGUF_ARCHS = frozenset(
{"sd1", "sd3", "sdxl", "aura", "hidream", "cosmos", "hyvid"}
)
@@ -281,7 +283,7 @@ def _arch_to_task(arch: Optional[str], name_hints: tuple[Optional[str], ...] = (
if any(_is_h3_bundle_gguf_hint(hint) for hint in name_hints):
return _VIDEO_GEN_TASK
if arch is None:
- # Qwen-Image-2.1 GGUFs have kv_count 0, so the name is the only evidence, as for a cloud placeholder.
+ # unsloth/Qwen-Image-2.1-GGUF has kv_count 0 (others declare "qwen_image21"): the name is the only evidence.
return _unhydrated_gguf_task(name_hints)
normalized = arch.lower()
if is_audio_cpp_gguf_architecture(normalized):
diff --git a/studio/backend/tests/test_cached_gguf_routes.py b/studio/backend/tests/test_cached_gguf_routes.py
index f2a96e9ed6d..fc1cb614138 100644
--- a/studio/backend/tests/test_cached_gguf_routes.py
+++ b/studio/backend/tests/test_cached_gguf_routes.py
@@ -2681,6 +2681,11 @@ 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"
assert models_route._arch_to_task("qwen_image") == "text-to-image"
+ # Qwen-Image-2.1 GGUFs that carry a header declare their own arch (#13328)
+ assert (
+ models_route._arch_to_task("qwen_image21", ("abenzerps/Qwen-Image-2.1-Uncensored-GGUF",))
+ == "text-to-image"
+ )
assert models_route._arch_to_task("llama") == "text-generation"
assert models_route._arch_to_task(None) is None
# Known-but-unsupported diffusion archs get a task that is neither chat nor a loadable image task, so both pickers skip them.
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 57fbfe194bd..6cc2b584ad9 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
@@ -436,3 +436,28 @@ def test_every_name_the_video_preflight_imports_from_routes_still_resolves():
f"core/inference/llama_cpp.py imports {missing} from routes.models, but routes.models "
f"does not bind them. The probe's broad except turns that into a silent fail-open."
)
+
+
+def test_an_image_arch_this_host_cannot_build_promises_no_page(tmp_path, monkeypatch):
+ # The catalog hides an unbuildable family, so the refusal must not name the Images page.
+ import core.inference.diffusion_engine_router as router
+
+ monkeypatch.setattr(router, "family_buildable_here", lambda fam, *, model_kind: False)
+ _, message = _refusal(
+ tmp_path,
+ arch = "qwen_image21",
+ name = "qwen-image-2.1-Q4_K_M.gguf",
+ identifier = "unsloth/Qwen-Image-2.1-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
+
+ monkeypatch.setattr(router, "family_buildable_here", lambda fam, *, model_kind: True)
+ _, message = _refusal(
+ tmp_path,
+ arch = "qwen_image21",
+ name = "qwen-image-2.1-Q4_K_M.gguf",
+ identifier = "unsloth/Qwen-Image-2.1-GGUF",
+ )
+ assert "Open it from the Images page" in message
diff --git a/studio/backend/tests/test_llama_cpp_start_failure_classification.py b/studio/backend/tests/test_llama_cpp_start_failure_classification.py
index 6f3d7b62d03..599db9a32dd 100644
--- a/studio/backend/tests/test_llama_cpp_start_failure_classification.py
+++ b/studio/backend/tests/test_llama_cpp_start_failure_classification.py
@@ -72,6 +72,16 @@ class TestDiffusionArchitectures:
assert "Images page" in msg
assert arch in msg
+ def test_an_image_arch_this_host_cannot_build_promises_no_page(self, monkeypatch):
+ import core.inference.diffusion_engine_router as router
+
+ monkeypatch.setattr(router, "family_buildable_here", lambda fam, *, model_kind: False)
+ out = "error loading model: unknown model architecture: 'qwen_image21'"
+ msg = _classify(out, "/models/qwen-image-2.1-Q4_K_M.gguf", "unsloth/Qwen-Image-2.1-GGUF")
+ assert "qwen_image21" in msg
+ assert "Use Unsloth's Images page to generate" not in msg
+ assert "does not list it either" in msg
+
# A video arch must name the VIDEO page: Images cannot run it either.
@pytest.mark.parametrize("arch", sorted(LlamaCppBackend._VIDEO_ARCHES))
def test_every_video_arch_routes_to_the_video_page(self, arch):