Skip to content

fix: genai config gaps - decoder path, image_processor.json, spatial_merge_size - #204

Merged
justinchuby merged 2 commits into
mainfrom
justinchu/genai-config-gaps
Apr 23, 2026
Merged

fix: genai config gaps - decoder path, image_processor.json, spatial_merge_size#204
justinchuby merged 2 commits into
mainfrom
justinchu/genai-config-gaps

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Fix 4 gaps vs the reference working Gemma4 genai config:

  1. decoder.filename: "decoder/model.onnx" for multi-model VLM packages (was "model.onnx")
  2. vision.config_filename: "image_processor.json" for Gemma4 (matches ort-extensions convention)
  3. vision.spatial_merge_size: Added from config (was missing)
  4. audio_features: Kept in embedding inputs (accurate to graph)

Also renames examples/gemma4/ort_genai/vlm/processor_config.jsonimage_processor.json.

…merge_size

1. decoder.filename: "decoder/model.onnx" for multi-model packages
2. vision.config_filename: "image_processor.json" (matches ort-extensions)
3. vision.spatial_merge_size: 2 (from config)
4. Update reference config in examples/

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>
@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing ea8251aa370b9c

Model Sub-model Changes Status

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing ea8251aa370b9c

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 60 60 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 66 66 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 107 107 +0.0%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 53 53 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 61 61 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 58 58 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 98 98 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 59 59 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 56 56 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 61 61 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 58 58 +0.0%
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0%
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0%
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0%
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0%
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0%
qwen3_5_vl (hybrid-qwen-vl) num_nodes 408 408 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 166 166 +0.0%
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0%
whisper (speech-to-text) num_nodes 128 128 +0.0%

No performance regressions.

The config_filename is read from genai_config.json at runtime —
ORT GenAI/extensions don't hardcode the filename. Keep the existing
processor_config.json convention for consistency across all VLMs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>
@justinchuby
justinchuby merged commit 12b96ae into main Apr 23, 2026
18 of 19 checks passed
@justinchuby
justinchuby deleted the justinchu/genai-config-gaps branch April 23, 2026 20:50

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

Fixes ORT GenAI export/config generation gaps for Gemma4 multimodal packages so generated artifacts match the known-good reference layout and filenames.

Changes:

  • Update genai_config generation for multimodal packages (decoder filename path) and enrich Gemma4 vision config fields (config_filename, spatial_merge_size).
  • Adjust auto-export processor config writing to emit image_processor.json for Gemma4 (ORT-extensions convention).
  • Update tests and example Gemma4 ORT-GenAI configs to match the new filenames/fields.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/mobius/integrations/ort_genai/genai_config.py Adjusts decoder filename selection for multimodal genai_config generation.
src/mobius/integrations/ort_genai/auto_export.py Writes Gemma4 image_processor.json and includes Gemma4 spatial_merge_size/config_filename in genai_config generation.
src/mobius/integrations/ort_genai/auto_export_test.py Updates Gemma4-related assertions to validate spatial_merge_size and image_processor.json.
examples/gemma4/ort_genai/vlm/image_processor.json Adds the renamed Gemma4 processor config example file.
examples/gemma4/ort_genai/vlm/genai_config.json Updates example genai_config to reference decoder/model.onnx, image_processor.json, and spatial_merge_size.
Comments suppressed due to low confidence (1)

src/mobius/integrations/ort_genai/auto_export.py:195

  • This function’s docstring mentions writing processor_config.json, but the implementation now writes image_processor.json for Gemma4 and processor_config.json otherwise. Please update the docstring to reflect that the output filename varies by model type (and, if callers rely on the name, consider returning the chosen filename explicitly).
    else:
        processor = {
            "image_size": getattr(vision, "image_size", None) or 448,

Comment on lines +356 to 360
decoder_filename = "decoder/model.onnx" if is_multimodal else "model.onnx"
decoder: dict[str, Any] = {
"session_options": _make_session_options(self.ep),
"filename": "model.onnx",
"filename": decoder_filename,
"head_size": self.head_dim,

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

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

For multimodal packages this hardcodes the decoder path to decoder/model.onnx, but not all multi-model exports save the decoder under a decoder/ subfolder. For example, Phi4MMMultiModalTask stores the decoder under the component key model, so ModelPackage.save() writes it to model/model.onnx. This will generate a genai_config that points at a non-existent file for those packages.

Consider making the decoder filename configurable (e.g., a decoder_filename parameter on GenaiConfigGenerator), and set it in write_ort_genai_config() based on which decoder component key is present in the ModelPackage (e.g., prefer decoder/model.onnx if "decoder" in pkg else model/model.onnx if "model" in pkg). Adding a regression test for the phi4mm export path would prevent this from reoccurring.

Copilot uses AI. Check for mistakes.
Comment on lines 277 to 285
vision_kwargs["spatial_merge_size"] = None
vision_kwargs["config_filename"] = "vision_processor.json"
elif model_type in ("gemma4", "gemma4_text"):
vision_kwargs["spatial_merge_size"] = None
vision_kwargs["config_filename"] = "processor_config.json"
vision_cfg = getattr(config, "vision", None)
sms = getattr(vision_cfg, "spatial_merge_size", 2)
vision_kwargs["spatial_merge_size"] = sms

if vision_input_mapping is not None:
vision_kwargs["input_names"] = vision_input_mapping

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

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

genai_config.json can reference vision_processor.json when has_speech is true, but _write_processor_config() never writes that filename (it writes either processor_config.json or image_processor.json). This makes the generated artifacts inconsistent: ORT-GenAI will try to load a processor file that wasn't exported.

A concrete fix is to have processor-config writing share the same filename selection logic as genai-config generation (or write an additional copy under the referenced name when has_speech is set).

Copilot uses AI. Check for mistakes.
@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

justinchuby added a commit that referenced this pull request Apr 23, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>
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.

2 participants