Skip to content

[experimental only] Add onnx-genai InferenceMetadata export (--runtime onnx-genai) - #398

Merged
justinchuby merged 2 commits into
mainfrom
feat/onnx-genai-metadata-export
Jul 16, 2026
Merged

[experimental only] Add onnx-genai InferenceMetadata export (--runtime onnx-genai)#398
justinchuby merged 2 commits into
mainfrom
feat/onnx-genai-metadata-export

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Adds a Mobius integration that emits onnx-genai's own inference_metadata.yaml (the InferenceMetadata schema) instead of ORT-GenAI's genai_config.json, so onnx-genai models carry the config that runtime needs.

  • New --runtime onnx-genai build target; emitter src/mobius/integrations/onnx_genai/inference_metadata.py.
  • Emits model.attention (type/heads/head_dim), model.max_sequence_length, kv_cache.native_dtype, and required_capabilities using the runtime's supported strings (grouped_query_attention / multi_head_attention).
  • KV pre-size capacity defaults to min(4096, model limit) (avoids exceeding WebGPU's 256 MiB buffer limit for large context windows); optional --max-length override.
  • Round-trip verified: onnx-genai loads a GQA WebGPU model from the emitted inference_metadata.yaml alone (no genai_config.json) and produces coherent output.

lintrunner clean; emitter pytest 8 passed.

Emit runtime-supported attention capabilities and bound the default serving KV capacity to 4096 tokens, with a configurable --max-length override.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 1ab1661260d6b0

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 Jul 13, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 1ab1661260d6b0

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 68 68 +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 54 54 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 62 62 +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 60 60 +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 62 62 +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 413 413 +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.

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

Adds an onnx-genai integration path that emits inference_metadata.yaml for Mobius exports, alongside a new CLI --runtime onnx-genai mode to generate that sidecar after saving the ONNX package.

Changes:

  • Introduces mobius.integrations.onnx_genai with helpers to generate and write inference_metadata.yaml.
  • Adds CLI support for mobius build --runtime onnx-genai plus --max-length to control the emitted serving KV capacity.
  • Updates ModelPackage.save() docs to reference the new onnx-genai metadata generation path.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/mobius/integrations/onnx_genai/inference_metadata.py New generator/writer for onnx-genai inference_metadata.yaml.
src/mobius/integrations/onnx_genai/inference_metadata_test.py Unit tests covering metadata generation, YAML formatting, and validation.
src/mobius/integrations/onnx_genai/init.py Public exports for the onnx-genai integration API.
src/mobius/_model_package.py Docstring update referencing onnx-genai metadata export option.
src/mobius/main.py Adds --runtime onnx-genai flow and --max-length validation/plumbing.

Comment on lines +69 to +73
capabilities = ["grouped_query_attention" if is_gqa else "multi_head_attention"]

attention: dict[str, Any] = {
"type": "group_query_attention" if is_gqa else "multi_head_attention",
"num_kv_heads": num_kv_heads,
Comment on lines +33 to +36
"attention": {
"type": "group_query_attention",
"num_kv_heads": 2,
"num_attention_heads": 14,
" - grouped_query_attention\n"
"model:\n"
" attention:\n"
" type: group_query_attention\n"
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.76190% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mobius/__main__.py 11.11% 5 Missing and 3 partials ⚠️
...bius/integrations/onnx_genai/inference_metadata.py 87.09% 5 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@justinchuby
justinchuby marked this pull request as draft July 14, 2026 17:49
@justinchuby
justinchuby marked this pull request as ready for review July 16, 2026 15:16
@justinchuby
justinchuby merged commit 40dbf1f into main Jul 16, 2026
13 of 20 checks passed
@justinchuby
justinchuby deleted the feat/onnx-genai-metadata-export branch July 16, 2026 15:19
@justinchuby justinchuby changed the title Add onnx-genai InferenceMetadata export (--runtime onnx-genai) [experimental only] Add onnx-genai InferenceMetadata export (--runtime onnx-genai) Jul 16, 2026
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