Skip to content

NXP backend: Fix bug when a partition output is also used by nodes inside the partition.#20423

Open
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-946-fix-failing-multiple-input-output-model-test
Open

NXP backend: Fix bug when a partition output is also used by nodes inside the partition.#20423
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-946-fix-failing-multiple-input-output-model-test

Conversation

@MartinPavella

@MartinPavella MartinPavella commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

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, dequantize nodes 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 a dequantize that's near the end of the model would be converted to a noop Transpose and inserted into the operators list 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 dequantize nodes 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, the dequantize node 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

@MartinPavella MartinPavella self-assigned this Jun 22, 2026
@MartinPavella MartinPavella added module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: nxp Changes to the NXP Neutron backend delegate labels Jun 22, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🔗 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 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 1 Unrelated Failure

As of commit 0f02959 with merge base 1a78804 (image):

NEW FAILURE - The following job has failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 22, 2026
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@MartinPavella

Copy link
Copy Markdown
Collaborator Author

@novak-vaclav @irtrukhina please feel free to have a look.

@novak-vaclav novak-vaclav requested a review from Copilot June 23, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@novak-vaclav novak-vaclav self-requested a review June 23, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: nxp Changes to the NXP Neutron backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants