Skip to content

Standardize symbolic dimensions in common ORT GenAI decoder exports - #751

Draft
tadani3 wants to merge 1 commit into
mainfrom
tommasoadani/naming_convention_investigation
Draft

tadani3 wants to merge 1 commit into
mainfrom
tommasoadani/naming_convention_investigation

Conversation

@tadani3

@tadani3 tadani3 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Standardize symbolic dimension names used by Mobius's common ORT GenAI decoder
exports.

The updated decoder paths now consistently use:

  • batch_size
  • sequence_length
  • past_sequence_length
  • total_sequence_length

This applies to:

  • Standard causal language-model decoders
  • Hybrid attention/recurrent decoders
  • The shared inputs_embeds decoder builder used by multimodal and
    speech-language packages

The tests save each graph as ONNX, load it again, and verify the serialized
input/output dimension names. This ensures the test covers the interface seen
by downstream consumers rather than only Mobius's in-memory graph.

Motivation

Olive's discrepancy check needs to convert symbolic ONNX dimensions into
concrete shapes when creating test inputs.

Mobius's common decoder paths previously emitted several names for the same
concept, including:

  • batch and batch_size
  • sequence_len and sequence_length
  • past_sequence_len and past_sequence_length

There was also an internal inconsistency where a cache input declared
past_sequence_len, while the attention-mask expression referred to
past_seq_len. These are different symbols from an ONNX consumer's
perspective.

As a result, Olive needed Mobius-specific aliases and fallback values to
resolve the exported shapes. Establishing a consistent vocabulary in Mobius
makes the ONNX interface more predictable and moves responsibility for naming
correctness to the exporter.

Changes

  • Canonicalize dynamic dimensions in CausalLMTask.
  • Canonicalize dynamic dimensions in HybridCausalLMTask.
  • Canonicalize dynamic dimensions in build_decoder_from_embeds.
  • Use the standalone total_sequence_length symbol instead of arithmetic
    expression strings.
  • Add save/load regression coverage for standard text decoders.
  • Add save/load regression coverage for shared multimodal decoders.
  • Update directly related task documentation and assertions.

Validation

  • src/mobius/tasks/_task_test.py
    • 115 passed
  • Affected Qwen and Gemma graph-construction tests
    • 60 passed
    • 4 skipped
  • Ruff lint and formatting checks passed.
  • git diff --check passed.

A broader graph-construction run completed with 1,379 passed and 48 skipped.
It also reported 14 existing shape-inference/checker failures in specialized
models under the local environment's older ONNX dependency stack. The focused
tests covering the changed decoder paths passed.

Compatibility

This does not change tensor names, ranks, dtypes, or concrete runtime shapes.
Normal inference callers should therefore be unaffected.

It does change symbolic dimension metadata. A downstream tool that explicitly
depends on the previous strings could be affected. This draft PR is intended
to establish whether these symbolic names should be treated as a documented
ORT GenAI export contract.

Previously exported ONNX artifacts are not modified by this change.

Follow-ups

  • Confirm the canonical symbolic-dimension contract with Mobius, Olive, and
    ORT GenAI owners.
  • Audit the remaining ORT GenAI-compatible specialized tasks and migrate them
    to the same vocabulary.
  • Add a package-level validator that detects unknown, legacy, or inconsistent
    generation dimensions before saving an ORT GenAI package.
  • Decide how older Mobius ONNX artifacts should be handled:
    • temporary compatibility aliases,
    • a minimum supported Mobius version, or
    • an explicit migration path.
  • Trace Olive's normal shape metadata sources and replace hard-coded fallback
    values with explicit discrepancy-check inputs or derived values.
  • Remove Olive's legacy Mobius aliases only after the standardized Mobius
    contract is released and Olive's compatibility policy is established.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Tommaso Adani seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing c2fde938 → 6a3e58b7

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.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing c2fde938 → 6a3e58b7

Model Sub-model Changes Status
bert (feature-extraction) model 0 ⚪
falcon model 0 ⚪
gemma2 model 0 ⚪
gemma4 (gemma4) decoder 0 ⚪
gemma4 (gemma4) embedding 0 ⚪
gemma4 (gemma4) vision_encoder 0 ⚪
gemma4_text model 0 ⚪
gpt2 model 0 ⚪
llama model 0 ⚪
llama (static-cache) model 0 ⚪
mamba (ssm-text-generation) model 0 ⚪
phi3 model 0 ⚪
phi3 (static-cache) model 0 ⚪
qwen model 0 ⚪
qwen (static-cache) model 0 ⚪
qwen2 model 0 ⚪
qwen2 (static-cache) model 0 ⚪
qwen2_moe model 0 ⚪
qwen2_moe (static-cache) model 0 ⚪
qwen3 model 0 ⚪
qwen3 (static-cache) model 0 ⚪
qwen3_5_moe (hybrid-text-generation) model 0 ⚪
qwen3_5_text (hybrid-text-generation) model 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) decoder 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) embedding 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0 ⚪
qwen3_moe model 0 ⚪
qwen3_moe (static-cache) model 0 ⚪
qwen3_next (hybrid-text-generation) model 0 ⚪
t5 (seq2seq) decoder 0 ⚪
t5 (seq2seq) encoder 0 ⚪
whisper (speech-to-text) decoder 0 ⚪
whisper (speech-to-text) encoder 0 ⚪

No architecture changes detected. ✅


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

This branch has not been deployed

No deployments
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