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 14, 05:30 UTC
[mrope][Qwen2-VL] Fix edge case where getting index of image/video token can potentially throw in default vl mrope implementation. (#23895)
Signed-off-by: Chenheli Hua <huachenheli@outlook.com>
Chenheli Hua committed
Aug 28, 2025 at 23:29 UTC
2d0afcc9dc925928ee8764c826a3661e487f9f82
1 file changed
+10
-4
vllm/model_executor/layers/rotary_embedding/mrope.py
+10
-4
@@ -670,12 +670,18 @@ class MRotaryEmbedding(RotaryEmbedding):
670
image_index, video_index = 0, 0
671
for _ in range(image_nums + video_nums):
672
video_second_per_grid_t = 0.0
673
- if image_token_id in input_tokens and remain_images > 0:
674
- ed_image = input_tokens.index(image_token_id, st)
673
+ if remain_images > 0:
674
+ try:
675
+ ed_image = input_tokens.index(image_token_id, st)
676
+ except ValueError:
677
+ ed_image = len(input_tokens) + 1
678
else:
679
ed_image = len(input_tokens) + 1
677
- if video_token_id in input_tokens and remain_videos > 0:
678
- ed_video = input_tokens.index(video_token_id, st)
680
+ if remain_videos > 0:
681
+ try:
682
+ ed_video = input_tokens.index(video_token_id, st)
683
+ except ValueError:
684
+ ed_video = len(input_tokens) + 1
685
else:
686
ed_video = len(input_tokens) + 1
687
if ed_image < ed_video: