Skip to content

Emit current shape-only ONNX GenAI tensor contracts - #725

Closed
justinchuby wants to merge 1 commit into
mainfrom
squad/fix-metadata-shape-contract
Closed

Emit current shape-only ONNX GenAI tensor contracts#725
justinchuby wants to merge 1 commit into
mainfrom
squad/fix-metadata-shape-contract

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • remove retired tensor-contract rank emission from the shared ONNX GenAI metadata builders and serializer
  • retain exact scalar shape: [], named symbolic dimensions, and independent Any dynamic dimensions without inventing fixed extents
  • retire the obsolete workflow capability list required by the current consumer
  • refresh all 15 producer-conformance package snapshots
  • add current TensorContract schema coverage across every signal package and stale-fixture guards

Fixes the producer failure reported by onnx-genai signal run https://github.com/justinchuby/onnx-genai/actions/runs/33886695719.

Validation

  • generated and snapshot-compared all 15 packages
  • current onnx-genai Rust validator: 15/15 valid
  • ONNX GenAI metadata suite: 722 passed, 3 skipped
  • Sensenova/static-cache related suite: 50 passed
  • Ruff 0.16.2 lint and format checks passed
  • git diff --check

A broader local non-integration run also reproduced three unrelated failures unchanged on Mobius origin/main (GGUF evidence expectation, Qwen Image diffusers API drift, and ModernBERT synthetic tolerance).

Publish explicit tensor shapes from the shared ONNX GenAI metadata authority, preserve symbolic and unconstrained dimensions, and remove retired workflow capabilities. Refresh all 15 conformance packages and validate them against the current consumer TensorContract schema.

Co-authored-by: Copilot <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot September 4, 2026 15:46
@justinchuby

Copy link
Copy Markdown
Member Author

Closing per project decision to pause cross-repository producer coordination and make the onnx-genai Mobius conformance signal manual-only for now. The implementation remains available in this PR if producer conformance is resumed later.

@@ -0,0 +1,74 @@
# Copyright (c) Microsoft Corporation.


def test_published_metadata_rejects_rank_shape_disagreement():
with pytest.raises(ValueError, match="declares rank 2.*has rank 1"):
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 014812f28b7ce4

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 Sep 4, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 014812f28b7ce4

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 68 68 +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 105 105 +0.0%
gpt2 model_size_bytes 324 KB 324 KB +0.0%
gpt2 num_nodes 54 54 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 60 60 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 56 56 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 94 94 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 58 58 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 54 54 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 60 60 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 56 56 +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 265 265 +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 127 127 +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 450 450 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 176 176 +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.

🔵 Needs a closer look

It changes a broad, externally-consumed metadata/schema surface (tensor contracts + manifest) across many fixtures and producers, so a final human verification of downstream compatibility is warranted.

Pull request overview

This PR updates Mobius’ ONNX GenAI inference-metadata emission to match the current schema expectations by removing retired rank fields from tensor contracts and retiring the workflow manifest capabilities list, while preserving explicit shape semantics (including scalars shape: [], symbolic dims, and unconstrained Any dims). It also refreshes the conformance fixtures and adds tests to ensure produced packages continue to validate against the canonical JSON schema.

Changes:

  • Retire tensor-contract rank emission (schema + producers + tests) and rely on shape length as the sole rank signal.
  • Remove/normalize away pipeline.workflow.manifest.capabilities and centralize YAML serialization via _dump_yaml + _published_metadata.
  • Add a schema-validation test over all generated signal packages and refresh all fixture snapshots to the new serialized form.
File summaries
File Description
tests/static_cache_metadata_test.py Updates static-cache assertions from rank to shape/len(shape).
tests/onnx_genai_current_schema_test.py New test validating all materialized packages against the current JSON schema.
tests/generate_onnx_genai_validation_packages.py Uses _dump_yaml for deterministic, normalized metadata output.
tests/compare_onnx_genai_validation_packages.py Adds invariant check that retired tensor-contract rank is not serialized.
tests/canonical_workflow_contract_test.py Updates contract assertions to require shape and forbid rank.
tests/fixtures/onnx_genai_workflows/vlm/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/video/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/tts/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/static_cache/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/speculative/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/shared_state_pixel_flow/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/protbert_protein_embeddings/inference_metadata.yaml Snapshot refresh: removes rank, updates dynamic dims to Any where appropriate.
tests/fixtures/onnx_genai_workflows/masked/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/hierarchical_audio/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/esm2_protein_embeddings/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/diffusion/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/diffusion_guided/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/decoder/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/codec/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
tests/fixtures/onnx_genai_workflows/adapter/inference_metadata.yaml Snapshot refresh: removes rank fields and workflow capabilities.
src/mobius/models/sensenova_u1_test.py Updates shared-state workflow expectations to forbid manifest capabilities.
src/mobius/integrations/onnx_genai/workflow_metadata_test.py Updates workflow tests to forbid manifest capabilities and rely on shape.
src/mobius/integrations/onnx_genai/speech_to_text_workflow_metadata_test.py Updates tests to forbid manifest capabilities.
src/mobius/integrations/onnx_genai/speech_enhancement_metadata_test.py Updates tests to use len(shape) rather than rank.
src/mobius/integrations/onnx_genai/shared_state_flow_metadata.py Removes rank from emitted tensor contracts; keeps explicit shape.
src/mobius/integrations/onnx_genai/package_facts_test.py Updates image media contract assertion from rank to shape.
src/mobius/integrations/onnx_genai/inference_metadata.py Removes rank dependence in contract compatibility and routes YAML writes through _dump_yaml.
src/mobius/integrations/onnx_genai/inference_metadata_test.py Updates test fixtures/helpers to match shape-only contract serialization.
src/mobius/integrations/onnx_genai/decoder_metadata.py Uses _dump_yaml for normalized YAML serialization.
src/mobius/integrations/onnx_genai/convert.py Uses _dump_yaml for normalized YAML serialization.
src/mobius/integrations/onnx_genai/codec_workflow_metadata_test.py Updates codec workflow contract assertion to remove rank.
src/mobius/integrations/onnx_genai/auto_export_test.py Updates auto-export workflow assertions from rank to shape/len(shape) and forbids capabilities.
src/mobius/integrations/onnx_genai/_workflow_contract.py Makes shape emission explicit (errors on unknown rank), uses Any for anonymous dynamic dims, and normalizes returned workflow via _published_metadata.
src/mobius/integrations/onnx_genai/_schema/inference_metadata.schema.json Updates schema: removes tensor-contract rank requirement, requires shape array, and documents Any semantics.
src/mobius/integrations/onnx_genai/_metadata_io.py Introduces _published_metadata normalization and _dump_yaml wrapper used by writers.
src/mobius/integrations/onnx_genai/_metadata_io_test.py New unit tests covering normalization behavior and Any shape semantics.
Review details
  • Files reviewed: 37/37 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

3 participants