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: refuse a text-encoder GGUF picked as the image or video model (#13423)

Daniel Hane6d9ff5a5d67
diff --git a/studio/backend/core/inference/diffusion_compat.py b/studio/backend/core/inference/diffusion_compat.py
index 36c55e6bf46..dc5b27d86f9 100644
--- a/studio/backend/core/inference/diffusion_compat.py
+++ b/studio/backend/core/inference/diffusion_compat.py
@@ -588,7 +588,7 @@ def speech_pick_refusal(
hf_token: Optional[str] = None,
allow_network: bool = True,
) -> Optional[str]:
- """Why this diffusion pick cannot load, when it names a speech GGUF, else None.
+ """Why this diffusion pick cannot load, when it names a speech or text-encoder GGUF, else None.
A media pick names its file, and ``detect_family_for_pick`` resolves the family from the FOLDER
rather than that name, so a csm quant sitting beside a FLUX denoiser answers flux.1: the pick
@@ -612,6 +612,16 @@ def speech_pick_refusal(
f"'{os.path.basename(gguf_filename)}' is a {named}speech checkpoint, which no image "
"or video backend can decode. Pick one of this folder's media GGUFs instead."
)
+ # A text-encoder GGUF (a FLUX.2-klein Qwen3 encoder repo tagged text-to-image, #9875) matches a family by name, then
+ # loads as the denoiser with every tensor unmapped and dies in .to() with "Cannot copy out of meta tensor".
+ from core.inference.diffusion_content import _TE_GGUF_ARCHS
+
+ if arch in _TE_GGUF_ARCHS:
+ return (
+ f"'{os.path.basename(gguf_filename)}' is a text encoder ({arch} GGUF), not a diffusion "
+ "model (DiT/UNet), so it cannot be loaded as the image or video model. Pick the "
+ "model's diffusion GGUF instead."
+ )
return None
diff --git a/studio/backend/tests/test_diffusion_compat_preflight.py b/studio/backend/tests/test_diffusion_compat_preflight.py
index 2aba2fca316..4302c9b596a 100644
--- a/studio/backend/tests/test_diffusion_compat_preflight.py
+++ b/studio/backend/tests/test_diffusion_compat_preflight.py
@@ -1060,6 +1060,23 @@ def test_a_runnable_media_pick_in_the_same_repo_still_loads(monkeypatch):
diffusion_compat.assert_pick_is_not_speech(CSM_REPO, DENOISER_FILE)
+TE_REPO = "ponpoke/flux2-klein-9b-uncensored-text-encoder"
+TE_FILE = "flux2-klein-9b-uncensored-q4_k_m.gguf"
+
+
+def test_an_undownloaded_text_encoder_pick_is_refused_before_any_download(monkeypatch):
+ """#9875: the repo name matches flux.2-klein, so without this the Qwen3 encoder loads as the denoiser and dies
+ with "Cannot copy out of meta tensor" after the download and the teardown."""
+ requests = _stub_range_reads(monkeypatch, {TE_FILE: _arch_header("qwen3")})
+
+ with pytest.raises(ValueError) as excinfo:
+ diffusion_compat.assert_pick_is_not_speech(TE_REPO, TE_FILE)
+
+ detail = str(excinfo.value)
+ assert TE_FILE in detail and "text encoder (qwen3 GGUF)" in detail
+ assert len(requests) == 1
+
+
def test_an_unreadable_speech_header_fails_open(monkeypatch):
"""Fail-open throughout: refusing a pick that works is worse than the download this saves."""
_stub_range_reads(monkeypatch, {}, status = 200)