Skip to content

Conversation

StrycekSimon
Copy link
Collaborator

@StrycekSimon StrycekSimon commented Sep 10, 2025

Summary

Updates example in aot_neutron_compile.py to reflect current state of NXP backend.

Test plan

AOT examples should run automatically in CI. You can manually test it using backends/nxp/run_aot_example.sh

cc @digantdesai @JakeStevens @robert-kalmar @MartinPavella @roman-janik-nxp

Copy link

pytorch-bot bot commented Sep 10, 2025

🔗 Helpful Links

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

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures

As of commit 815a3f7 with merge base fd9f176 (image):

NEW FAILURES - The following jobs have failed:

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 Sep 10, 2025
@StrycekSimon
Copy link
Collaborator Author

@pytorchbot label "release notes: nxp"

@pytorch-bot pytorch-bot bot added the release notes: nxp Changes to the NXP Neutron backend delegate label Sep 10, 2025

edge_program_manager = NeutronEdgePassManager()(edge_program_manager)

if args.remove_quant_io_ops:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This step is done before delegation, but in executorch_pipeline.py it is done after delegation. In our local repo it is placed before delegation. Why are there differences?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it should be placed before the delegation. @MartinPavella, can you confirm it since you are the author of the updated executorch_pipeline.py?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In executorch_pipeline, the removal of I/O quantization after partitioning was up-streamed by you, with @skywall as the original author (cf2f170).
I did not add the IO removal, so I'm not sure which order is preferred. Perhaps Lukas can comment. (But I am leaning towards keeping it consistent with main-nxp.)

Copy link
Collaborator Author

@StrycekSimon StrycekSimon Sep 15, 2025

Choose a reason for hiding this comment

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

I agree, I will change it.

Edit: Done ✅

@robert-kalmar robert-kalmar added the module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ label Sep 12, 2025
if args.delegate:
logging.info("Executing Neutron Partitioner and Delegate")
edge_program_manager = edge_program_manager.to_backend(
NeutronPartitioner(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please unify edge_program_manager.to_backend(), compile_spec and partitioner creation with version in executorch_pipeline.py`.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done ✅

@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch from 6d033df to ddf400c Compare September 15, 2025 09:20

if remove_quant_io_ops:
edge_program_manager = edge_program_manager.transform(
[RemoveIOQuantOpsPass(edge_program_manager=edge_program_manager)]
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to this PR but why is this not part of the NeutronEdgePassManager?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I probably did put the RemoveIOQuantOpsPass call on a wrong place. I will double check it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The RemoveIOQuantOps is intentionally not part of the NeutronPassManager default passes, as this changes the model API:
Normally when the quantization is performed and consequently the delegation to Neutron backend the model input and output type is untouched - e.g. FP32. There is a Quantize node doing the input quantization for the rest of the (optionally) Neutron compute.
This pass removes the Quantize and Dequantize nodes from the I/O tensors, and changes the datatype to int8 .

It can be applied by the NeutronPassManager, but with user choice option. Not by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I said, we can add an optional arg to the PassManager for this pass. It feels like someone has to go out of their way to do this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved the application to the PassManager itself. Now it is an opt-in boolean.

if args.remove_quant_io_ops:
edge_program = edge_program.transform(
[RemoveIOQuantOpsPass(edge_program_manager=edge_program)]
edge_program_manager = edge_program_manager.transform(
Copy link
Contributor

Choose a reason for hiding this comment

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

as I said before can we move the pass inside the passmanager and add a remove_quant_io as an arg to it?

@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch 2 times, most recently from a038916 to 90c851c Compare September 22, 2025 15:08
@StrycekSimon
Copy link
Collaborator Author

I refactored the aot_neutron_compile.py file to use to_edge_transform_and_lower for simpicity of the example. The executorch_pipeline.py still requires converting to edge and than to backend separately for testing purposes.

@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch from c4f2d68 to e3cdc16 Compare September 23, 2025 17:08
@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch from e3cdc16 to bd17839 Compare September 23, 2025 17:14
@StrycekSimon
Copy link
Collaborator Author

StrycekSimon commented Sep 23, 2025

Sorry everyone for the tag, I somehow managed to mess up a rebase.

@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch from bd17839 to bdf54da Compare September 23, 2025 17:59
@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch from bdf54da to 815a3f7 Compare September 23, 2025 18:31
@StrycekSimon
Copy link
Collaborator Author

The fail with Samsung's tests is unrelated and appears in other PRs. The second red signal is some problem in the runner setup, and I don't see any relation to changes made in this PR.

@robert-kalmar
Copy link
Collaborator

@roman-janik-nxp please re-review if you agree with the implementation of the requested change.

@roman-janik-nxp roman-janik-nxp merged commit 25b3d63 into pytorch:main Sep 25, 2025
128 of 130 checks passed
@roman-janik-nxp roman-janik-nxp deleted the upstream/main-nxp/EIEX-533-upstream-addition-of-to_edge_with_preserved_ops-nxpedgepassmanage-to-aot_neutron_compile.py branch September 25, 2025 09:18
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.

5 participants