Repository navigation
Description
Summary
DeepSeek-V3.2 (deepseek_v32) gates reasoning in its chat template via a thinking_mode variable ("thinking" / "chat"), not the conventional enable_thinking boolean. mlxcel forwards the generic enable_thinking kwarg to the Jinja chat template, so for a deepseek_v32 checkpoint whose template reads thinking_mode, toggling reasoning from the request (or via the server default) may have no effect.
Confidence note: this depends on the actual
chat_template.jinjashipped with thedeepseek_v32checkpoint. First step is verification (see below); if the checkpoint template already acceptsenable_thinking, this is a no-op and the issue can be closed.
Current state in mlxcel
- Thinking kwargs are passed through a deliberately generic mechanism:
src/server/chat_template_kwargs.rs(designed so "future keys likeenable_thinkinginherit" the plumbing) andsrc/server/chat_template.rs(default_enable_thinking, theenable_thinking=self.has_thinkingdefault). - There is no model-type-aware aliasing: mlxcel surfaces
enable_thinkingto the template but never thethinking_modevariant that the DeepSeek-V3.2 template expects.
What needs to be built
- Verify the
thinkingtoggle variable in thedeepseek_v32(andglm_moe_dsa) checkpointchat_template.jinja. If it isenable_thinking, close as not-needed. - If it is
thinking_mode, add a model-aware alias so that when the active template is the DeepSeek-V3.2 family, the server also providesthinking_mode = "thinking"(whenenable_thinkingis true) or"chat"(when false), derived from the same resolvedenable_thinkingvalue (request override or server default). Keep the genericenable_thinkingpassthrough intact for all other models. - Make the alias data-driven (not hard-coded per checkpoint) so future templates that adopt
thinking_modeare covered.
Acceptance criteria
- Verified which variable the DeepSeek-V3.2 chat template uses; documented in the issue/PR.
- If
thinking_modeis used: a request withenable_thinking: falseagainst adeepseek_v32checkpoint renders a non-reasoning prompt;enable_thinking: true(or the thinking default) renders a reasoning prompt. - No behavior change for non-DeepSeek-V3.2 models.
- Unit coverage for the alias mapping (true -> "thinking", false -> "chat").
Files
src/server/chat_template_kwargs.rssrc/server/chat_template.rs
Context
Discovered during an upstream-sync review of recent DeepSeek-V3.2 changes; the chat-template thinking toggle uses a thinking_mode variable that mlxcel's generic enable_thinking passthrough does not currently produce.
Activity
inureyes commentedon Jul 1, 2026
Verification result
Fetched the real templates directly rather than relying on the
thinking_modeguess in the issue description:deepseek-ai/DeepSeek-V3.2-Expassets/chat_template.jinja(https://huggingface.co/deepseek-ai/DeepSeek-V3.2-Exp/blob/main/assets/chat_template.jinja) uses a barethinkingboolean, notthinking_modeand notenable_thinking:{% if not thinking is defined %}{% set thinking = false %}{% endif %}, later branching with{%- if not thinking %}{{'</think>'}}{%- else %}{{'<think>'}}{%- endif %}.glm_moe_dsa) ships its own template (https://huggingface.co/zai-org/GLM-5.2/blob/main/chat_template.jinja) that already reads the conventionalenable_thinkingkwarg directly and needs no change.mlx-communityDeepSeek-V3.2 exports currently checked (DeepSeek-V3.2-4bit,DeepSeek-V3.2-Speciale-4bit,DeepSeek-V3.2-mlx-5bit) ship no chat template at all today, but the upstream/model-native template does gate on the barethinkingname, so this is a real gap once a template is present, just named differently than the issue assumed.Since the gating variable is neither
enable_thinking(not a no-op) northinking_modeas speculated, but a third bare-boolean variant, this was implemented as a data-driven alias rather than closed as a no-op: PR #579 addsChatTemplateProcessor::wants_bare_thinking_alias, which detects thenot thinking is definedidiom in the loaded template source and mirrors the resolvedenable_thinkingvalue into athinkingkey when present. Detection is based on template text, not a hard-coded model name, so any future template adopting the same idiom is covered automatically, andenable_thinkingpassthrough for every other model (including GLM-5.2) is unchanged.fix(server): define tools only when the request sends them (#1598)