From e752b0cbc69877f79074d249fcfa44a347249aeb Mon Sep 17 00:00:00 2001 From: Isotr0py Date: Fri, 24 Jan 2025 01:20:33 +0800 Subject: [PATCH] [Bugfix] Fix broken internvl2 inference with v1 (#12360) Signed-off-by: Isotr0py <2037008807@qq.com> --- vllm/multimodal/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vllm/multimodal/utils.py b/vllm/multimodal/utils.py index 094e0682a068b..900bed5929b3d 100644 --- a/vllm/multimodal/utils.py +++ b/vllm/multimodal/utils.py @@ -503,8 +503,13 @@ def modality_group_func(mm_input: "MultiModalKwargs") -> Union[str, int]: if len(mm_input.modalities) > 1: return id(mm_input) - # Otherwise return the modality string - return list(mm_input.modalities)[0] + elif len(mm_input.modalities) == 1: + return list(mm_input.modalities)[0] + + # FIXME(Isotr0py): Modality of mm_input from legacy pipeline is empty, + # this is used to make InternVL with legacy pipeline still work with v1. + else: + return "" return [ list(group) for _, group in groupby(mm_inputs, key=modality_group_func)