Skip to content

Commit 063eb8c

Browse files
justinchubyCopilot
andauthored
Generate graph-driven ORT GenAI decoder configs (#611)
## Summary - emit the released architecture-neutral `model.type: "decoder"` contract for compatible single-model decoder-only text graphs - derive semantic inputs, cache templates, outputs, sparse global cache slots, recurrent pairs, and sliding-window metadata from the optimized ONNX graph - preserve runtime-specific LFM2 and Phi-3 LongRoPE behavior, fail closed for Mobius GPT-2's incompatible separate-cache ABI and unsupported state layouts, and record runtime compatibility without emitting main-only `state_groups` - keep GGUF runtime promotion evidence-gated while validating the exact SmolLM F16/CPU/tokenizer route end to end ## Validation - 228 focused ORT GenAI/GGUF config tests - 2,871 affected CLI/ORT GenAI/GGUF tests - exact SmolLM deterministic generation on `onnxruntime-genai` 0.14.1 and 0.15.2 - exact Q4_K_M fail-closed/dequantized parity test from the stacked base - full initialized lintrunner pass - two independent high-confidence reviews plus a final fix verification Stacked on #609. --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent aa93ab6 commit 063eb8c

6 files changed

Lines changed: 734 additions & 73 deletions

File tree

‎docs/cli_reference.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,44 @@ tokenizer files to the output directory:
161161
- With `--config` (local directory): tokenizer files are copied from that
162162
directory.
163163

164+
For a single-model decoder-only text graph, Mobius emits the architecture-neutral
165+
`model.type: "decoder"` contract supported by onnxruntime-genai 0.14.0 and newer.
166+
The graph determines the exact semantic input names, output names, cache templates,
167+
and global cache indices, so dense, MoE, tied-weight, quantized, and unknown
168+
architecture names do not need a runtime registry entry.
169+
170+
Architecture-specific types remain only where the runtime selects different
171+
behavior. `lfm2` uses its legacy convolution-cache implementation. `gpt2` selects
172+
`Gpt_Model`, but Mobius's separate rank-4 key/value cache ABI does not match that
173+
runtime's rank-5 combined-cache contract, so config generation currently fails
174+
closed. `phi3`, `phimoe`, and `phi3small` retain their names because the released
175+
generator uses them to recompute LongRoPE caches when generation crosses the
176+
short-context threshold. Multimodal, audio, encoder-decoder, special-position-ID,
177+
and split pipeline packages remain outside the generic path and require their
178+
dedicated types and schemas. These exceptions follow the
179+
[v0.15.2 runtime model factory](https://github.com/microsoft/onnxruntime-genai/blob/v0.15.2/src/models/model.cpp#L874-L907),
180+
which selects `Gpt_Model`, `LFM2_Model`, `WhisperModel`, `MarianModel`,
181+
`MultiModalLanguageModel`, and `DecoderOnlyPipelineModel` separately from
182+
`DecoderOnly_Model`; Qwen-VL's special position handling is likewise implemented in
183+
its [dedicated runtime model](https://github.com/microsoft/onnxruntime-genai/blob/v0.15.2/src/models/qwen_vl_model.cpp).
184+
The Phi-3 LongRoPE threshold dispatch is in the released
185+
[`Generator`](https://github.com/microsoft/onnxruntime-genai/blob/v0.15.2/src/generators.cpp).
186+
187+
Released generic recurrent state is enabled only when the optimized graph exposes
188+
matching `conv_state` and `recurrent_state` names derived from the same cache
189+
template. Mobius rejects static-cache names and heterogeneous state layouts that
190+
the released config schema cannot represent rather than emitting a misleading
191+
dense cache. The deferred state-manifest work is tracked by
192+
[#605](https://github.com/onnxruntime/mobius/issues/605).
193+
194+
Each export also writes `runtime_compatibility.json`. Generic decoder metadata
195+
records the minimum runtime version and the latest stable release exercised by
196+
Mobius (0.15.2); it never emits the unreleased `decoder.state_groups` field.
197+
Generic config availability does not promote a GGUF runtime verdict: the only
198+
runtime-supported GGUF route remains the exact pinned SmolLM F16/CPU package, while
199+
SmolLM2 remains rejected because its GGUF padding-token metadata conflicts with the
200+
official pinned tokenizer.
201+
164202
#### Example
165203

166204
```bash

‎src/mobius/integrations/gguf/_runtime_package.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,14 @@ def write_gguf_runtime_package(
280280
"ORT GenAI runtime packaging requires an explicit evidenced execution "
281281
"provider: cpu, cuda, or dml."
282282
)
283-
artifacts.update(write_ort_genai_config(pkg, str(stage), ep=execution_provider))
283+
artifacts.update(
284+
write_ort_genai_config(
285+
pkg,
286+
str(stage),
287+
ep=execution_provider,
288+
runtime_version=runtime_version,
289+
)
290+
)
284291
else:
285292
from mobius.integrations.onnx_genai import write_onnx_genai_config
286293

0 commit comments

Comments
 (0)