Skip to content

Add grid dimension validation - #2219

Merged
apsonawane merged 6 commits into
mainfrom
asonawane/qwen-oob
Jun 12, 2026
Merged

Add grid dimension validation#2219
apsonawane merged 6 commits into
mainfrom
asonawane/qwen-oob

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

This pull request adds important validation and safety checks to the QwenVisionPipeline::CalculateWindowIndex function in src/models/qwen_vl_vision.cpp. The changes are focused on improving robustness by validating input dimensions and preventing integer overflows during memory allocation.

Input Validation and Safety Improvements:

  • Added checks to ensure that all grid dimensions (grid_t, grid_h, grid_w) are positive; throws an exception if not.
  • Added upper bounds for grid dimensions and total allocation size to prevent integer overflow and excessive memory usage (limits each dimension and the total number of elements to ~1 billion). Throws exceptions if exceeded.
  • Refactored allocation and indexing logic to use the new validated and padded dimensions, improving clarity and safety. [1] [2]

Copilot AI review requested due to automatic review settings June 11, 2026 20:00
@apsonawane
apsonawane requested a review from a team as a code owner June 11, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens robustness in the Qwen VL vision pipeline by adding validation around QwenVisionPipeline::CalculateWindowIndex, which computes window reordering indices from image_grid_thw-derived dimensions.

Changes:

  • Added input validation for non-positive grid dimensions.
  • Introduced upper bounds intended to prevent excessive allocations / overflows.
  • Refactored allocation and indexing to use precomputed padded dimensions and a single alloc_size.

Comment thread src/models/qwen_vl_vision.cpp Outdated
Comment thread src/models/qwen_vl_vision.cpp Outdated
Comment thread src/models/qwen_vl_vision.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/models/qwen_vl_vision.cpp Outdated
@apsonawane
apsonawane enabled auto-merge (squash) June 11, 2026 23:06
@apsonawane
apsonawane merged commit 4c4091d into main Jun 12, 2026
63 of 67 checks passed
@apsonawane
apsonawane deleted the asonawane/qwen-oob branch June 12, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants