Skip to content

NXP backend - added support for aten.conv2d using the new Neutron flow#19717

Open
novak-vaclav wants to merge 2 commits into
pytorch:mainfrom
nxp-upstream:feature/EIEX-861-add-conv2d-support-new-neutron-flow
Open

NXP backend - added support for aten.conv2d using the new Neutron flow#19717
novak-vaclav wants to merge 2 commits into
pytorch:mainfrom
nxp-upstream:feature/EIEX-861-add-conv2d-support-new-neutron-flow

Conversation

@novak-vaclav
Copy link
Copy Markdown
Contributor

@novak-vaclav novak-vaclav commented May 21, 2026

Summary

Added support for aten.conv2d using new Neutron flow.

Test plan

tests can be manually run using pytest -c /dev/null backends/nxp/tests/

cc @robert-kalmar @JakeStevens @digantdesai @rascani @MartinPavella

Copilot AI review requested due to automatic review settings May 21, 2026 08:04
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 21, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19717

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:

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 May 21, 2026
@novak-vaclav
Copy link
Copy Markdown
Contributor Author

@pytorchbot label "module: nxp"

@novak-vaclav
Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: nxp"

@pytorch-bot pytorch-bot Bot 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 May 21, 2026
@novak-vaclav
Copy link
Copy Markdown
Contributor Author

Please also review @MartinPavella @roman-janik-nxp @StrycekSimon. Thank you 😄

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds aten.conv2d delegation coverage for the NXP Neutron “new flow” and expands the NXP backend test suite to validate delegation behavior and (where possible) numerical correctness.

Changes:

  • Add a new-flow support-check path in the convolution converter and tighten failure behavior when group conv decomposition is missing.
  • Add extensive new pytest coverage for conv2d delegation/non-delegation scenarios under the new Neutron flow (including depthwise and edge/bounds cases, plus targeted xfails for known issues).
  • Improve NPU-vs-CPU mismatch reporting in the output comparator by including the max diff in the assertion message.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
backends/nxp/tests/model_output_comparator.py Improves assertion failure message for output mismatches.
backends/nxp/tests/ir/converter/node_converter/test_conv_converter.py Adds a large new test suite for conv2d under the new Neutron flow, including delegation checks and known-issue xfails.
backends/nxp/backend/ir/converter/node_converters/ops_converters/convolution_converter.py Introduces new-flow target support checks and adjusts convolution argument handling / group-conv behavior.
backends/nxp/aten_passes/split_group_convolution.py Updates group-conv splitting pass to handle optional bias and propagate FakeTensor meta safely.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@novak-vaclav novak-vaclav force-pushed the feature/EIEX-861-add-conv2d-support-new-neutron-flow branch from 9cedbc4 to bc6ecdf Compare May 21, 2026 10:29
@novak-vaclav
Copy link
Copy Markdown
Contributor Author

Fixed the issues found by Copilot.

Copy link
Copy Markdown
Collaborator

@MartinPavella MartinPavella left a comment

Choose a reason for hiding this comment

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

Will review the rest of test_conv_converter tomorrow.


# The arguments of the conv are:
# [x, w, b, stride, padding, dilation, transposed, output padding, groups]
# https://github.com/pytorch/pytorch/blob/v2.6.0/aten/src/ATen/native/Convolution.cpp#L286-L291
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit:
This link only describes the arguments after x, w and b, so for example it doesn't mention that the bias is optional (as your code suggests).
Perhaps this could be a better source for this information: https://docs.pytorch.org/docs/main/user_guide/torch_compiler/torch.compiler_ir.html (mostly for future PRs)

convolution(Tensor input, Tensor weight, Tensor? bias, SymInt[] stride, SymInt[] padding, SymInt[] dilation, bool transposed, SymInt[] output_padding, SymInt groups) -> Tensor

# strideH <= 4096, strideW <= 4096
# dilationH <= 4096, dilationW <= 4096
w_node_shape = (
w_node.meta["val"].shape if hasattr(w_node, "meta") else w_node.shape
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Have you encountered a case where the weights don't have the meta attribute?
I have not seen such a case yet and I believe we rely meta being available in our codebase.

conv_utils.conv_op_factory,
)
):
raise RuntimeError("Group convolution was not decomposed.")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit:
Consider mentioning the NXP backend in the message. E.g. raise RuntimeError("NXP backend: Group convolution was not decomposed.").

nodes = list(edge_program.graph.nodes)
assert len(nodes) == 15
assert (
nodes[11].target.__name__ == "aten.convolution.default"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: Please also replace these assertions with ones that use the Convoultion alias.

assert all_close
assert (
all_close
), f"NPU output doesn't match reference. Maximum absolute difference: {max_diff}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why duplicate the message?
If you think the error message should contain the max_diff, please remove the print statement and keep only the assert message.

expected_non_delegated_ops={},
)
dataset = RandomDatasetCreator(low=-1, high=1)
comparator = AllCloseOutputComparator(atol=1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since you are using a float dataset in the range of [-1, 1), an absolute tolerance of 1 seems awfully high. Is it really intended?


except AssertionError as e:
if "NPU output doesn't match reference" in str(e):
pytest.xfail(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems dangerous.
If I understand correctly, all tests (which don't fail with NeutronConverter) will pass. Either their error is low (so it passes), or the error is high and the test is marked with xfail (so it passes).
Is that really the behavior?

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.

3 participants