Skip to content

Conversation

@jethroqti
Copy link
Contributor

Qualcomm AI Engine Direct - add pass for extra padding then maxpool2d

Summary:
The padding value used in max_pool2d operations differs between PyTorch and QNN implementations. PyTorch uses negative infinity, while QNN uses zero. To ensure consistent max_pool2d output across both frameworks, we handle this by padding tensor with constant in advance then doing max_pool2d without constant padding. Note that for the quantization flow, we set quant_min as the padding value. If, at runtime, there is a value smaller than quant_min, it could result in an accuracy drop.

Test plans:
python backends/qualcomm/tests/test_qnn_delegate.py TestQNNQuantizedOperator.test_qnn_backend_max_pool2d -b build-android -H ${HOST} -s ${SN} -m ${CHIPID}
python backends/qualcomm/tests/test_qnn_delegate.py TestQNNFloatingPointOperator.test_qnn_backend_max_pool2d -b build-android -H ${HOST} -s ${SN} -m ${CHIPID}

Summary:
The padding value used in max_pool2d operations differs between PyTorch and QNN implementations.
PyTorch uses negative infinity, while QNN uses zero. To ensure consistent max_pool2d output across both frameworks,
we handle this by padding tensor with constant in advance then doing max_pool2d without constant padding.

Test plans:
python backends/qualcomm/tests/test_qnn_delegate.py TestQNNQuantizedOperator.test_qnn_backend_max_pool2d -b build-android -H ${HOST} -s ${SN} -m ${CHIPID}
python backends/qualcomm/tests/test_qnn_delegate.py TestQNNFloatingPointOperator.test_qnn_backend_max_pool2d -b build-android -H ${HOST} -s ${SN} -m ${CHIPID}
@jethroqti jethroqti requested a review from cccclai as a code owner January 10, 2026 02:50
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 10, 2026

🔗 Helpful Links

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

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

❌ 6 New Failures, 1 Cancelled Job, 1 Unrelated Failure

As of commit b3e891d with merge base 47dc1de (image):

NEW FAILURES - The following jobs have failed:

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

UNSTABLE - The following job is marked as unstable, possibly due to flakiness 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 Jan 10, 2026
@jethroqti
Copy link
Contributor Author

@pytorchbot label "release notes: qualcomm"

@pytorch-bot pytorch-bot bot added the release notes: qualcomm Changes to the Qualcomm backend delegate label Jan 10, 2026
@jethroqti
Copy link
Contributor Author

Due to the padding value used in max_pool2d operations differs between PyTorch and QNN implementations. This pass will improve this situation. Please take a look. Thanks.
@cccclai @haowhsu-quic

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. release notes: qualcomm Changes to the Qualcomm backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants