[WebGPU] fixes pointer arithmetic bug for multi-image inputs for mistral3 - #2510
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes multi-image Pixtral/Ministral vision-output handling by avoiding invalid pointer arithmetic on non-byte-addressable device buffer handles (notably WebGPU), preventing Generator.SetInputs access violations when num_images_ > 1.
Changes:
- Stops constructing per-image output tensor views via
feat_raw + offset, which is unsafe for EPs wherep_device_is an opaque handle (e.g., WebGPU). - Runs the vision encoder into a standalone per-image output tensor and copies results into the combined
image_featuresbuffer usingByteWrapTensor(...).subspan(...).CopyFrom(...).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…tatement in function' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
kunal-vaishnavi
approved these changes
Sep 1, 2026
kunal-vaishnavi
enabled auto-merge (squash)
September 1, 2026 20:07
kunal-vaishnavi
deleted the
prathikrao/webgpu-multi-image-input-bugfix
branch
September 1, 2026 20:59
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.
Fix WebGPU multi-image Pixtral output handling
The customer's native multi-image repro shows that two-image Ministral/Pixtral inference succeeds on CPU and that each image succeeds independently on WebGPU, but the two-image WebGPU case fails in
Generator.SetInputs, including repeatable0xC0000005native access violations.PixtralVisionStateran vision once per image and wrote each result into an offset view of the combinedimage_featuresoutput. The WebGPU comment insrc/ep/webgpu/interface.cppidentified the issue:p_device_is aWGPUBufferhandle cast touint8_t*, not byte-addressable memory;p_device_ + offsetis therefore not a valid sub-buffer handle. The first image uses offset zero, while the second image does not.This change runs each image into a standalone device output tensor and copies it into the combined feature tensor through
ByteWrapTensor(...).subspan(...).CopyFrom(...). That path handles nonzero WebGPU offsets safely instead of constructing invalid handle-derived tensor views.