Skip to content

Cortex-M backend: Add quantized int8 batch matmul (CMSIS-NN)#17799

Merged
rascani merged 1 commit into
pytorch:mainfrom
rascani:cortex-m-batch-mm
Mar 10, 2026
Merged

Cortex-M backend: Add quantized int8 batch matmul (CMSIS-NN)#17799
rascani merged 1 commit into
pytorch:mainfrom
rascani:cortex-m-batch-mm

Conversation

@rascani
Copy link
Copy Markdown
Contributor

@rascani rascani commented Mar 2, 2026

Summary

Add cortex_m::quantized_batch_matmul wrapping arm_batch_matmul_s8. The RHS is always pre-transposed: constant RHS (parameters) are transposed at AOT time in the pass, dynamic RHS get a cortex_m::transpose node inserted in the graph.

It would be preferable if we could pre-compute or cache the constant RHS kernel sums, but I could not find any public CMSIS-NN APIs that would allow us to do so.

Fixes #16109

Authored with Claude.

Test plan

pytest backends/cortex_m/test/ops/test_batch_matmul.py

Add cortex_m::quantized_batch_matmul wrapping arm_batch_matmul_s8.
The RHS is always pre-transposed: constant RHS (parameters) are
transposed at AOT time in the pass, dynamic RHS get a
cortex_m::transpose node inserted in the graph.

Authored with Claude.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Mar 2, 2026

🔗 Helpful Links

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

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

❌ 1 Awaiting Approval, 3 New Failures

As of commit cb40758 with merge base 25f2a3f (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 Mar 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 2, 2026

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.

@rascani
Copy link
Copy Markdown
Contributor Author

rascani commented Mar 6, 2026

Any thoughts @AdrianLundell? Not sure if you had an alternate approach to bmm in mind.

@AdrianLundell
Copy link
Copy Markdown
Collaborator

Sorry I missed this, I agree this looks reasonable!

@rascani rascani merged commit 7b5c60d into pytorch:main Mar 10, 2026
156 of 160 checks passed
jpiat pushed a commit to jpiat/executorch that referenced this pull request Mar 17, 2026
…#17799)

### Summary
Add cortex_m::quantized_batch_matmul wrapping arm_batch_matmul_s8. The
RHS is always pre-transposed: constant RHS (parameters) are transposed
at AOT time in the pass, dynamic RHS get a cortex_m::transpose node
inserted in the graph.

It would be preferable if we could pre-compute or cache the constant RHS
kernel sums, but I could not find any public CMSIS-NN APIs that would
allow us to do so.

Fixes pytorch#16109

Authored with Claude.

### Test plan
```
pytest backends/cortex_m/test/ops/test_batch_matmul.py
```
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BatchMatMul : Add CMSIS NN Op support

2 participants