Fix C# phi-2 test - #1050
Merged
Merged
Conversation
Chester Liu (skyline75489)
marked this pull request as ready for review
November 15, 2024 01:45
Contributor
Author
|
Note that there's still resource leaks in the C# tests. Will try to fix it later. |
Ryan Hill (RyanUnderhill)
approved these changes
Nov 15, 2024
Baiju Meswani (baijumeswani)
approved these changes
Nov 15, 2024
Abhishek Jindal (ajindal1)
pushed a commit
that referenced
this pull request
Nov 21, 2024
The C# phi-2 test was skipped due to the wrong model path. This PR intends to fix it.
Abhishek Jindal (ajindal1)
added a commit
that referenced
this pull request
Nov 22, 2024
Ti-Tai Wang (titaiwangms)
added a commit
that referenced
this pull request
Apr 26, 2026
## Summary Adds Mistral3/Pixtral VLM support to onnxruntime-genai with multi-image inference. Includes C++ image processor, PixtralVisionState for per-image vision processing, Python export support, and comprehensive tests. ## Changes ### C++ Runtime - **Mistral3 image processor** — `[IMG]`/`[IMG_BREAK]`/`[IMG_END]` token expansion based on image resolution and patch geometry, multi-image support - **PixtralVisionState** — per-image vision processing loop with bounds checks and overflow guard; slices from padded batch tensor using `image_sizes` metadata from ort-extensions `PixtralImageSizes` op - **Virtual `SetExtraInputs`** — proper polymorphic dispatch for vision state subclasses - **`IsPixtralFamily()` model type detection** — enables Pixtral-specific codepath - **`processor_config.json`** — with `PixtralImageSizes` preprocessing step - **`context_length` / `max_length` separation** — `context_length` controls KV cache allocation while `max_length` controls generation stopping, preventing premature EOS with large image token counts - **INT32 `input_ids`** — token IDs above 32767 (Pixtral `[IMG]`=128011) require int32 ### Python Export Support - Mistral3 model classes (`Mistral3Config`, `Mistral3ForConditionalGeneration`) - FP8 dtype promotion for checkpoint loading - `get_user_content()` handler for Mistral3 prompt formatting ## Multi-Image Architecture Pixtral uses dynamic image sizes (28×28 to 1540×1540) so images can't be batched in the vision encoder. `PixtralVisionState` processes each image individually by: 1. Reading `image_sizes` tensor from ort-extensions `PixtralImageSizes` op (provides per-image H×W) 2. Slicing the padded `[N, C, max_H, max_W]` batch tensor to extract each image's actual pixels 3. Running vision encoder on each image separately 4. Concatenating vision embeddings for the decoder ## Dependencies - **onnxruntime-extensions PR #1050** — `PixtralImageSizes` custom op for image size metadata - **PR #2076** — YaRN RoPE parity fixes (merged) ✅ ## Testing - 5 multi-image token expansion tests (various image sizes and counts) - Virtual dispatch verification tests for `SetExtraInputs` - YaRN RoPE parity tests (from merged #2076) - E2E verified: multi-image (fish.jpg + challenge.jpg) correctly describes both images --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
The C# phi-2 test was skipped due to the wrong model path. This PR intends to fix it.