Repository navigation
mlir-imp: resolve If/Loop body values that shadow the owner's output names locally - #1333
Open
amd-rmotiram wants to merge 1 commit into
Open
amd-rmotiram wants to merge 1 commit into
amd-rmotiram wants to merge 1 commit into
Conversation
|
Thanks for opening a PR! This project follows LLVM's incremental-development and AI-tool-use Before requesting review, please check that:
Reviewers are assigned through |
…names locally Outer NodeArgs without a Value (the enclosing op's own outputs) are no longer treated as captures, and the node-arg name map is built pre-order so the region op claims its result names before same-named body values. Fixes import of whisper merged decoders. Adds numeric test test_if_subgraph_names.py. Co-authored-by: Cursor <cursoragent@cursor.com>
amd-rmotiram
force-pushed
the
fix/model-load-failures
branch
from
October 26, 2026 21:15
f724fee to
f22e92a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mlir-imp: fix import of If bodies whose outputs reuse the If's output names
Summary
The 12 whisper "merged" decoders (whisper-base and whisper-large-v3-turbo
decoder_model_merged{,_bnb4,_int8,_q4,_quantized,_uint8}) fail during the ONNX -> MLIR import:Their
Ifbranches return values named the same as theIf's own outputs. ONNX allows this: inside a branch, the branch's value shadows the outer name. The importer mishandled it in two places inmorphizen/mlir-imp/src/mlir-graph.cpp.Problem
flowchart TD A["Import If: output names declared<br/>(placeholders, no Value yet)"] --> B["Import branch bodies"] B --> C["Branch looks up present.0.decoder.key"] C --> D["Not local, found in parent<br/>as an empty placeholder"] D --> E["Treated as a capture<br/>register_captured_alias(name, null)"] E --> F["CHECK fails: null Value"] style F fill:#f8d7da,stroke:#c00 G["Build main-graph name table<br/>(post-order: children first)"] --> H["Branch value claims the name"] H --> I["If output dropped (emplace keeps first)"] I --> J["Partitioning fails<br/>morphizen-ep.cpp:894 / :461"] style J fill:#f8d7da,stroke:#c00The second failure only shows up once the first is fixed.
Solution
flowchart TD C["Branch looks up a name"] --> L{"Local?"} L -- Yes --> U["Use local value"] L -- No --> P{"In parent AND<br/>has a Value?"} P -- Yes --> R["Real capture"] P -- No --> S["Not found: branch creates its own<br/>value (shadows outer name)"] style R fill:#d4edda,stroke:#080 style S fill:#d4edda,stroke:#080 G["Build main-graph name table<br/>(pre-order: parent first)"] --> H["If claims its output names first"] H --> I["Same-named branch values don't override"] style I fill:#d4edda,stroke:#080get_node_arg_index: an outer name only counts as a capture if it already has a Value. Genuine captures always do, because outer nodes are imported in topological order.initialize_node_args_map: walk pre-order, matchingpopulate_node_arg_indexes.add_node: log a warning when a named input has no producer and is replaced bynone. Before this change, that case asserted.Testing (Strix Halo, gfx1151)
'onnx.If' op failed to build output inits (fully-static output shapes required).test/numeric/tests/test_if_subgraph_names.py(then and else branches) and the existingtest_dangling_outputs.pypass: 6/6. The new test fails without this fix.decoder_model.onnxcrashes (0xC0000005) both with and without this change.Known gaps
onnx.Ifstatic-shape error above blocks them.Ifonly.Loop/Scan/nested-Ifshadowing uses the same code path but isn't directly tested, and there is no lit test.add_nodewarning and anoneinput. ORT's load-time validation normally rejects such models first.