fix(morphizen): guard empty output NodeArg in try_fuse - #594
Open
AMDmoore wants to merge 2 commits into
Open
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 |
AMDmoore
force-pushed
the
fix/node-arg-empty-output
branch
from
July 30, 2026 11:04
1c58746 to
f58cc67
Compare
L2 Accuracy Results (EP vs CPU)
Threshold: 0.01 | Run: 3493 - Commit: |
MorphiZen EP Performance Results
EPContext Export Performance
EPContext Import Performance
OGA Benchmark Results
OGA Wheel Smoke (Python benchmark_e2e.py)
Run: 3493 - Commit: |
Large hybrid/quantized models (e.g. NemotronH INT4-RTN) contain nodes whose
first output slot is an empty, non-existent NodeArg -- optional outputs and
DequantizeLinear's optional zero_point in INT4-quantized weights. Reading such
a slot via node_arg_get_name fatal-CHECKs in node_arg.cpp
("node_arg doesn't exist!"), aborting the whole compilation.
Add node_first_existing_output_name() and guard the try_fuse boundary
(calculate_return_values, check_loop, isolated-node initializer collection,
meta_def node emission, and Pass::fuse) so empty/optional output slots fall
back to the first existing output name instead of crashing.
Co-Authored-By: Cursor <cursor@cursor.com>
Made-with: Cursor
Co-authored-by: Cursor <cursoragent@cursor.com>
amd-mingw
reviewed
Jul 30, 2026
amd-mingw
reviewed
Jul 30, 2026
amd-mingw
requested changes
Jul 30, 2026
AMDmoore
force-pushed
the
fix/node-arg-empty-output
branch
from
July 30, 2026 16:31
f58cc67 to
259cef8
Compare
AMDmoore
added a commit
that referenced
this pull request
Jul 31, 2026
Address review feedback on PR #594: - Move node_first_existing_output_name next to node_get_first_output_name in the node utilities (node.hpp / node.cpp) so both pass.cpp and pass_imp.cpp reuse it instead of duplicating the first-existing-output loop. - Pass a NodeConstRef (node_ref) at both call sites. Co-authored-by: Cursor <cursoragent@cursor.com>
AMDmoore
added a commit
that referenced
this pull request
Jul 31, 2026
Address review feedback on PR #594: - Move node_first_existing_output_name next to node_get_first_output_name in the node utilities (node.hpp / node.cpp) so both pass.cpp and pass_imp.cpp reuse it instead of duplicating the first-existing-output loop. - Pass a NodeConstRef (node_ref) at both call sites. Co-authored-by: Cursor <cursoragent@cursor.com>
AMDmoore
force-pushed
the
fix/node-arg-empty-output
branch
2 times, most recently
from
July 31, 2026 10:45
122e0bb to
d48fd6d
Compare
Address review feedback on PR #594: - Move node_get_first_existing_output_name next to node_get_first_output_name in the node utilities (node.hpp / node.cpp) so both pass.cpp and pass_imp.cpp reuse it instead of duplicating the first-existing-output loop. - At the NodeConstRef call sites, pass the underlying const Node& explicitly via *node_ref.ptr() rather than relying on the implicit NodeConstRef -> const Node& conversion. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Large hybrid/quantized models (e.g. NemotronH INT4-RTN) contain nodes with empty, non-existent
NodeArgslots. Two distinct cases show up:TopKconsumes only itsIndicesoutput (output 1); theValuesoutput (output 0) is unused, so output slot 0 is an emptyNodeArg.DequantizeLinear's optionalzero_pointin INT4-quantized weights.Reading such a slot via
node_arg_get_namefatal-CHECKs innode_arg.cpp(node_arg doesn't exist!), aborting the entire model compilation.Fix:
node_get_first_existing_output_name()as a node utility next tonode_get_first_output_name(innode.hpp/node.cpp), and use it at everytry_fuseboundary that reads a node's output name (calculate_return_values,check_loop, meta_def node emission, andPass::fuse). It skips empty/non-existent output slots and returns the first existing output name. A fused node must still produce at least one real output, so itCHECKs (matchingnode_get_first_output_node_arg) rather than emitting a bogus node name.node_arg_existsbefore readingzero_point's name.Test plan
fixbranch succeeds;hipgpu.dll/hip-compiler.dllrebuilt and deployed.run_oga_dynamiccompiles and runs with nonode_arg doesn't existcrash (MorphiZen EP Load ONNX Model Success+Compilation successful).mainproduces byte-identical output, confirming zero behavioral change for models whose output slots all exist.Made with Cursor