Skip to content

feat(server): map enable_thinking -> thinking_mode for the DeepSeek-V3.2 chat template #512

Closed

Description

@inureyes

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.jinja shipped with the deepseek_v32 checkpoint. First step is verification (see below); if the checkpoint template already accepts enable_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 like enable_thinking inherit" the plumbing) and src/server/chat_template.rs (default_enable_thinking, the enable_thinking=self.has_thinking default).
  • There is no model-type-aware aliasing: mlxcel surfaces enable_thinking to the template but never the thinking_mode variant that the DeepSeek-V3.2 template expects.

What needs to be built

  1. Verify the thinking toggle variable in the deepseek_v32 (and glm_moe_dsa) checkpoint chat_template.jinja. If it is enable_thinking, close as not-needed.
  2. 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 provides thinking_mode = "thinking" (when enable_thinking is true) or "chat" (when false), derived from the same resolved enable_thinking value (request override or server default). Keep the generic enable_thinking passthrough intact for all other models.
  3. Make the alias data-driven (not hard-coded per checkpoint) so future templates that adopt thinking_mode are covered.

Acceptance criteria

  • Verified which variable the DeepSeek-V3.2 chat template uses; documented in the issue/PR.
  • If thinking_mode is used: a request with enable_thinking: false against a deepseek_v32 checkpoint 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.rs
  • src/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

  1. added
    type:enhancement
    status:investigation
    priority:low
    status:done
    and removed
    status:investigation
    on Jun 30, 2026
  2. inureyes commented on Jul 1, 2026

    @inureyes
    MemberAuthor

    Verification result

    Fetched the real templates directly rather than relying on the thinking_mode guess in the issue description:

    Since the gating variable is neither enable_thinking (not a no-op) nor thinking_mode as speculated, but a third bare-boolean variant, this was implemented as a data-driven alias rather than closed as a no-op: PR #579 adds ChatTemplateProcessor::wants_bare_thinking_alias, which detects the not thinking is defined idiom in the loaded template source and mirrors the resolved enable_thinking value into a thinking key 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, and enable_thinking passthrough for every other model (including GLM-5.2) is unchanged.

  3. self-assigned this
    on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority:lowstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions