Validate Qwen vision embedding output - #2511
Merged
Akshay Sonawane (apsonawane) merged 2 commits intoSep 10, 2026
Merged
Conversation
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
August 31, 2026 23:43
Copilot started reviewing on behalf of
Akshay Sonawane (apsonawane)
August 31, 2026 23:43
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens Qwen2.5-VL vision embedding injection by centralizing validation of embedding/vision tensor shapes and adding a focused unit test to ensure invalid shapes fail fast with clear runtime errors.
Changes:
- Added
Generators::ValidateVisionEmbeddingShapesto validate embedding/vision tensor ranks, dims, and token capacity. - Updated
Qwen2_5_VL_PipelineState::InjectVisionEmbeddingsto reuse the centralized shape validation and to reject non-float embedding outputs early. - Added a C++ unit test covering valid/invalid vision embedding shape scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/cpp/model_tests.cpp | Adds a unit test for the new shape validation helper. |
| src/models/qwen_vl_model.h | Introduces centralized vision embedding shape validation helper. |
| src/models/qwen_vl_model.cpp | Uses centralized validation and adds explicit float element-type check before embedding injection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kunal-vaishnavi
approved these changes
Sep 9, 2026
Akshay Sonawane (apsonawane)
deleted the
msrc/qwen-vl-embedding-bounds
branch
September 10, 2026 04:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the robustness of vision embedding injection in the Qwen2.5-VL model by centralizing and expanding validation of tensor shapes and element types, and by adding targeted unit tests. The main changes ensure that runtime errors due to shape mismatches or invalid data types are caught early and handled with clear error messages.
Validation improvements:
ValidateVisionEmbeddingShapesinqwen_vl_model.hto check that embeddings and vision feature tensors have the correct rank, matching dimensions, and sufficient size for all input tokens.InjectVisionEmbeddingsinqwen_vl_model.cppto callValidateVisionEmbeddingShapesand to explicitly check that the embeddings tensor contains float elements, throwing descriptive exceptions otherwise. [1] [2]Testing:
QwenVisionEmbeddingShapeValidationinmodel_tests.cppto verify that valid shapes pass and invalid shapes throw the expected runtime errors.