From 852755cc92507607b93ae06fe6c7a00faae327f2 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 17 Mar 2026 07:46:21 +0000 Subject: [PATCH] studio: fix stale GGUF metadata when switching models, update default helper model Reset _supports_reasoning, _supports_tools, _chat_template, and _context_length at the top of _read_gguf_metadata so flags from a previously loaded model do not carry over. Without this, loading a reasoning model (eg Qwen3.5-4B) then switching to a non-reasoning model (eg Qwen3-4B-Instruct-2507) would keep supports_reasoning=True from the first model, causing the UI to show "Thought for 0 seconds" and passing --chat-template-kwargs enable_thinking to a model whose chat template does not support it. Also update the default helper GGUF from Qwen3-4B-Instruct-2507-GGUF to Qwen3.5-4B-GGUF to match the frontend fallback auto-load model. --- studio/backend/core/inference/llama_cpp.py | 7 +++++++ studio/backend/utils/datasets/llm_assist.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index 08126dedf7..410305d138 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -446,6 +446,13 @@ class LlamaCppBackend: Parses only the KV pairs we need (~30ms even for multi-GB files). For split GGUFs, metadata is always in shard 1. """ + # Reset metadata from any previously loaded model so stale flags + # (eg _supports_reasoning) do not carry over when switching models. + self._context_length = None + self._chat_template = None + self._supports_reasoning = False + self._supports_tools = False + try: WANTED = {"general.architecture", "tokenizer.chat_template"} arch = None diff --git a/studio/backend/utils/datasets/llm_assist.py b/studio/backend/utils/datasets/llm_assist.py index 5012c8ba07..1dc0c495e5 100644 --- a/studio/backend/utils/datasets/llm_assist.py +++ b/studio/backend/utils/datasets/llm_assist.py @@ -26,7 +26,7 @@ from loggers import get_logger logger = get_logger(__name__) -DEFAULT_HELPER_MODEL_REPO = "unsloth/Qwen3-4B-Instruct-2507-GGUF" +DEFAULT_HELPER_MODEL_REPO = "unsloth/Qwen3.5-4B-GGUF" DEFAULT_HELPER_MODEL_VARIANT = "UD-Q4_K_XL" README_MAX_CHARS = 1500