NXP backend: Fix bug when a partition output is also used by nodes inside the partition.#20423
Merged
MartinPavella merged 2 commits intoJun 30, 2026
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20423
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 5 Unrelated FailuresAs of commit 7520ce4 with merge base 2ec218c ( NEW FAILURE - The following job has failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Collaborator
Author
|
@novak-vaclav @irtrukhina please feel free to have a look. |
novak-vaclav
left a comment
Collaborator
There was a problem hiding this comment.
A few minor comments, otherwise good job! 😊
0f02959 to
281c99a
Compare
novak-vaclav
approved these changes
Jun 26, 2026
jirioc
approved these changes
Jun 29, 2026
281c99a to
7520ce4
Compare
Collaborator
Author
|
The failing checks seem unrelated and the internal CI is passing. Merging. |
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
[De]quantize nodes that form QDQ clusters are handled by turning float tensors to int8 and assigning to them the quantization parameters in the Neutron IR. But these operators cannot just disappear because the graph would be disconnected (there would be "holes" in it). Usually we can redirect the outputs of these operators to their inputs, and if this is not possible, we can convert the operators to identity operators, which are optimized out later.
Up until a recent PR,
dequantizenodes were always being turned into identity ops (not skipped), which caused issues in optimization passes. This is because the QDQ nodes are converted before the compute nodes. So for example adequantizethat's near the end of the model would be converted to a noop Transpose and inserted into theoperatorslist before the compute ops which topologically come before it. So the topological ordering of the graph was broken.The recent PR made it so that only the
dequantizenodes that consume model inputs are turned to identity, and the rest is skipped (fixing the topological order issue). That PR however failed to identify an edge case where if a node is both the output of a partition and it is also used as input to other nodes inside that partition, thedequantizenode that comes after it cannot be skipped, and it must be turned into identity. Therefore, we cannot avoid breaking the topological order.For this reason, after all edge operators are converted to Neutron IR (and before any IR optimizations), the operators of the graph need to be topologically sorted.
This PR fixes the bug with the intermediate output, and it introduces the topological operator sorting.
Test plan
Unit test provided.
cc @robert-kalmar @JakeStevens @digantdesai @rascani