From e42b49bd69d4b3c814d14e9433ab96cafb5a629a Mon Sep 17 00:00:00 2001 From: Julien Denize <40604584+juliendenize@users.noreply.github.com> Date: Sat, 14 Mar 2026 15:26:43 +0100 Subject: [PATCH] Mistral common v10 (#36971) Signed-off-by: juliendenize Signed-off-by: Julien Denize <40604584+juliendenize@users.noreply.github.com> Co-authored-by: root Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Cyrus Leung --- requirements/common.txt | 2 +- requirements/rocm-test.txt | 2 +- requirements/test.txt | 2 +- vllm/tokenizers/mistral.py | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/requirements/common.txt b/requirements/common.txt index 5e156edb75..61c60ea39b 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -31,7 +31,7 @@ partial-json-parser # used for parsing partial JSON outputs pyzmq >= 25.0.0 msgspec gguf >= 0.17.0 -mistral_common[image] >= 1.9.1 +mistral_common[image] >= 1.10.0 opencv-python-headless >= 4.13.0 # required for video IO pyyaml six>=1.16.0; python_version > '3.11' # transitive dependency of pandas that needs to be the latest version for python 3.12 diff --git a/requirements/rocm-test.txt b/requirements/rocm-test.txt index 50d4d9aa6e..e616a99c53 100644 --- a/requirements/rocm-test.txt +++ b/requirements/rocm-test.txt @@ -95,7 +95,7 @@ transformers==4.57.5 # Pin HF Hub version huggingface-hub==0.36.2 # Pin Mistral Common -mistral-common[image,audio]==1.9.1 +mistral-common[image,audio]==1.10.0 # Required for Prithvi tests terratorch==1.2.2 # Required for Prithvi tests diff --git a/requirements/test.txt b/requirements/test.txt index ac5fb9c2ed..31404d91f1 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -482,7 +482,7 @@ mbstrdecoder==1.1.3 # typepy mdurl==0.1.2 # via markdown-it-py -mistral-common==1.9.1 +mistral-common==1.10.0 # via -r requirements/test.in more-itertools==10.5.0 # via lm-eval diff --git a/vllm/tokenizers/mistral.py b/vllm/tokenizers/mistral.py index 95335c9834..ca61edeb86 100644 --- a/vllm/tokenizers/mistral.py +++ b/vllm/tokenizers/mistral.py @@ -7,6 +7,9 @@ from typing import TYPE_CHECKING, Any, cast, overload from mistral_common.protocol.instruct.request import ( ChatCompletionRequest as MistralChatCompletionRequest, ) +from mistral_common.protocol.instruct.request import ( + ReasoningEffort, +) from mistral_common.protocol.instruct.tool_calls import Function, Tool from mistral_common.protocol.instruct.validator import ValidationMode from mistral_common.tokens.tokenizers.base import ( @@ -192,6 +195,15 @@ def validate_request_params(request: "ChatCompletionRequest"): if request.chat_template is not None or request.chat_template_kwargs is not None: raise ValueError("chat_template is not supported for Mistral tokenizers.") + if request.reasoning_effort and request.reasoning_effort not in list( + ReasoningEffort + ): + raise ValueError( + f"reasoning_effort={request.reasoning_effort} is not supported by " + "Mistral models. Supported values are: " + f"{[e.value for e in ReasoningEffort]}." + ) + def _tekken_token_to_id(tokenizer: "Tekkenizer", t: str | bytes) -> int: assert isinstance(tokenizer, Tekkenizer), type(tokenizer) @@ -419,6 +431,12 @@ class MistralTokenizer(TokenizerLike): truncation = kwargs.get("truncation", False) max_length = kwargs.get("max_length") + version_kwargs = {} + # NOTE: This is for backward compatibility. + # Transformers should be passed arguments it knows. + if self.version >= 15: + version_kwargs["reasoning_effort"] = kwargs.get("reasoning_effort") + messages, tools = _prepare_apply_chat_template_tools_and_messages( messages, tools, continue_final_message, add_generation_prompt ) @@ -433,6 +451,7 @@ class MistralTokenizer(TokenizerLike): max_length=max_length, return_tensors=None, return_dict=False, + **version_kwargs, ) def decode(