-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[Model][Qwen3VL] Simplify get_mrope_input_positions using numpy
#28302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the get_mrope_input_positions function to use NumPy instead of PyTorch for improved performance and readability. The changes are logical and well-implemented, replacing complex PyTorch operations with more concise NumPy equivalents like np.indices.
I've identified one high-severity issue related to an edge case where empty input_tokens would cause a crash. I've provided a code suggestion to handle this case gracefully. Other than that, the changes look good.
DarkLight1337
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm thinking of directly using the positions from mm_features instead of having to calculate the mask again, WDYT?
I'm not entirely sure how you plan to do this, but not having to compute the mask again does sound sensible. |
|
We can pass |
|
I will open another PR to update the argument list, then we can migrate the models to actually make use of |
|
Opened #28399 |
|
This pull request has merge conflicts that must be resolved before it can be |
|
Feel free to update your PR now |
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
4eacf50 to
a8494d5
Compare
DarkLight1337
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
|
@DarkLight1337 Just to make sure there's no confusion: I only rebased this PR so far but haven't made use of I'm not sure when I'll have time to migrate the logic to use |
|
Feel free to work on this yourself! |
…lm-project#28302) Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com> Signed-off-by: George D. Torres <gdavtor@gmail.com>
…lm-project#28302) Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
Purpose
This PR simplifies the Qwen3VL
get_mrope_input_positionscomputation by usingnp.indicesto make the code more readable.In a profile I also noticed that the torch CPUs ops, especially
torch.tensor(list[int])are slower than their numpy equivalents so this PR also changes the computation to numpy.Before:
After:
Test Plan
Test Result
Before:
After: