Skip to content

[Bugfix][Rust Frontend] Match DeepSeek-V4.1 renderer to the 1017 reference encoding - #62200

Merged
robertgshaw2-redhat merged 3 commits into
vllm-project:mainfrom
robertgshaw2-redhat:dsv41-1017-rust-renderer-parity
Oct 19, 2026
Merged

robertgshaw2-redhat merged 3 commits into
vllm-project:mainfrom
robertgshaw2-redhat:dsv41-1017-rust-renderer-parity

Conversation

@robertgshaw2-redhat

@robertgshaw2-redhat robertgshaw2-redhat commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Rust counterpart of #62199: match the DeepSeek V4.1 renderer to the updated reference encoding/.

Affects both V4.1-Flash checkpoints (launch and 1017). DeepSeek fixed the turn handling in both repos (launch 314113f, 1017 release); their encoding/ is now identical. The image-token check has been in the reference since launch.

Claims

  • Tool results alone no longer start a new user turn, so reasoning before a tool call is kept.
  • Literal <|deepseek_image|> in message text or reasoning returns 400.
  • V4 is unchanged.

Examples

1. Tool call in thinking mode, with no tools field in the request

[{"role": "user", "content": "What's the weather in Paris? Answer in Fahrenheit."},
 {"role": "assistant", "content": "", "reasoning": "Tool returns Celsius; convert to Fahrenheit.",
  "tool_calls": [{"id": "c1", "type": "function", "function": {"name": "get_weather", "arguments": "{\"city\": \"Paris\"}"}}]},
 {"role": "tool", "tool_call_id": "c1", "content": "{\"temp_c\": 20}"}]

Before (reasoning dropped):

<|User|>What's the weather in Paris? Answer in Fahrenheit.<|Assistant|></think>

<|DSML| calls>...

After (reasoning kept, same as the reference encoder):

<|User|>What's the weather in Paris? Answer in Fahrenheit.<|Assistant|><think>Tool returns Celsius; convert to Fahrenheit.</think>

<|DSML| calls>...

2. Literal image token in text

[{"role": "user", "content": "hi <|deepseek_image|>"}]

Before: accepted, so the prompt has an image placeholder with no image. After: 400.

Validation

  • cargo test -p vllm-chat --lib renderer::: 210 passed. The new tests fail on main. fmt and clippy are clean.
  • E2E with vllm-rs render on DeepSeek-V4.1-Flash-1017: token IDs now match the Python frontend (113 vs 97 on main); the literal image token returns 400.

Details

Not a duplicate: open Rust renderer PRs (#62189, #56334) don't touch turn boundaries or placeholder validation.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

🤖 Generated with Claude Code

…rence encoding

Tool-result-only user-content blocks no longer start a new user turn, so
drop_thinking keeps the reasoning that led to a tool call. Reject literal
image placeholder tokens in message text and reasoning. Mirrors the Python
encoder fix so both frontends render identical prompts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Robert Shaw <robertgshaw2@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added deepseek Related to DeepSeek models rust DSv4.1 Related to DeepSeek-V4.1 models bug Something isn't working labels Oct 17, 2026

@sfeng33 sfeng33 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, cc @BugenZhao in case you want to take another look.

@robertgshaw2-redhat robertgshaw2-redhat added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 17, 2026
@robertgshaw2-redhat

Copy link
Copy Markdown
Collaborator Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #95626 for commit 6fc735e74df3.

@robertgshaw2-redhat

Copy link
Copy Markdown
Collaborator Author

/ci retry

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #95903 for commit 7268d0070009, running 3 failed step(s) from Buildkite CI #95626.

@BugenZhao BugenZhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@robertgshaw2-redhat
robertgshaw2-redhat merged commit 2cea893 into vllm-project:main Oct 19, 2026
20 checks passed
@robertgshaw2-redhat
robertgshaw2-redhat deleted the dsv41-1017-rust-renderer-parity branch October 19, 2026 14:57
bantianyue pushed a commit to bantianyue/vllm that referenced this pull request Oct 28, 2026
…rence encoding (vllm-project#62200)

Signed-off-by: Robert Shaw <robertgshaw2@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working deepseek Related to DeepSeek models DSv4.1 Related to DeepSeek-V4.1 models ready ONLY add when PR is ready to merge/full CI is needed rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants