Add Ministral-3-3B VLM recipe: hybrid Olive + Mobius export#352
Draft
titaiwangms wants to merge 1 commit intomainfrom
Draft
Add Ministral-3-3B VLM recipe: hybrid Olive + Mobius export#352titaiwangms wants to merge 1 commit intomainfrom
titaiwangms wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “builtin” export + inference recipe for mistralai/Ministral-3-3B-Instruct-2512, targeting ONNX Runtime GenAI by exporting the text decoder via Olive/ModelBuilder and the vision/embedding pieces via Mobius, plus generating the runtime genai_config.json/processor_config.json.
Changes:
- Introduces an end-to-end export/config-generation script (
optimize.py) and a GenAI inference example (inference.py). - Adds Olive configs for CPU/mobile (INT4) and CUDA (FP16), along with recipe metadata (
info.yml) and docs (README.md). - Adds custom patched modeling code under
codes/intended to support ONNX export.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| mistralai-Ministral-3-3B-Instruct-2512/builtin/user_script.py | Adds model config constants (currently with import-time HF loading). |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/requirements.txt | Declares Olive + Mobius + torch/transformers dependencies. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/README.md | Documents export workflow, output layout, and inference usage. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/optimize.py | Implements export pipeline and GenAI config/tokenizer patching. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/info.yml | Registers builtin recipe metadata (keywords/EPs/devices/name). |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/inference.py | Provides a CLI to run text-only and multimodal inference with ORT GenAI. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/cuda/text.json | Olive ModelBuilder config for FP16 CUDA decoder export. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/cpu_and_mobile/text.json | Olive ModelBuilder config for INT4 CPU/mobile decoder export. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/codes/modeling_ministral3.py | Adds patched model components for ONNX-export-friendly behavior. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/codes/init.py | Exposes Ministral3Model symbol. |
| mistralai-Ministral-3-3B-Instruct-2512/builtin/.gitignore | Ignores generated model artifacts and Olive cache. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mistralai-Ministral-3-3B-Instruct-2512/builtin/requirements.txt
Outdated
Show resolved
Hide resolved
8058122 to
9d5c64b
Compare
a140a47 to
b3f8592
Compare
- Olive for text decoder, Mobius for vision + embedding - Lazy config loading via __getattr__ (PEP 562) - Fail-fast validation for missing components - Transforms-based processor_config.json - image_token_id=10 from HF config - Pin mobius dependency - Add eval.py (AI2D benchmark, follows Qwen VLM pattern) - Fix: dtype string handling, model save paths, genai_config filenames - Fix: conditional position_ids, vision output squeeze, embedding zero-padding Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b3f8592 to
5969770
Compare
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.
Summary
Complete olive recipe for exporting
mistralai/Ministral-3-3B-Instruct-2512VLM to ONNX for ORT GenAI inference. Uses a hybrid approach justified by Pixtral's architecture:Pixtral's dynamic H×W vision input and 2D RoPE are incompatible with Olive's dynamo-based export, making Mobius the correct tool for the vision and embedding components.
Recipe Structure
Key Features
processor_config.json: Matches ORT GenAI's image preprocessor format (DecodeImage → ConvertRGB → Resize → Rescale → Normalize)genai_config.jsongeneration: Setsimage_token_id=10, correct model type, token IDs from HF configTokenizersBackend→LlamaTokenizerfor genai compatibilityReview Feedback Addressed (8 comments)
user_script.pyuses__getattr__pattern; import takes 1ms with no network callsmobius@043a56finstead of@mainfor reproducibilitymobius._builder.resolve_dtype; pass dtype string directly tomobius.build()ValueError/FileNotFoundErrorif vision/embedding components are missingos.replace()instead ofshutil.move()patch_size,spatial_merge_size, token IDs from HuggingFace config viauser_scriptbos_token_id,eos_token_id,pad_token_id,image_token_idfrom HF configtokenslist ininference.pyBugs Fixed During E2E Testing
build()accepts dtype as a string, nottorch.dtype— pass CLI string directlysave()outputsmodel.onnxat root, not in component subdirectory — save directly tovision/andembedding/subdirsvision/model.onnxandembedding/model.onnxto match subdirectory layoutmodeling_ministral3.pydocumented as reference-only (not used byoptimize.py)Testing
genai_config.jsonverified:image_token_id=10, transforms-basedprocessor_config.jsonFiles Changed (11 files, +885)
optimize.pyuser_script.pyinference.pycpu_and_mobile/text.jsoncuda/text.jsoncodes/modeling_ministral3.pyrequirements.txtinfo.yml,README.md,.gitignore