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.

✅ No Failures

As of commit f3c142d with merge base 47dc1de (image):
💚 Looks good so far! There are no failures yet. 💚

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

@cccclai
Copy link
Contributor

cccclai commented Jan 14, 2026

Hey can you address the lintrunner error?

@meta-codesync
Copy link
Contributor

meta-codesync bot commented Jan 14, 2026

@cccclai has imported this pull request. If you are a Meta employee, you can view this in D90710816.

@jethroqti
Copy link
Contributor Author

Hey can you address the lintrunner error?

Sure.

@jethroqti
Copy link
Contributor Author

@pytorchbot label "release notes: qualcomm"

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