From 5082f5b7fcd269faba7ee3974eca685ef43e7c34 Mon Sep 17 00:00:00 2001 From: ywang96 Date: Mon, 16 Dec 2024 04:56:13 +0000 Subject: [PATCH] fix empty tensor --- vllm/model_executor/models/pixtral.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vllm/model_executor/models/pixtral.py b/vllm/model_executor/models/pixtral.py index 161d6b41bfa5f..f05ea195e043d 100644 --- a/vllm/model_executor/models/pixtral.py +++ b/vllm/model_executor/models/pixtral.py @@ -245,6 +245,11 @@ def get_multimodal_embeddings(self, **kwargs) -> Optional[NestedTensors]: # Do not split, return as tensor of shape [1, fs, hs] return image_embeds.unsqueeze(0) + # If the last split index is the last index in image_tokens, we + # ignore it to avoid empty split tensor + if split_indices[-1] == len(image_tokens): + split_indices = split_indices[:-1] + image_embeds = image_embeds.tensor_split(split_indices.cpu()) return image_embeds