@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / d8da76f3b7
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 10, 20:15 UTC

[Bugfix] Fix BAGEL online serving for text and image understanding (#31546)

Signed-off-by: Dylan1229 <yvanphys@gmail.com> Signed-off-by: UED <zxr3611244710@gmail.com> Signed-off-by: mr-ye-cao <yecaoyc2019@gmail.com> Co-authored-by: UED <zxr3611244710@gmail.com> Co-authored-by: mr-ye-cao <yecaoyc2019@gmail.com> Co-authored-by: Mr-Ye-Cao <60802056+Mr-Ye-Cao@users.noreply.github.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>

Fanjiang Ye committed Dec 31, 2025 at 16:46 UTC d8da76f3b7e48d8b8a5274e78e8190c9d0671175
2 files changed +15 -3
vllm/model_executor/models/bagel.py
+7
@@ -346,6 +346,13 @@ class BagelForConditionalGeneration(
346 }
347 )
348
349 + @classmethod
350 + def get_placeholder_str(cls, modality: str, i: int) -> str | None:
351 + if modality.startswith("image"):
352 + return "<|image_pad|>"
353 +
354 + raise ValueError("Only image modality is supported")
355 +
356 def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
357 super().__init__()
358
vllm/transformers_utils/processors/bagel.py
+8 -3
@@ -4,6 +4,7 @@
4 """BAGEL processor for image and text inputs."""
5
6 from transformers import AutoProcessor
7 +from transformers.feature_extraction_utils import BatchFeature
8 from transformers.image_utils import ImageInput
9 from transformers.processing_utils import ProcessorMixin
10 from transformers.tokenization_utils_base import PreTokenizedInput, TextInput
@@ -44,12 +45,16 @@ class BagelProcessor(ProcessorMixin):
45 text_inputs = self.tokenizer(text, **kwargs) if text is not None else None
46
47 if pixel_values is not None and text_inputs is not None:
47 - text_inputs["pixel_values"] = pixel_values["pixel_values"]
48 - return text_inputs
48 + # Combine text and image inputs into BatchFeature
49 + combined = dict(text_inputs)
50 + combined["pixel_values"] = pixel_values["pixel_values"]
51 + return BatchFeature(combined)
52 elif pixel_values is not None:
53 return pixel_values
54 + elif text_inputs is not None:
55 + return BatchFeature(dict(text_inputs))
56 else:
52 - return text_inputs
57 + return BatchFeature({})
58
59 def batch_decode(self, *args, **kwargs):
60 """