Skip to content

dsv4.1: chat encoding and tool parsing - #39665

Merged
hnyls2002 merged 86 commits into
mainfrom
dsv4.1-chat
Sep 17, 2026
Merged

hnyls2002 merged 86 commits into
mainfrom
dsv4.1-chat

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add the DeepSeek-V4.1 chat encoder (encoding_dsv41.py): spaced DSML tag names (<|DSML| calls> / <|DSML| invoke> / <|DSML| parameter>), a numeric reasoning-effort prefix, mid-conversation system messages, quick-instruction task tokens, and OpenAI image_url parts rendered as image placeholders.
  • Add DeepSeekV41Detector (tool-call parser deepseekv41) on top of the V3.2 detector, with an xgrammar structural tag built for the spaced names; register the deepseek-v41 reasoning parser as an alias of the V4 one.
  • Select the V4.1 encoder from --tool-call-parser deepseekv41 or from the model config (model_type == "deepseek_v41" / DeepseekV41* architectures); template auto-detection resolves both parsers the same way.

Changes

Encoder and serving

  • serving_chat: V4.1 requests go through the dsv4/dsv32 encoding branch. Tools are passed as the client sent them (unset fields dropped, OpenAI field order). Image parts are collected from the encoder and the placeholder is replaced with the model's image token.
  • reasoning_effort: tiers low/high/xhigh/max pass through, an OpenAI float in [0, 0.99] maps onto the 1-100 budget, an integer budget is accepted via chat_template_kwargs.reasoning_effort. Unsupported values (minimal, medium) log a warning and fall back to the server default, which is the encoder default high unless SGLANG_DSV41_REASONING_EFFORT sets a tier or an integer budget.

Detectors

  • DeepSeekV32Detector: the DSML block / invoke / parameter tag names become class attributes and every token and regex is derived from them. V3.2 and V4 keep their literal tags and behavior; V4 now only overrides the block name.

Verification

  • test_serving_chat.py pins the new dsv41 spec; the existing V4 / V3.2 detector, function-call parser, reasoning parser and template-manager CPU suites pass unchanged.
  • Chat encoding is compared against the V4.1 reference implementation; detector structural tags are compared across tool-choice, parallel and thinking modes.

CI States

Latest PR Test (Base): ❌ Run #35179071184
Latest PR Test (Extra): ❌ Run #35179070932
Latest PR Test (AMD ROCm 10): ❌ Run #35179071125

@hnyls2002
hnyls2002 requested a review from JustinTong0323 as a September 15, 2026 22:30
@hnyls2002
hnyls2002 added this pull request to stack #39667 September 15, 2026 22:32
@hnyls2002
hnyls2002 removed this pull request from stack #39667 September 15, 2026 22:43
@hnyls2002
hnyls2002 changed the base branch from dsv4.1-mhc to dsv4.1-vision September 15, 2026 22:43
@hnyls2002
hnyls2002 added this pull request to stack #39669 September 15, 2026 22:43
@hnyls2002
hnyls2002 removed this pull request from stack #39669 September 15, 2026 22:56
@hnyls2002
hnyls2002 added this pull request to stack #39672 September 15, 2026 22:58
Base automatically changed from dsv4.1-vision to main September 17, 2026 01:11
@mintlify

mintlify Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
lmsysorg 🟢 Ready View Preview Sep 17, 2026, 3:43 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 17, 2026
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_serving_chat.py test_deepseekv4_detector.py test_function_call_parser.py test_reasoning_parser.py test_template_manager.py test_serving_responses.py test_serving.py

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test_serving_chat.py test_deepseekv4_detector.py test_function_call_parser.py test_reasoning_parser.py test_template_manager.py test_serving_responses.py test_serving.py:

🚀 ubuntu-latest (7 tests): ✅ View workflow run

cd test/ && python3 registered/unit/entrypoints/openai/test_serving_chat.py
cd test/ && python3 registered/unit/function_call/test_deepseekv4_detector.py
cd test/ && python3 registered/unit/function_call/test_function_call_parser.py
cd test/ && python3 registered/unit/parser/test_reasoning_parser.py
cd test/ && python3 registered/unit/parser/test_template_manager.py
cd test/ && python3 registered/unit/entrypoints/openai/test_serving_responses.py
cd test/ && python3 registered/unit/entrypoints/anthropic/test_serving.py

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ai

@github-actions

Copy link
Copy Markdown
Contributor

⛔ /tag-and-rerun-ai isn't a recognized CI command. Did you mean /tag-and-rerun-ci?

See the command reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants