From 7c40d61eaf6bdd80bb493cf94032efbbe0ed0ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ganczarenko?= Date: Tue, 4 Aug 2026 15:34:58 +0200 Subject: [PATCH] [Bugfix] Flatten >2D multimodal embeddings, not just 3D (#50250) Signed-off-by: Michal Ganczarenko --- vllm/model_executor/models/transformers/multimodal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vllm/model_executor/models/transformers/multimodal.py b/vllm/model_executor/models/transformers/multimodal.py index a87e28241f..3d077ac021 100644 --- a/vllm/model_executor/models/transformers/multimodal.py +++ b/vllm/model_executor/models/transformers/multimodal.py @@ -558,8 +558,8 @@ class MultiModalMixin(SupportsMultiModal, SupportsMRoPE): total_expected = sum(split_sizes) # Flatten to 2D: [total_tokens, hidden_dim] - if embeddings.ndim == 3: - embeddings = embeddings.view(-1, embeddings.shape[-1]) + if embeddings.ndim > 2: + embeddings = embeddings.reshape(-1, embeddings.shape[-1]) total_tokens = embeddings.shape[0] if total_tokens == total_expected: