Skip to content

Commit cb865c1

Browse files
DarkLight1337shreyankg
authored andcommitted
[Bugfix] Fix embedding assignment for InternVL-based models (vllm-project#15086)
Signed-off-by: DarkLight1337 <[email protected]>
1 parent a91f983 commit cb865c1

File tree

7 files changed

+123
-106
lines changed

7 files changed

+123
-106
lines changed

examples/offline_inference/vision_language.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ def run_gemma3(questions: list[str], modality: str) -> ModelRequestData:
169169
model=model_name,
170170
max_model_len=2048,
171171
max_num_seqs=2,
172-
# Default is False; setting it to True is not supported in V1 yet
173172
mm_processor_kwargs={"do_pan_and_scan": True},
174173
disable_mm_preprocessor_cache=args.disable_mm_preprocessor_cache,
175174
)

examples/offline_inference/vision_language_multi_image.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ def load_gemma3(question: str, image_urls: list[str]) -> ModelRequestData:
9191
model=model_name,
9292
max_model_len=8192,
9393
max_num_seqs=2,
94-
# Default is False; setting it to True is not supported in V1 yet
95-
mm_processor_kwargs={"do_pan_and_scan": True},
9694
limit_mm_per_prompt={"image": len(image_urls)},
9795
)
9896

vllm/model_executor/models/gemma3_mm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def get_image_repl(
183183
image_width: int,
184184
image_height: int,
185185
processor: Optional[Gemma3Processor],
186-
) -> PromptUpdateDetails:
186+
) -> PromptUpdateDetails[str]:
187187
if processor is None:
188188
processor = self.get_hf_processor()
189189

vllm/model_executor/models/h2ovl.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,15 @@ def __init__(
249249
def image_token_id(self) -> int:
250250
return self.tokenizer.get_vocab()[IMG_CONTEXT]
251251

252-
def get_image_repl_features(
252+
def get_image_repl(
253253
self,
254254
feature_size: int,
255255
num_patches: Optional[int],
256-
) -> str:
257-
return IMG_CONTEXT * feature_size
256+
) -> PromptUpdateDetails[str]:
257+
repl_features = IMG_CONTEXT * feature_size
258+
repl_full = IMG_START + repl_features + IMG_END
258259

259-
def get_image_repl_full(
260-
self,
261-
feature_size: int,
262-
num_patches: Optional[int],
263-
) -> str:
264-
features = self.get_image_repl_features(feature_size, num_patches)
265-
return IMG_START + features + IMG_END
260+
return PromptUpdateDetails(full=repl_full, features=repl_features)
266261

267262
def resolve_min_max_num(
268263
self,
@@ -501,12 +496,7 @@ def get_replacement_internvl(item_idx: int):
501496
if num_patches is not None:
502497
assert isinstance(num_patches, int)
503498

504-
return PromptUpdateDetails(
505-
full=hf_processor.get_image_repl_full(feature_size,
506-
num_patches),
507-
features=hf_processor.get_image_repl_features(
508-
feature_size, num_patches),
509-
)
499+
return hf_processor.get_image_repl(feature_size, num_patches)
510500

511501
return [
512502
PromptReplacement(

0 commit comments

Comments
 (0)