Unverified Commit 2d0afcc9 authored by Chenheli Hua's avatar Chenheli Hua Committed by GitHub
Browse files

[mrope][Qwen2-VL] Fix edge case where getting index of image/video token can...


[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: default avatarChenheli Hua <huachenheli@outlook.com>
parent b4f9e963
......@@ -670,12 +670,18 @@ class MRotaryEmbedding(RotaryEmbedding):
image_index, video_index = 0, 0
for _ in range(image_nums + video_nums):
video_second_per_grid_t = 0.0
if image_token_id in input_tokens and remain_images > 0:
if remain_images > 0:
try:
ed_image = input_tokens.index(image_token_id, st)
except ValueError:
ed_image = len(input_tokens) + 1
else:
ed_image = len(input_tokens) + 1
if video_token_id in input_tokens and remain_videos > 0:
if remain_videos > 0:
try:
ed_video = input_tokens.index(video_token_id, st)
except ValueError:
ed_video = len(input_tokens) + 1
else:
ed_video = len(input_tokens) + 1
if ed_image < ed_video:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment