Skip to content

Conversation

roman-janik-nxp
Copy link
Collaborator

@roman-janik-nxp roman-janik-nxp commented Oct 6, 2025

Summary

This PR replaces optimizations 'fuse_activation_functions.py' by quantization of Conv 2D and Linear ops together with fusable activations - selected activations supported by Neutron (Relu, Relu6, Sigmoid, Tanh). Logic is determined by target specs, now supporting Neutron-C. Tests updated. Relu has now non-shared, standalone quantization.

Test plan

Unit tests provided (test_edge_passes.py, test_quantizer.py).

cc @robert-kalmar @JakeStevens @digantdesai

Copy link

pytorch-bot bot commented Oct 6, 2025

🔗 Helpful Links

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

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

❌ 3 New Failures, 1 Cancelled Job

As of commit 6fdef26 with merge base f81e834 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOB - The following job was cancelled. Please retry:

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 Oct 6, 2025
@roman-janik-nxp
Copy link
Collaborator Author

@pytorchbot label "module: nxp" "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 Oct 6, 2025


class HardTanhInPlacePattern(QuantizationPattern):
class HardTanhInPlacePattern(SingleInputBasicPattern):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't you forget to remove the get_anchors() method?

"quantized_decomposed.quantize_per_tensor.default",
"quantize_per_channel.default",
"quantized_decomposed.quantize_per_channel.default",
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not compare the targets directly? It would be more reliable.


class NeutronTargetNeutronC:
@staticmethod
def is_supported_fused_activation(node_: Node) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps the suffix _aten should be added to the name. Same for is_fusable_conv_or_linear().
It is not clear that the function is meant for the aten dialect.

exir_ops.edge.aten.hardtanh.default,
exir_ops.edge.aten.relu.default,
exir_ops.edge.aten.sigmoid.default,
exir_ops.edge.aten.tanh.default,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this necessary?
I would expect that since the Move*AuxiliaryOperatorIntoSeparateQDQClusterPass now supports these operators, they should be the main nodes within their own QDQ clusters.

activation_quantizer = self.neutron_quantizer.op_to_quantizer[
activation.target
]
activation_quantizer.annotate(gm)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor:
The code only makes sense if the activation_quantizer only quantizes the output, and not the input. Perhaps a comment explaining that would be useful here. Same for the 3 patterns below.

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