Skip to content

Commit 3de1b7b

Browse files
justinchubyCopilot
andcommitted
Merge branch 'main' into roy/qwen38-mtp-head-export
Resolves 15 conflict blocks across 8 files. Twelve were formatting-only: main had run ruff format over code this branch also touched (quoted vs bare type annotations, list concat vs unpacking, line wrapping, a docstring rewording). Took main's side so the formatter would not immediately undo the merge. One of those blocks also dropped `_index_dim1`, which was defined and never called. Three were genuine two-sided changes and both sides are kept: - `__main__.py`: this branch added the MTP sidecar save; main replaced the runtime dispatch with `write_gguf_runtime_package` (dual onnx-genai/ort-genai from #543). The code after the conflict already referenced both, so dropping either would not have compiled. - `_group_query_attention.py` / its test: main added sliding-window support (`local_window_size` from the attention bias) plus a `TestSlidingWindowSurvivesFusion` suite; this branch had only a reformat there. `inference_metadata_test.py` needed more than conflict resolution. The branch's copy predates main's removal of `add_explicit_package_io` and referenced it seven times, so taking the branch side broke collection for six modules. Took main's file and re-applied this branch's `TestMtpSpeculatorMetadata` block (with its `_MtpBackboneConfig` fixture and `_seed_backbone_metadata` helper), plus the `write_mtp_speculator_metadata` import. `_seed_backbone_metadata` seeded `{"model_type": "qwen3_5_text"}`, which the runtime schema rejects as an unknown top-level property — a schema failure for a reason unrelated to the speculator block under test. Seeded an empty document instead; the writer only appends `speculative`. Tests: gguf + rewrite_rules 475 passed / 1 skipped. In inference_metadata_test.py, 4 pre-existing failures remain (reproduced on origin/main using main's own test file) and `TestMtpSpeculatorMetadata`'s schema case still fails — see the PR discussion, it is a stale committed schema rather than a defect in this branch. Co-authored-by: Copilot <[email protected]> Copilot-Session: d60eb808-7cc6-4abc-b48d-2a6dd3841624
2 parents b6747e6 + eec8e3f commit 3de1b7b

224 files changed

Lines changed: 57502 additions & 2222 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/golden_regen.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@ jobs:
7777
if: inputs.device != 'cuda'
7878
run: pip install onnxruntime
7979

80-
- name: Install onnxruntime (GPU)
81-
if: inputs.device == 'cuda'
82-
run: pip install onnxruntime-gpu
83-
8480
- name: Install dependencies
8581
run: |
8682
pip install -r requirements/ci/requirements.txt
8783
pip install -e '.[testing,transformers]'
8884
85+
- name: Install onnxruntime (GPU)
86+
if: inputs.device == 'cuda'
87+
run: |
88+
# Install after project dependencies so the CPU ORT package cannot overwrite it.
89+
pip install --pre --no-deps --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ onnxruntime-gpu
90+
8991
- name: Reject trust_remote_code cases
9092
run: |
9193
# Safety: never auto-run models that require trust_remote_code

‎.github/workflows/gpu_l4_golden_parity.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ jobs:
6464
pip install -r requirements/ci/requirements.txt
6565
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
6666
pip install -e '.[testing,transformers]'
67-
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
67+
# PyPI's ORT 1.27+ wheel requires CUDA 13, while these runners use CUDA 12.
68+
pip install --pre --no-deps --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ onnxruntime-gpu
69+
pip install --no-deps onnxruntime-genai-cuda
6870
6971
- name: Check for golden test data
7072
id: check_golden

‎.github/workflows/gpu_l5_generation_e2e.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ jobs:
6464
pip install -r requirements/ci/requirements.txt
6565
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
6666
pip install -e '.[testing,transformers]'
67-
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
67+
# PyPI's ORT 1.27+ wheel requires CUDA 13, while these runners use CUDA 12.
68+
pip install --pre --no-deps --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ onnxruntime-gpu
69+
pip install --no-deps onnxruntime-genai-cuda
6870
6971
- name: Run L5 generation E2E tests
7072
env:

‎.github/workflows/main.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ jobs:
283283
pip install -r requirements/ci/requirements.txt
284284
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
285285
pip install -e '.[testing]'
286-
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple/ "onnxruntime-gpu<1.27" onnxruntime-genai-cuda
286+
# PyPI's ORT 1.27+ wheel requires CUDA 13, while these runners use CUDA 12.
287+
pip install --pre --no-deps --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ onnxruntime-gpu
288+
pip install --no-deps onnxruntime-genai-cuda
287289
- name: Run fast integration tests
288290
env:
289291
HF_TOKEN: ${{ secrets.HF_TOKEN }}

‎.github/workflows/validation_examples_gpu.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ jobs:
8383
pip install -r requirements/ci/requirements.txt
8484
pip install -e '.[testing,transformers]'
8585
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
86-
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
86+
# PyPI's ORT 1.27+ wheel requires CUDA 13, while these runners use CUDA 12.
87+
pip install --pre --no-deps --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ onnxruntime-gpu
88+
pip install --no-deps onnxruntime-genai-cuda
8789
8890
- name: Run ${{ matrix.name }}
8991
env:

‎.gitignore‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ __marimo__/
213213
*.onnx.data
214214
*.gguf
215215

216+
# Generated conformance-package artifacts. The metadata beside them is the
217+
# contract under review and is committed; the graphs and adapter weights are a
218+
# deterministic function of
219+
# tests/generate_onnx_genai_validation_packages.py, so committing them would
220+
# store megabytes of bytes no reviewer reads. CI regenerates and validates
221+
# them; tests get them from the materialized_workflow_packages fixture.
222+
tests/fixtures/onnx_genai_workflows/**/*.safetensors
223+
224+
# Where CI and the test fixture materialize those packages in full. Nothing
225+
# here is reviewable input: it is the regenerated output the validate and
226+
# conformance steps consume.
227+
validation/
228+
216229
# Common test dirs
217230
output/**
218231
cache_dir/**

‎CHANGELOG.md‎

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,144 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- An exported graph is no longer transcribed into its own workflow component.
13+
A component backed by a shipped `.onnx` file now declares only `ports.roles`;
14+
the artifact answers every question about which ports exist and what shape
15+
they have, and the runtime resolves them against the live session. The
16+
removed block was a second statement of the same ABI with nothing keeping the
17+
two in agreement — the same defect as `model.io`, one level down. Package
18+
validation and runtime conformance both stay at 11/11 against the pinned ONNX
19+
GenAI branch, and the contract tests now resolve every role, invocation
20+
binding and state pair against the graph itself rather than against the
21+
metadata's agreement with a copy of itself, which is a strictly stronger
22+
check.
23+
24+
Policy graphs keep their contracts, and that boundary was measured rather
25+
than assumed: a workflow value inherits its dtype, rank and request axis from
26+
the port that produced it, so dropping them left row-wise emits untyped and
27+
made 4 of the 11 packages invalid. Those contracts type the workflow's own
28+
dataflow; they do not describe an external interface.
29+
30+
- Deep decoders are now covered where the cache layer annotation actually
31+
matters. Every metadata package built in the test suite had two layers, and
32+
below ten a cell label sorts identically whether ordered lexicographically,
33+
numerically or by insertion — so a `layer` derived from a cell's position
34+
rather than parsed from its port name would have passed every assertion while
35+
transposing caches on any real model. `canonical_workflow_contract_test` now
36+
builds twelve-layer dynamic, static-cache and hybrid decoders and pins that
37+
the declared layer restates the port name, that ordering by it recovers the
38+
buffer lists, and that a hybrid's alternating groups own layers their cells'
39+
positions never equal. A producer that dropped the parse leaves the 101
40+
pre-existing assertions green and fails seven of these.
41+
42+
- Every component a task builds now declares an optimization role. Qwen3-TTS's
43+
four loop-wiring graphs (`code_predictor_prefill`,
44+
`code_predictor_step_embedder`, `code_predictor_indices`, `talker_text_step`)
45+
were absent from `TTSTask.model_roles`, so `build_from_module` fell back to
46+
the `"decoder"` role and offered them the GQA / QKV-packing passes meant for
47+
attention stacks, and `inspect_components` under-reported the package by four
48+
components. They now declare a `"glue"` role: a parameter-free graph that
49+
reads every tensor it uses from a graph input. `arch_validation_test` fails
50+
any task that builds a component it does not declare, and a network-free unit
51+
test pins the same invariant for Qwen3-TTS.
52+
53+
### One canonical serialized representation
54+
55+
#### Changed
56+
57+
- **`pipeline.workflow` is now the only place a package describes its graph
58+
ABI.** No export emits `model.io`, including a bare single-file decoder: that
59+
case is a one-component workflow, not a different kind of document. `model`
60+
keeps package-wide geometry and capabilities and nothing else. Two writable
61+
statements of one fact are a defect whatever they contain — nothing forces
62+
them to agree, and a reader of either never learns the other exists — so a
63+
runtime that wants an optimized single-graph path derives it by lowering the
64+
workflow instead. Verified end to end: the ONNX GenAI runtime executes the
65+
fixed-capacity decode path from the workflow alone, with no `model.io` in the
66+
package.
67+
68+
#### Added
69+
70+
- An ONNX component that ships an artifact declares no port contracts. The
71+
`.onnx` file travels inside the package and is authoritative for which ports
72+
exist and what each one's dtype, rank and shape is, so transcribing that into
73+
YAML would be a second writable statement of one fact — the very thing this
74+
section removes — sitting one level below `model.io` rather than beside it.
75+
The runtime resolves ports against the live session, which catches a name the
76+
graph does not expose instead of agreeing with a stale echo of it. A
77+
producer-synthesized policy graph is the exception and states its contracts,
78+
because a workflow value takes its dtype, rank and request axis from the port
79+
that produced it: those contracts are the dataflow's type annotations, not a
80+
description of an external interface.
81+
- Every ONNX component declares `ports.roles`: what it *does* with a value bound
82+
to a port. An invocation records which SSA value reaches a port, not whether
83+
that port is tokens, a mask or logits. Mobius mints these port names in its own
84+
task builders, so it states the mapping (`input_ids`→`token_ids`,
85+
`inputs_embeds`, `attention_mask`, `position_ids`, `logits`,
86+
`last_hidden_state`→`hidden_states`, `encoder_hidden_states`,
87+
`audio_features`) rather than inferring it. A port outside that vocabulary
88+
carries no role.
89+
- State port aliases declare `role` (`key`/`value`) and `layer`. A layer's key
90+
and value buffers are the same dtype and shape, and a cell's label sorts
91+
lexicographically so `cache_10` precedes `cache_2` — pairing per-layer buffers
92+
positionally would silently transpose two layers' caches. Both fields are
93+
emitted together or not at all, so a recurrent or convolution cache is never
94+
given a fabricated index.
95+
- `IndexedScatter.kv_length_ports` names the port carrying the graph-visible
96+
valid length, beside the existing `write_indices_ports`. The two control
97+
vectors are both rank-1 integers and are therefore indistinguishable by shape;
98+
with both named, the whole fixed-capacity ABI is recoverable from the workflow.
99+
- `tests/canonical_workflow_contract_test.py` pins the invariant. It asks one
100+
set of shape-agnostic questions of dynamic, static-cache, FP8, heterogeneous
101+
and composite packages — and of all 11 checked-in fixtures — so a future
102+
feature cannot grow its own top-level block while every feature-specific test
103+
keeps passing.
104+
105+
### Fixed-capacity (static) KV cache and FP8 KV cache metadata
106+
107+
#### Added
108+
109+
- `--features static-cache` now produces onnx-genai metadata instead of being
110+
refused. The producer publishes the write cursor (`write_indices`), the valid
111+
length (`nonpad_kv_seqlen`), the fixed-capacity buffer contracts, the
112+
per-layer input/output pairs, and an `indexed_scatter` state-service update
113+
discipline naming the cursor, the capacity and the per-component port that
114+
carries it. The buffers are declared as `recurrence: {kind: invariant}` loop
115+
cells and the capacity as a `package.cache_capacity` literal workflow input.
116+
Nothing dispatches on model name; the ports are read from the graph.
117+
- Heterogeneous caches keep their own disciplines. Gemma 4's sliding layers stay
118+
on a growing rank-4 BNSH cache while its full-attention layers use rank-3
119+
fixed-capacity buffers, and only the layers that own a buffer bind ports in a
120+
state group — its KV-shared suffix owns none.
121+
- A `static_cache` package joined the checked-in onnx-genai conformance
122+
fixtures, so the engine exercises the fixed-capacity carry and the write
123+
cursor rather than only the growing-tensor path.
124+
125+
#### Fixed
126+
127+
- Gemma 4's shared-KV fallback pinned a 4-D BNSH shape onto *any* borrowed KV
128+
tensor whose rank was not 4. A static-cache source hands over a fully known
129+
rank-3 `[batch, capacity, kv_hidden]` buffer, so this overwrote a correct
130+
shape with a wrong one — corrupting the declared shape of
131+
`updated_key_cache.N` and defeating the rank-3 static-source test further
132+
down, which would then have transposed a rank-3 tensor as BNSH. The fallback
133+
now only supplies a shape when there is none.
134+
- Gemma 4's vision-language decoder dropped `attention_mask` whenever the export
135+
was static, but a Gemma 4 decoder is only *partly* static: its sliding layers
136+
keep a dynamic cache and build their bias from that mask. The hybrid decoder
137+
therefore lost all padding information. Both builders now apply one rule — a
138+
mask exists exactly when some layer still has a dynamic cache — so a fully
139+
static decoder carries no unused port and a hybrid one keeps its mask.
140+
- `--features fp8-kv-cache` no longer silently produces a float16 cache. The
141+
gate only tested whether GQA fusion was *expected*; the pass now reports how
142+
many caches it converted and the build fails when the answer is zero, naming
143+
the reason: FP8 KV storage needs an attention operator with `k_scale`/
144+
`v_scale` inputs, which a `TensorScatter` + `ai.onnx` `Attention` static-cache
145+
graph does not have.
146+
147+
10148
### Qwen3.5/3.6-MoE mixed float/quantized decoder (Olive checkpoints)
11149

12150
#### Fixed
@@ -33,6 +171,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
33171
- Other checkpoint formats retain their previous graph construction; this
34172
change only aligns Mobius with Olive's module selection.
35173

174+
- Qwen3.6 VL exports now emit the packed Qwen image-processing pipeline when
175+
the composite build exposes its unwrapped `qwen3_5_moe_text` config. This
176+
adds the required `PatchImage` transform so `pixel_values` matches the
177+
vision encoder's rank-2 packed-patch input.
178+
36179
#### Added
37180

38181
- `Qwen2MoELayer(..., shared_expert_gate_class=...)` to override the linear

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ multi-component export for pipelines.
3232
| **Multimodal** | Gemma 3/4, Phi-4MM (vision + audio + LoRA), Nemotron Parse, LLaVA, InternVL2, Mage-VL (image + streaming video), MiniCPM-V 4.6, Qwen2.5-VL, Qwen3-VL, Qwen3.5/3.6-VL, Pixtral |
3333
| **Encoder-only** | BERT, RoBERTa, ALBERT, DeBERTa, DistilBERT, ELECTRA, XLNet |
3434
| **Encoder-Decoder** | BART, T5/mT5, Marian, M2M-100, Pegasus, BigBird-Pegasus |
35-
| **Speech-to-Text** | Whisper, Moonshine, FastConformer-RNNT, FunASR, Qwen3-ASR, SenseVoice |
35+
| **Speech-to-Text** | Whisper, Moonshine, FastConformer-RNNT, FunASR, GLM-ASR, Qwen3-ASR, SenseVoice |
3636
| **Audio** | Wav2Vec2, HuBERT, WavLM, SpeechT5 |
3737
| **Vision** | ViT, BEiT, DeiT, DINOv2, Swin, CLIP, SigLIP |
3838
| **Diffusion** | Stable Diffusion (UNet + VAE + ControlNet), Flux, SD3, DiT, QwenImage / Qwen-Image-Edit-2509, HunyuanDiT, CogVideoX |

‎docs/cli_reference.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ mobius build --model meta-llama/Llama-3.2-1B output/ \
236236
|--------|-------------|
237237
| `--task TASK` | Model task (auto-detected if not specified). Use `mobius list tasks` to see available tasks. |
238238
| `--dtype DTYPE` | Target dtype for model weights: `f16`, `bf16`, `f32` (also accepts `float16`, `bfloat16`, `float32`). If omitted, the dtype is auto-detected from the HuggingFace config (`torch_dtype`); provide `--dtype` to override it. Weights are cast at save time. |
239+
| `--revision REVISION` | Immutable HuggingFace revision used consistently for config, weights, tokenizer, processor, and runtime metadata artifacts. |
239240
| `--no-weights` | Export graph structure only, without weight data. Useful for inspection or testing. |
240241
| `--external-data FORMAT` | External data format: `onnx` (default) or `safetensors`. |
241242
| `--max-shard-size SIZE` | Maximum shard size for safetensors external data (e.g. `5GB`). Only used with `--external-data safetensors`. |

‎docs/design/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ perf-benchmarking
1515
phi4mm-architecture
1616
phi4mm-four-model-split
1717
phi4mm-ort-genai-integration
18+
sensenova-u1-neo-unify
1819
test-infrastructure-map
1920
```

0 commit comments

Comments
 (0)