-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix MIGraphX subgraph output selection to avoid promoting internal ou… #26188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix MIGraphX subgraph output selection to avoid promoting internal ou… #26188
Conversation
Seeing ORT value errors when I run this. let me take a look |
Can you post the errors here, please? |
We're not even hitting MIGraphX compile step here. which indicates there's something occurring after this change was added. Let me take a look at this change. |
I confirm that the PR breaks execution of almost all the models with MIGraphX EP. I am seeing errors similar to the one below.
|
@TedThemistokleous @apwojcik thanks for letting me know. This is my theory as to what is causing these issues: the stricter logic for adding outputs to Now, which internally produced output nodes are no longer making it in I will finalize a solution tomorrow. Here is my plan: 1). Create a new data structure to hold the internally produced outputs Although the current implementation is neat, my plan will make the code more readable. Any feedback? |
First off, appreciate the effort on this and contribution. You dove right in. Keep it simple. If you know the outputs of the graph as well as the inputs any other outputs that arent in the graph output list should be pruned regardless of fusions since those are dangling outputs. Essentially as you fuse each node, ensure there's a consumer to the output, if the next() node is null for that output path then you know its dangling. You can double check this in the final output of the graph to ensure even in the case of output layer being fused, you still have the same outputs and inputs to the entire model. I think there's a way to massage the logic here to just exclude dangling outputs, and ensure they're filtered from the final output. That ensures that the fused graph use still gets Onnx's optimizations but none of the dangling outputs are then propagated and therefore not allocated in the later stages of this EP |
Thank you for the response and encouragement:) After studying the code some more, I think there may also be a hidden bug in the current/old implementation in this branch: Is there any reason MiGraphX did not use the logic for finding the inputs and outputs from |
697d22e
to
ac1458f
Compare
I would actually be open to a refactor at some point. Found the solution btw. Its an edge case with using subgraph when all the graph is supported/used here so we get into a degenerate case when there's an onnx model with dangling outputs for the intermediate nodes. Will post fix shortly. I inherited a bit of this code so I'll likely be cleaning things as I go through. If you have any suggestions or ideas I'm open to input and by nature of this being open source, you're welcome to contribute too. |
Fix for this should be here now - #26224 |
Sounds good. I will write out a refactoring on this branch so you can see what I have in mind. I suggest calling |
…tputs
Description
Tighten output selection in
MIGraphXExecutionProvider::GetSubGraph(...)
so a node’s output is included only if it has an external consumer (outside the subgraph) or is a top-level graph output.Motivation and Context
Previously, MIGraphX could promote internal-only values (e.g., BatchNormalization auxiliary outputs) to fused graph outputs, causing downstream compile errors. This fix conforms MIGraphX subgraph output selection to the boundary-only rule used elsewhere, preventing accidental promotion of unused outputs.
Related: #26176