Skip to content

Qualcomm AI Engine Direct - Exact integer floor_divide and remainder - #24057

Open
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/qnn-exact-int-floor-divide
Open

msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/qnn-exact-int-floor-divide

Conversation

@msluszniak

@msluszniak msluszniak commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Integer // and % went through float div + floor, which is inexact on the HTP (23999 // 80 gives 300 in fp16; the floor_divide test had a "rounding issue" TODO). Integer remainder now lowers to QNN ElementWiseMod and integer floor division to int32 (x - x mod y) / y, for both floor_divide and div(rounding_mode="floor"). DecomposeFloorDivide is removed (supersedes #24034); float paths are unchanged.

Test plan

New int cases in test_qnn_backend_floor_divide / test_qnn_backend_remainder (including the re-enabled TODO case and a Python-scalar divisor) fail on main in fp16 and pass here (x86 simulator). test_passes.py and rework/passes/test.py give the same results as main; the full TestQNNFloatingPointOperator / TestQNNQuantizedOperator suites pass.

cc @cccclai @winskuo-quic @shewu-quic @haowhsu-quic @DannyYuyang-quic @cbilgin @abhinaykukkadapu @psiddh @nil-is-all

Integer // and % were decomposed into float div + floor, which is inexact on the
HTP (23999 // 80 gave 300 in fp16; the floor_divide test had a "rounding issue"
TODO). Integer remainder now lowers to QNN ElementWiseMod (the result takes the
divisor's sign, like torch), and integer floor division to int32
(x - x mod y) / y, for both floor_divide and div(rounding_mode="floor").
DecomposeFloorDivide is removed; float paths are unchanged.
@msluszniak
msluszniak requested a review from psiddh as a code owner October 21, 2026 11:48
@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 Awaiting Approval, 4 New Failures

As of commit 12ba70b with merge base e6cfbf8 (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

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 Oct 21, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Oct 21, 2026
@nil-is-all nil-is-all added partner: qualcomm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Qualcomm module: qnn Issues related to Qualcomm's QNN delegate and code under backends/qualcomm/ labels Oct 21, 2026
borys3kk pushed a commit to borys3kk/swm_executorch that referenced this pull request Oct 22, 2026
Integer // and % were decomposed into float div + floor, which is inexact on the
HTP (23999 // 80 gave 300 in fp16). Integer remainder now lowers to QNN
ElementWiseMod (the result takes the divisor's sign, like torch), and integer floor
division to int32 (x - x mod y) / y, for both floor_divide and
div(rounding_mode="floor"). DecomposeFloorDivide is removed; float paths are unchanged.

Backport of pytorch/executorch#24057 (replaces the #24034
backport's DecomposeFloorDivide change; its scalar test stays). 1.4.1 has no rework pass tests.

This branch has not been deployed

No deployments
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. community: contribution PRs coming from community (excluding hardware partners) module: qnn Issues related to Qualcomm's QNN delegate and code under backends/qualcomm/ partner: qualcomm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Qualcomm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants