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: use the edge Gemma 4 template for the QAT E2B/E4B repos (#12715)
Pundarikaksh Narayan Tripathi7f4945c668f7
diff --git a/studio/backend/core/inference/chat_templates.py b/studio/backend/core/inference/chat_templates.pyindex 50d767b46c6..ae2ae2fc2d0 100644--- a/studio/backend/core/inference/chat_templates.py+++ b/studio/backend/core/inference/chat_templates.py@@ -31,7 +31,10 @@ _GEMMA4_GGUF_RE = re.compile(r"^unsloth/gemma-4-.+-gguf$", re.IGNORECASE)# Google ships two distinct gemma-4 chat templates: E2B/E4B omit the empty "<|channel>thought<channel|>" block on# enable_thinking=false, while the 12b/26B-A4B/31B family emits it. Route the two GGUF families to the matching# bundled template so each keeps its model's intended behavior.-_GEMMA4_EDGE_GGUF_RE = re.compile(r"^unsloth/gemma-4-e[24]b-it-gguf$", re.IGNORECASE)+# The QAT repos (gemma-4-E4B-it-qat-GGUF, plus the -qat-mobile builds) are the same edge models under a longer name.+# Without the optional suffix they fell through to the standard template and got the empty thought block on+# thinking-off, so the Think toggle did nothing (#12708).+_GEMMA4_EDGE_GGUF_RE = re.compile(r"^unsloth/gemma-4-e[24]b-it(?:-qat(?:-mobile)?)?-gguf$", re.IGNORECASE)_GEMMA4_TEMPLATE_FILE = "gemma-4.jinja"_GEMMA4_EDGE_TEMPLATE_FILE = "gemma-4-edge.jinja"diff --git a/studio/backend/tests/test_gemma4_chat_template_override.py b/studio/backend/tests/test_gemma4_chat_template_override.pyindex 067ce303df2..96796d06267 100644--- a/studio/backend/tests/test_gemma4_chat_template_override.py+++ b/studio/backend/tests/test_gemma4_chat_template_override.py@@ -100,6 +100,8 @@ def _detect_reasoning_flags():("unsloth/gemma-4-E4B-it-GGUF", True),("unsloth/gemma-4-31B-it-GGUF", True),("unsloth/gemma-4-26B-A4B-it-GGUF", True),+ ("unsloth/gemma-4-E4B-it-qat-GGUF", True),+ ("unsloth/gemma-4-12B-it-qat-GGUF", True),("UNSLOTH/GEMMA-4-E2B-IT-GGUF", True), # case-insensitive("gemma-4-E2B-it-GGUF", True), # owner-less shorthand -> unsloth/("gemma-4-31B-it-GGUF", True), # owner-less shorthand -> unsloth/@@ -125,7 +127,12 @@ def test_is_unsloth_gemma4_gguf(model_id, expected):("unsloth/gemma-4-E2B-it-GGUF", True),("unsloth/gemma-4-E4B-it-GGUF", True),("UNSLOTH/GEMMA-4-E4B-IT-GGUF", True),+ ("unsloth/gemma-4-E2B-it-qat-GGUF", True),+ ("unsloth/gemma-4-E4B-it-qat-GGUF", True),+ ("unsloth/gemma-4-E4B-it-qat-mobile-GGUF", True),+ ("unsloth/gemma-4-E2B-it-qat-mobile-GGUF", True),("unsloth/gemma-4-12b-it-GGUF", False),+ ("unsloth/gemma-4-12B-it-qat-GGUF", False),("unsloth/gemma-4-26B-A4B-it-GGUF", False),("unsloth/gemma-4-31B-it-GGUF", False),("unsloth/gemma-3-4b-it-GGUF", False),@@ -142,6 +149,19 @@ def test_resolver_returns_edge_template_for_e2b_e4b():assert out != BUNDLED+def test_resolver_routes_qat_repos_by_family():+ # The QAT repos are named like the plain ones plus "-qat", and the edge+ # template has to follow them: an E2B/E4B QAT model that gets the standard+ # template is handed an empty thought block on thinking-off (issue #12708).+ for mid in ("unsloth/gemma-4-E2B-it-qat-GGUF", "unsloth/gemma-4-E4B-it-qat-GGUF"):+ out = resolve_effective_chat_template_override(model_identifier = mid, user_override = None)+ assert out == EDGE+ out = resolve_effective_chat_template_override(+ model_identifier = "unsloth/gemma-4-12B-it-qat-GGUF", user_override = None+ )+ assert out == BUNDLED++def test_resolver_handles_owner_less_shorthand():# ModelConfig.from_identifier prefixes unsloth/ for bare ids; the resolver# runs before that, so it must apply the same normalization.