-
Notifications
You must be signed in to change notification settings - Fork 369
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 all commits
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 |
|---|---|---|
|
|
@@ -514,9 +514,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) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -637,12 +637,10 @@ class VLMPipeline::VLMPipelineImpl : public VLMPipelineBase{ | |
| } | ||
| }; | ||
|
|
||
| // TODO: remove it when QWEN ticket-167316/GEMMA3 ticket-171180 is fixed | ||
| // TODO: remove it when GEMMA3 ticket-171180 is fixed | ||
| bool requires_sdpa(const std::filesystem::path& models_dir) { | ||
| auto vlm_config = utils::from_config_json_if_exists<VLMConfig>(models_dir, "config.json"); | ||
| return vlm_config.model_type == VLMModelType::QWEN2_VL || | ||
| vlm_config.model_type == VLMModelType::QWEN2_5_VL || | ||
| vlm_config.model_type == VLMModelType::GEMMA3; | ||
| return vlm_config.model_type == VLMModelType::GEMMA3; | ||
| } | ||
|
Comment on lines
+640
to
644
|
||
|
|
||
| VLMPipeline::VLMPipeline( | ||
|
|
||
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: