Repository navigation
Add fixed-capacity Gemma4 vision exports - #803
ananyaa-ms wants to merge 2 commits into
Conversation
Performance Comparison
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the opt-in fixed-capacity Gemma4 vision export changes.
No open issues 🎉
What changed in this PR
Adds opt-in fixed-capacity Gemma4 vision exports while preserving the default dynamic-output, single-image behavior.
Changes:
- Supports fixed patch/output capacities with fixed or symbolic image batches.
- Preserves spatial pooling and image-major feature ordering, with padding at each image’s tail.
- Adds configuration validation, shape and numerical parity tests, and documentation for trimming outputs before embedding.
| File | Description |
|---|---|
src/mobius/tasks/_gemma4.py |
Defines fixed-capacity vision input shapes and batch contracts. |
src/mobius/models/gemma4.py |
Adds a fixed-capacity spatial pooler and selects it when configured. |
src/mobius/models/gemma4_test.py |
Tests shapes, pooling, FP32/FP16 parity, embedding compatibility, and invalid settings. |
src/mobius/_configs/_base.py |
Adds and validates vision capacity and batch settings. |
docs/api/build_from_module.md |
Documents configuration, tensor shapes, and downstream trimming requirements. |
Review effort: Balanced
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
21c050e to
3616bef
Compare
| ``GatherBlockQuantized`` or requantize weights. PersonaPlex and RE-USE | ||
| bespoke builders do not support this option. | ||
|
|
||
| ``extra_options`` supplies model-specific settings. Currently supported |
There was a problem hiding this comment.
It would be good to have a way to avoid bloat in this option. That said I don't have a better idea yet.
There was a problem hiding this comment.
We're able to modify the model for a fixed capacity output using Olive surgeries (microsoft/Olive#2791). Then this mobius PR won't be needed.
|
Could you include motivation in the PR description? Thanks! |
|
Is #746 related? |
|
@ananyaa-ms if this logic is for fixing some shapes to a static value, I wonder if it would make sense to pair this with the symbolic engine https://github.com/onnx/onnx-shape-inference. So that this becomes generally applicable to models. |
This PR was opened to export a fully-static shaped version of the vision model to support NPU compilation. Based on our conversation @justinchuby , I'm replacing this with an Olive surgery (microsoft/Olive#2791) as it's probably only required for few NPU EPs |
Motivation: Compiling
google/gemma-4-E2B-itfor OpenVINO NPU requires static vision shapes. Expose fixed-capacity vision export throughextra_optionsso the full vision model can compile without splitting it into smaller models.• Add opt-in fixed patch and output capacities while preserving dynamic export defaults.
• Support fixed or dynamic image batches with image-major output blocks.
• Preserve spatial pooling and valid-feature ordering, with unused capacity at each image’s tail.
• Validate export settings and document shapes and downstream trimming requirements.
• Add shape, pooling, FP32/FP16 parity, and package compatibility coverage.