From 2157bef2bac566b585cc154e4a86796e43edf7d5 Mon Sep 17 00:00:00 2001 From: mgoin Date: Wed, 2 Apr 2025 15:21:43 +0000 Subject: [PATCH 1/2] [V1] Support Mistral3 in V1 Signed-off-by: mgoin --- vllm/model_executor/models/mistral3.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/vllm/model_executor/models/mistral3.py b/vllm/model_executor/models/mistral3.py index 4cd9a7bf58e7..872769dd649e 100644 --- a/vllm/model_executor/models/mistral3.py +++ b/vllm/model_executor/models/mistral3.py @@ -31,12 +31,12 @@ from vllm.multimodal.profiling import BaseDummyInputsBuilder, ProcessorInputs from vllm.sequence import IntermediateTensors -from .interfaces import (MultiModalEmbeddings, SupportsMultiModal, SupportsPP, - SupportsV0Only) +from .interfaces import MultiModalEmbeddings, SupportsMultiModal, SupportsPP from .pixtral import PixtralHFEncoderInfo, PixtralHFVisionModel from .utils import (AutoWeightsLoader, flatten_bn, init_vllm_registered_model, maybe_prefix, merge_multimodal_embeddings) -from .vision import get_vision_encoder_info, select_patch_features +from .vision import (get_vision_encoder_info, scatter_patch_features, + select_patch_features) class Mistral3ImagePixelInputs(TypedDict): @@ -425,7 +425,7 @@ def init_vision_tower_for_llava( info=_build_mistral3_info, dummy_inputs=Mistral3DummyInputsBuilder) class Mistral3ForConditionalGeneration(nn.Module, SupportsMultiModal, - SupportsPP, SupportsV0Only): + SupportsPP): packed_modules_mapping = { "qkv_proj": ["q_proj", "k_proj", "v_proj"], @@ -518,7 +518,7 @@ def _parse_and_validate_image_input( return Mistral3ImagePixelInputs( type="pixel_values_pixtral", pixel_values=flatten_bn(pixel_values), - embed_is_patch=embed_is_patch, + embed_is_patch=flatten_bn(embed_is_patch), ) def _process_image_input( @@ -557,7 +557,10 @@ def get_multimodal_embeddings( vision_embeddings = self._process_image_input(image_input) - return vision_embeddings + return scatter_patch_features( + vision_embeddings, + image_input["embed_is_patch"], + ) def get_input_embeddings( self, From 7313922190d651d33242d5503bf5379f11b56dc9 Mon Sep 17 00:00:00 2001 From: mgoin Date: Wed, 2 Apr 2025 17:38:14 +0000 Subject: [PATCH 2/2] Update docs Signed-off-by: mgoin --- docs/source/models/supported_models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/models/supported_models.md b/docs/source/models/supported_models.md index bf7e2b5b1c5d..74b4eab92043 100644 --- a/docs/source/models/supported_models.md +++ b/docs/source/models/supported_models.md @@ -888,7 +888,7 @@ See [this page](#generative-models) for more information on how to use generativ * `mistralai/Mistral-Small-3.1-24B-Instruct-2503`, etc. * * ✅︎ - * + * ✅︎ - * `MllamaForConditionalGeneration` * Llama 3.2 * T + I+