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 8, 21:30 UTC
[Bugfix] Fix ScoreMultiModalParam multi-document scoring returning single result (#33837)
Signed-off-by: Andreas Karatzas <akaratza@amd.com> Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io> Co-authored-by: wang.yuqi <yuqi.wang@daocloud.io>
Andreas Karatzas committed
Feb 5, 2026 at 00:17 UTC
1f70313e59bfae08588bb503b69c249a5ebd1e01
1 file changed
+21
-44
tests/models/multimodal/pooling/test_jinavl_reranker.py
+21
-44
@@ -1,6 +1,5 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-from typing import cast
3
4
import pytest
5
import transformers
@@ -117,7 +116,7 @@ def _normalize_image(image_val: str) -> str:
116
117
def create_score_multimodal_param(
118
content_parts: list[dict],
120
-) -> ScoreMultiModalParam:
119
+) -> list[ScoreMultiModalParam]:
120
"""
121
Create a ScoreMultiModalParam from a list of content dictionaries.
122
@@ -152,7 +151,7 @@ def create_score_multimodal_param(
151
)
152
)
153
155
- return ScoreMultiModalParam(content=formatted_content)
154
+ return [ScoreMultiModalParam(content=[content]) for content in formatted_content]
155
156
157
def _run_vllm(
@@ -198,23 +197,7 @@ def _run_hf(
197
else:
198
raise ValueError("Unsupported query format")
199
201
- # Separate documents by type
202
- text_docs: list[str] = []
203
- image_docs: list[str] = []
204
- text_indices: list[int] = []
205
- image_indices: list[int] = []
206
-
207
- for idx, doc in enumerate(document_strs):
208
- if "text" in doc:
209
- text_docs.append(doc["text"])
210
- text_indices.append(idx)
211
- elif "image" in doc:
212
- image_docs.append(_normalize_image(doc["image"]))
213
- image_indices.append(idx)
214
- else:
215
- raise ValueError(f"Unsupported document format at index {idx}")
216
-
217
- scores: list[None | float] = [None] * len(document_strs)
200
+ scores: list[float] = []
201
202
with hf_runner(
203
model,
@@ -223,30 +206,24 @@ def _run_hf(
206
auto_cls=AutoModel,
207
model_kwargs={"key_mapping": CHECKPOINT_TO_HF_MAPPER},
208
) as hf_model:
226
- # Score text documents
227
- if text_docs:
228
- text_scores = hf_model.model.compute_score(
229
- [[query_data, d] for d in text_docs],
230
- max_length=2048,
231
- query_type=query_type,
232
- doc_type="text",
233
- )
234
- for i, s in zip(text_indices, text_scores):
235
- scores[i] = s
236
-
237
- # Score image documents
238
- if image_docs:
239
- image_scores = hf_model.model.compute_score(
240
- [[query_data, d] for d in image_docs],
241
- max_length=2048,
242
- query_type=query_type,
243
- doc_type="image",
244
- )
245
- for i, s in zip(image_indices, image_scores):
246
- scores[i] = s
247
-
248
- assert all(s is not None for s in scores)
249
- return cast(list[float], scores)
209
+ for doc in document_strs:
210
+ if "text" in doc:
211
+ score = hf_model.model.compute_score(
212
+ [[query_data, doc["text"]]],
213
+ max_length=2048,
214
+ query_type=query_type,
215
+ doc_type="text",
216
+ )
217
+ scores.append(score)
218
+ elif "image" in doc:
219
+ score = hf_model.model.compute_score(
220
+ [[query_data, doc["image"]]],
221
+ max_length=2048,
222
+ query_type=query_type,
223
+ doc_type="image",
224
+ )
225
+ scores.append(score)
226
+ return scores
227
228
229
def _run_test(