Skip to content

Conversation

StrycekSimon
Copy link
Collaborator

@StrycekSimon StrycekSimon commented Sep 8, 2025

Summary

Adds per-channel quantization for convolution layer and introduces NodeArgsIdx class to Neutron Quantizer for better handling of indexes to quantized node's args list.

NodeArgsIdx allows selection of nested objects, e.g. an object in a list in node's args list. It also simplifies NeutronAtenQuantizer annotation process by using annotate_inputs() for inputs, weights and biases.

Test plan

The implementation should be covered by either existing or newly added unit tests.

cc @digantdesai @JakeStevens @robert-kalmar, @skywall, @roman-janik-nxp

Copy link

pytorch-bot bot commented Sep 8, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Cancelled Job

As of commit 1a3d9e5 with merge base 7e228ee (image):

NEW FAILURE - The following job has 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 Sep 8, 2025
@StrycekSimon
Copy link
Collaborator Author

Based on a conversation from this PR, I added a feature that uses the implementation. The old PR can be declined.

@StrycekSimon StrycekSimon changed the title Per-channel quantization of convolution layer NXP backend: Per-channel quantization of convolution layer Sep 8, 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 8, 2025
@robert-kalmar robert-kalmar added the module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ label Sep 10, 2025
@roman-janik-nxp roman-janik-nxp self-requested a review September 10, 2025 14:46
)
assert nodes[10].name == "aten_convolution_default"

@classmethod
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: I would move this method up to be 1st, to aling with other tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is pretty chaotic across our unittest tests. I will make it consistent.

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 ✅

"QDQDequantizeConverter",
"QDQPerTensorDequantizeConverter",
"QDQPerChannelDequantizeConverter",
"QDQQuantizeConverter",
Copy link
Contributor

Choose a reason for hiding this comment

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

only QDQDequantizer needs to be updated, not QDQQuantizeConverter too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Correct, as there are no changes to QDQQuantizeConverter. Per channel quantization scheme is used only for weights and biases, which are inputs - dequantize nodes.

list[tuple[fx.Node, NodeArgsIdx]]
| list[tuple[fx.Node, NodeArgsIdx, DerivedQuantizationSpec]]
),
spec: QuantizationSpec | None,
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, why switch from Optional to | None?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a part of move to Python 3.10 type hints and leaving imports from Typing.


# pyre-ignore[6]: incompatible parameter type
annotate_inputs(anchors.inputs, input_act_qspec)
annotate_weights_or_biases(anchors.weights, weight_qspec)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this function no longer used at all now and can be removed entirely?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it is replaced by annotate_inputs().

@robert-kalmar robert-kalmar force-pushed the upstream/main-nxp/EIEX-486+EIEX-493-upstream-per-channel-quantization-of-convolution branch from 02d89fb to 16df359 Compare September 22, 2025 07:58
@StrycekSimon StrycekSimon force-pushed the upstream/main-nxp/EIEX-486+EIEX-493-upstream-per-channel-quantization-of-convolution branch from 16df359 to 1a3d9e5 Compare September 23, 2025 07:34
@StrycekSimon
Copy link
Collaborator Author

StrycekSimon commented Sep 23, 2025

The error in Samsung's tests seems to be caused by some problem with downloading resources, and is most likely unrelated.

Update: I double-checked it and this error is also present in other PRs...

@robert-kalmar robert-kalmar merged commit 57ca96f into pytorch:main Sep 23, 2025
128 of 130 checks passed
@robert-kalmar robert-kalmar deleted the upstream/main-nxp/EIEX-486+EIEX-493-upstream-per-channel-quantization-of-convolution branch September 23, 2025 13:14
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