Skip to content

[Mistral Tokenizer] allow more leniency in apply_chat_template#41658

Merged
vllm-bot merged 7 commits intovllm-project:mainfrom
juliendenize:juliendenize/patch_mistral_tokenizer
May 6, 2026
Merged

[Mistral Tokenizer] allow more leniency in apply_chat_template#41658
vllm-bot merged 7 commits intovllm-project:mainfrom
juliendenize:juliendenize/patch_mistral_tokenizer

Conversation

@juliendenize
Copy link
Copy Markdown
Contributor

@juliendenize juliendenize commented May 4, 2026

Purpose

This PR upgrade mistral-common to 1.11.2. This allows to:

  • use 'reasoning' inside assistant message to support user sending back think trace to the model which improves performance for some of them (including Mistral Medium 3.5)
  • move Tool special handling inside mistral-common to reduce LOC inside vLLM

Test Plan

Tested on manually made requests + updated some unit tests in the lib

Test Result

All pass


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Signed-off-by: juliendenize <julien.denize@mistral.ai>
Copy link
Copy Markdown

@claude claude Bot left a comment

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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request upgrades mistral_common to version 1.11.2 and refactors the Mistral tokenizer and tool parser to utilize native library methods for tool adaptation. The internal helper for preparing chat templates has been converted into a validation function, removing manual message and tool modification logic. Feedback identifies a high-severity issue where the add_generation_prompt parameter was omitted in the call to the underlying transformers tokenizer, which could lead to incorrect prompt formatting.

messages, continue_final_message, add_generation_prompt
)

return self.transformers_tokenizer.apply_chat_template(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The add_generation_prompt argument is missing from the call to self.transformers_tokenizer.apply_chat_template. While mistral-common often infers the generation prompt from the conversation state, the transformers tokenizer wrapper (MistralCommonBackend) explicitly supports this parameter. Omitting it causes it to default to False, which may conflict with the user's intent and vLLM's default behavior (where add_generation_prompt defaults to True).

Suggested change
return self.transformers_tokenizer.apply_chat_template(
return self.transformers_tokenizer.apply_chat_template(
conversation=messages,
tools=tools,
add_generation_prompt=add_generation_prompt,
continue_final_message=continue_final_message,
tokenize=tokenize,
padding=padding,
truncation=truncation,
max_length=max_length,
return_tensors=None,
return_dict=False,
**version_kwargs,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it was already not the case. While I agree ultimately that we'd want to do that, we need to wait a bit that last Transformers version is released as I recently updated MistralCommonBackend.

Comment thread tests/tokenizers_/test_mistral.py
juliendenize and others added 3 commits May 4, 2026 22:38
Signed-off-by: juliendenize <julien.denize@mistral.ai>
Signed-off-by: juliendenize <julien.denize@mistral.ai>
Copy link
Copy Markdown
Contributor

@joa-stdn joa-stdn left a comment

Choose a reason for hiding this comment

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

thanks a lot!

@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label May 4, 2026
@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA May 5, 2026
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) May 5, 2026 02:36
@juliendenize
Copy link
Copy Markdown
Contributor Author

@DarkLight1337 i don't think the CI errors are related ! If you agree could you consider merging 🙏 ?

@vllm-bot vllm-bot merged commit 16e3364 into vllm-project:main May 6, 2026
148 of 151 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA May 6, 2026
chaojun-zhang pushed a commit to chaojun-zhang/vllm that referenced this pull request May 6, 2026
…project#41658)

Signed-off-by: juliendenize <julien.denize@mistral.ai>
Co-authored-by: Roger Wang <hey@rogerw.io>
amd-mghanimi pushed a commit to amd-mghanimi/vllm that referenced this pull request May 6, 2026
…project#41658)

Signed-off-by: juliendenize <julien.denize@mistral.ai>
Co-authored-by: Roger Wang <hey@rogerw.io>
Signed-off-by: Mehdi Ghanimifard <mehdi.ghanimifard@amd.com>
Copilot AI pushed a commit to hongbolv/vllm that referenced this pull request May 7, 2026
…project#41658)

Signed-off-by: juliendenize <julien.denize@mistral.ai>
Co-authored-by: Roger Wang <hey@rogerw.io>
Co-authored-by: hongbolv <33214277+hongbolv@users.noreply.github.com>
ikaadil pushed a commit to ikaadil/vllm that referenced this pull request May 7, 2026
…project#41658)

Signed-off-by: juliendenize <julien.denize@mistral.ai>
Co-authored-by: Roger Wang <hey@rogerw.io>
Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com>
libinta pushed a commit to libinta/vllm that referenced this pull request May 8, 2026
…project#41658)

Signed-off-by: juliendenize <julien.denize@mistral.ai>
Co-authored-by: Roger Wang <hey@rogerw.io>
Signed-off-by: Libin Tang <libin.tang@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build mistral Related to Mistral models nvidia ready ONLY add when PR is ready to merge/full CI is needed tool-calling

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants