[MM] Simplify prompt updates: replace PromptSeq with list[int] (#53372)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Co-authored-by: Qwen Code <noreply@alibaba-inc.com>
This commit is contained in:
Cyrus Leung
2026-08-23 14:50:32 +08:00
committed by GitHub
co-authored by Qwen Code
parent a3561ef8e4
commit ebcd606467
53 changed files with 831 additions and 855 deletions
+10 -3
View File
@@ -26,6 +26,7 @@ from vllm.multimodal.parse import (
from vllm.multimodal.processing import (
PromptReplacement,
PromptUpdateDetails,
cached_encode,
)
from vllm.transformers_utils.processors.internvl import InternVLImageProcessor
from vllm.transformers_utils.processors.nvlm_d import NVLMProcessor
@@ -106,6 +107,8 @@ class NVLMMultiModalProcessor(BaseInternVLMultiModalProcessor[NVLMProcessingInfo
hf_processor: NVLMProcessor,
out_mm_data: BatchedTensorInputs,
):
tokenizer = self.info.get_tokenizer()
if "image_num_patches" in out_mm_data:
image_num_patches = out_mm_data["image_num_patches"]
assert isinstance(image_num_patches, torch.Tensor)
@@ -138,14 +141,18 @@ class NVLMMultiModalProcessor(BaseInternVLMultiModalProcessor[NVLMProcessingInfo
repl = hf_processor.get_image_repl(num_patches, num_features=feature_size)
return PromptUpdateDetails.select_text(
repl.full + "\n", hf_processor.ctx_image_token
# `repl.full` ends in the special `</Image>` token, so there is
# no BPE merge across the boundary with the newline
newline_ids = cached_encode(tokenizer, "\n", add_special_tokens=False)
return PromptUpdateDetails.select_token_id(
repl.full + newline_ids, hf_processor.ctx_image_token_id
)
# See note in dummy data regarding why we have the extra newline
return PromptReplacement(
modality="image",
target="<image>\n",
target=cached_encode(tokenizer, "<image>\n", add_special_tokens=False),
replacement=get_replacement_nvlm,
)