-
Notifications
You must be signed in to change notification settings - Fork 380
Change input shape for 3D position_ids of Qwen 2.5 VL with M-RoPE #3400
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -499,9 +499,11 @@ class ModelRunner { | |
| if (hidden_state_input && hidden_state_input.get_size() > 0) { | ||
| m_request.set_tensor("hidden_states", hidden_state_input); | ||
| } | ||
| if (position_ids.get_shape().size() == 3) { | ||
| // flatten positions ids for 3D position ids case | ||
| position_ids.set_shape({ov::shape_size(position_ids.get_shape())}); | ||
| if (position_ids.get_shape().size() == 3 && position_ids.get_shape()[0] == 3 && | ||
| position_ids.get_shape()[1] == 1) { | ||
| // M-RoPE: squeeze pseudo-batch dim [3, 1, total_token_num] -> [3, total_token_num] | ||
| const auto& position_ids_shape = position_ids.get_shape(); | ||
| position_ids.set_shape({position_ids_shape[0], position_ids_shape[2]}); | ||
| } | ||
|
Comment on lines
+517
to
522
|
||
| // typical LLM parameters | ||
| if (!m_cached_position_ids) { | ||
|
|
||
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.
The hardcoded check for shape[0] == 3 and shape[1] == 1 is specific to M-RoPE (Multi-dimensional Rotary Position Embedding) used by Qwen2-VL models. This is fragile because:
Consider: