Skip to content

Conversation

huachenheli
Copy link
Contributor

@huachenheli huachenheli commented Aug 29, 2025

Purpose

In #23838, Gemini caught an edge case where checking image/video token in input_tokens does not guarantee input_tokens.index(image_token_id, st) won't throw, hence the missing try-catch block is needed. After discussion with @DarkLight1337 we want to add this check in the default vl mrope code as well.

image

Test Plan

Note that there's no meaningful perf impact since checking an item in the list is generally very fast:

(vllm) [[email protected] ~/github/vllm (mrope)]$ python -m timeit "99999 in range(100000)"
5000000 loops, best of 5: 84.3 nsec per loop
(vllm) [[email protected] ~/github/vllm (mrope)]$ python -m timeit "99999 in range(100000)"
5000000 loops, best of 5: 83 nsec per loop
(vllm) [[email protected] ~/github/vllm (mrope)]$ python -m timeit "99999 in range(100000)"
5000000 loops, best of 5: 84.3 nsec per loop

e2e benchmarks (reference only):
Without this PR:

============ Serving Benchmark Result ============
Successful requests:                     10        
Benchmark duration (s):                  3.75      
Total input tokens:                      156       
Total generated tokens:                  1667      
Request throughput (req/s):              2.67      
Output token throughput (tok/s):         444.86    
Total Token throughput (tok/s):          486.49    
---------------Time to First Token----------------
Mean TTFT (ms):                          943.28    
Median TTFT (ms):                        881.49    
P99 TTFT (ms):                           1103.42   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          11.93     
Median TPOT (ms):                        11.91     
P99 TPOT (ms):                           13.91     
---------------Inter-token Latency----------------
Mean ITL (ms):                           14.21     
Median ITL (ms):                         14.30     
P99 ITL (ms):                            17.47     
==================================================

With this PR:

============ Serving Benchmark Result ============
Successful requests:                     10        
Benchmark duration (s):                  3.69      
Total input tokens:                      156       
Total generated tokens:                  1642      
Request throughput (req/s):              2.71      
Output token throughput (tok/s):         445.57    
Total Token throughput (tok/s):          487.90    
---------------Time to First Token----------------
Mean TTFT (ms):                          888.17    
Median TTFT (ms):                        772.37    
P99 TTFT (ms):                           1079.04   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          12.35     
Median TPOT (ms):                        12.56     
P99 TPOT (ms):                           13.80     
---------------Inter-token Latency----------------
Mean ITL (ms):                           14.78     
Median ITL (ms):                         14.40     
P99 ITL (ms):                            16.96     
==================================================

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@huachenheli huachenheli changed the title [mrope] Fix edge case. [mrope] Fix edge case where getting index of image/video token can potentially throw. Aug 29, 2025
Signed-off-by: Chenheli Hua <[email protected]>
@huachenheli huachenheli marked this pull request as ready for review August 29, 2025 03:49
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this doesn't improve performance significantly, the code still becomes more robust. Thanks for working on this!

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) August 29, 2025 03:58
@huachenheli huachenheli changed the title [mrope] Fix edge case where getting index of image/video token can potentially throw. [mrope][Qwen2-VL] Fix edge case where getting index of image/video token can potentially throw in default vl mrope implementation. Aug 29, 2025
@mergify mergify bot added the qwen Related to Qwen models label Aug 29, 2025
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 29, 2025
@vllm-bot vllm-bot merged commit 2d0afcc into vllm-project:main Aug 29, 2025
43 of 47 checks passed
eicherseiji pushed a commit to eicherseiji/vllm that referenced this pull request Sep 9, 2025
…ken can potentially throw in default vl mrope implementation. (vllm-project#23895)

Signed-off-by: Chenheli Hua <[email protected]>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
…ken can potentially throw in default vl mrope implementation. (vllm-project#23895)

Signed-off-by: Chenheli Hua <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants