feat: add all 7 Qwen3.5 sizes to MODEL_RENDERER_MAP, autodetect think polarity#8
Merged
feat: add all 7 Qwen3.5 sizes to MODEL_RENDERER_MAP, autodetect think polarity#8
Conversation
… polarity Five Qwen3.5 sizes (4B / 9B / 35B-A3B / 122B-A10B / 397B-A17B) ship one chat template (default ``enable_thinking=true``); the smaller 0.8B and 2B sizes ship the polarity-flipped variant (default ``enable_thinking=false`` → empty ``<think>\n\n</think>\n\n`` at the generation-prompt boundary). ``Qwen35Renderer`` now probes the tokenizer's chat_template at construction with a one-shot ``apply_chat_template`` call and resolves its ``enable_thinking`` default from the polarity it detects. All seven sizes now render byte-identical to their own ``apply_chat_template`` — including with ``add_generation_prompt=True`` where the polarity diverges. Explicit ``enable_thinking=True/False`` still overrides; the autodetect only fires when the caller omits the flag. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f2b8a3c to
76a7310
Compare
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.
Summary
MODEL_RENDERER_MAP:0.8B,2B,4B,9B,35B-A3B,122B-A10B,397B-A17B(previously only the middle three were listed).Qwen35Rendererto autodetect theenable_thinkingdefault from the tokenizer's chat template at construction.0.1.7→0.1.8.Why
Qwen3.5 ships two chat-template variants that differ only in the polarity of the gen-prompt branch:
<think>\n(thinking on)<think>\n\n</think>\n\n(empty block)The previous
Qwen35Rendererhardcodedenable_thinking=True, which matched the big-default variant but not the small one — so 0.8B / 2B couldn't be added to the map without silently breaking byte parity atadd_generation_prompt=True.Implementation
Qwen35Renderer.__init__(... enable_thinking: bool | None = None):None(the new default), runs a one-shottokenizer.apply_chat_template(...)probe and reads the polarity off the resulting tail (</think>⇒ default off).enable_thinking=True/Falsestill wins — autodetect only fires when the caller omits the flag.True(matches the big-default majority).Tests
New
tests/test_qwen35_size_coverage.py(37 cases):qwen3.5; catches silent additions.Qwen35Renderer.render_idsmatchesapply_chat_templatetoken-for-token.Full suite:
937 passed, 48 skipped, 1 xfailed.Test plan
pytest tests/test_qwen35_size_coverage.py— 37 cases passpytest tests/ --ignore=tests/test_client.py) — 937 pass, no regressions🤖 Generated with Claude Code