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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: resolve the FLUX.2-klein 9B base for a local ComfyUI file (#13290)
Daniel Hanaced791b6cab
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.pyindex 5de535c5d8c..09d897f4444 100644--- a/studio/backend/core/inference/diffusion_families.py+++ b/studio/backend/core/inference/diffusion_families.py@@ -299,6 +299,12 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (("fp8", "unsloth/FLUX.2-klein-4B-FP8"),),aliases = ("flux2-klein",),+ # A local ComfyUI file has no card tag, so without these a 9B pick got the 4B base and was refused.+ named_variant_bases = (+ "black-forest-labs/FLUX.2-klein-9B",+ "black-forest-labs/FLUX.2-klein-base-9B",+ "black-forest-labs/FLUX.2-klein-base-4B",+ ),# Train the undistilled bases, then preview their adapters on the matching 4-step models. Both vendor ids# resolve through the ungated mirrors at fetch time.trainable = True,diff --git a/studio/backend/tests/test_diffusion_more_families.py b/studio/backend/tests/test_diffusion_more_families.pyindex c79fe714134..438eab9f3a1 100644--- a/studio/backend/tests/test_diffusion_more_families.py+++ b/studio/backend/tests/test_diffusion_more_families.py@@ -969,6 +969,38 @@ def test_a_local_turbo_gguf_resolves_the_turbo_base_by_name(assert dmod._resolve_base_repo(str(tmp_path), None, fam, None, name) == expected+ "name, expected",+ [+ ("flux-2-klein-9b.safetensors", "black-forest-labs/FLUX.2-klein-9B"),+ ("flux-2-klein-9b-fp8.safetensors", "black-forest-labs/FLUX.2-klein-9B"),+ ("flux-2-klein-9b-Q4_K_M.gguf", "black-forest-labs/FLUX.2-klein-9B"),+ ("flux-2-klein-base-9b.safetensors", "black-forest-labs/FLUX.2-klein-base-9B"),+ ("flux-2-klein-base-4b.safetensors", "black-forest-labs/FLUX.2-klein-base-4B"),+ ("flux-2-klein-4b.safetensors", "black-forest-labs/FLUX.2-klein-4B"),+ ("flux-2-klein-4b-Q4_K_M.gguf", "black-forest-labs/FLUX.2-klein-4B"),+ ],+)+def test_a_local_klein_file_resolves_its_variant_base_by_name(+ monkeypatch, tmp_path, name, expected+):+ from core.inference import diffusion as dmod+ from core.inference.diffusion_compat import flux2_pick_mismatch+ from core.inference.diffusion_families import detect_family_for_pick++ monkeypatch.setattr(dmod, "_hf_base_model", lambda repo_id, token: None)+ monkeypatch.setattr(dmod, "_remember_companion_base", lambda repo_id, base: None)+ fam = detect_family_for_pick(str(tmp_path), name, "flux.2-klein")+ base = dmod._resolve_base_repo(str(tmp_path), None, fam, None, name)+ assert base == expected+ if name.endswith(".gguf"):+ import core.inference.diffusion_compat as compat++ dim = 4096 if "9b" in name else 3072+ monkeypatch.setattr(compat, "flux2_inner_dim_for_pick", lambda *a, **k: dim)+ assert flux2_pick_mismatch(fam, str(tmp_path), name, base) is None++@pytest.mark.parametrize("repo, gguf, expected",[