fix(chat): use Qwen3 template for Qwen3ChatTemplate.template_str#1492
Open
lntutor wants to merge 1 commit into
Open
fix(chat): use Qwen3 template for Qwen3ChatTemplate.template_str#1492lntutor wants to merge 1 commit into
lntutor wants to merge 1 commit into
Conversation
Qwen3ChatTemplate.template_str was mistakenly set to qwen2dot5_it_template (a copy-paste from Qwen2dot5ChatTemplate), even though the class is registered in CHAT_TEMPLATE_CACHE for qwen3_it_template/qwen3_gguf_template. Engine.chat_completion renders the prompt from get_chat_template(). template_str, so every Qwen3 chat completion was rendered with the Qwen2.5 template -- injecting a spurious default 'You are Qwen, created by Alibaba Cloud...' system message when none is supplied and dropping Qwen3's <think>/enable_thinking handling. Point template_str at qwen3_it_template so the rendered prompt matches the template the class is registered for. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6RtoHuxrDqTUo9Mw9h4Cv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
Qwen3ChatTemplate.template_stris set toqwen2dot5_it_template— a copy-paste fromQwen2dot5ChatTemplate:But the class is registered in
CHAT_TEMPLATE_CACHEforqwen3_it_template/qwen3_gguf_template.Engine.chat_completionrenders the prompt fromget_chat_template().template_str, so every Qwen3 chat completion is rendered with the Qwen2.5 template. The two differ materially: with no system message, the Qwen2.5 template injects a spurious default"You are Qwen, created by Alibaba Cloud. You are a helpful assistant.", and it lacks Qwen3's<think>/enable_thinkinghandling — a silently malformed prompt.It's the only one of the 12 template classes whose
template_strreferences a template it isn't registered for.Fix
Point
template_stratqwen3_it_template(defined just above the class).Tests
Adds
tests/unit/test_chat.py(chat.pyhad no offline unit test — existing chat-template tests need a model download): the Qwen3 class'stemplate_strmatches its registered template, and rendering a user-only conversation no longer injects the Qwen2.5 default system message. Full offline unit suite passes (428) with no regressions.