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 12, 16:00 UTC
Fix EVS crash when using `video_embeds` inputs in Qwen2.5-VL (#29232)
Signed-off-by: zitian.zhao <zitian.zhao@tencentmusic.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
ZiTian Zhao committed
Nov 22, 2025 at 22:48 UTC
d84d8f4429a5246a9d9f179b47fac7e13801710d
1 file changed
+16
-1
vllm/model_executor/models/qwen2_5_vl.py
+16
-1
@@ -230,6 +230,9 @@ class Qwen2_5_VLVideoEmbeddingInputs(TensorSchema):
230
- hidden_size must match the hidden size of language model backbone.
231
- video_grid_thw shape: (num_videos, 3) in (grid_t, grid_h, grid_w)
232
format
233
+ - second_per_grid_ts: The video time interval (in seconds) for each
234
+ grid along the temporal dimension in the 3D position IDs. Returned
235
+ when `videos` is not `None`.
236
"""
237
238
type: Literal["video_embeds"]
@@ -244,6 +247,11 @@ class Qwen2_5_VLVideoEmbeddingInputs(TensorSchema):
247
TensorShape("nv", 3),
248
]
249
250
+ second_per_grid_ts: Annotated[
251
+ torch.Tensor | None,
252
+ TensorShape("nv"),
253
+ ] = None
254
+
255
256
Qwen2_5_VLVideoInputs: TypeAlias = (
257
Qwen2_5_VLVideoPixelInputs | Qwen2_5_VLVideoEmbeddingInputs
@@ -1311,6 +1319,7 @@ class Qwen2_5_VLForConditionalGeneration(
1319
type="video_embeds",
1320
video_embeds=video_embeds,
1321
video_grid_thw=video_grid_thw,
1322
+ second_per_grid_ts=second_per_grid_ts,
1323
)
1324
1325
def _process_image_input(
@@ -1422,7 +1431,13 @@ class Qwen2_5_VLForConditionalGeneration(
1431
1432
# Cast to long to match the original code
1433
# https://github.com/huggingface/transformers/blob/41980ce93e775f6c88500c51c8db7946fc6a2add/src/transformers/models/qwen2_5_vl/modular_qwen2_5_vl.py#L491 # noqa
1425
- second_per_grid_ts = video_input["second_per_grid_ts"].long()
1434
+ second_per_grid_ts = video_input.get("second_per_grid_ts")
1435
+ if second_per_grid_ts is None:
1436
+ raise ValueError(
1437
+ "second_per_grid_ts is required when video_pruning_rate > 0 "
1438
+ "is enabled for video inputs, including the video_embeds path."
1439
+ )
1440
+ second_per_grid_ts = second_per_grid_ts.long()
1441
tokens_per_second = self.config.vision_config.tokens_per_second
1442
1443
video_embeds_out = []