Skip to content

Lower static FP32 matmul to existing matrix kernels - #24454

Open
JakeStevens wants to merge 1 commit into
pytorch:mainfrom
JakeStevens:export-D129095332
Open

JakeStevens wants to merge 1 commit into
pytorch:mainfrom
JakeStevens:export-D129095332

Conversation

@JakeStevens

Copy link
Copy Markdown
Contributor

Summary:

Ulterior Motive

Unblock matrix multiplication in native Swin and Swin V2 execution.

Rationale

What: Lower supported static FP32 matmul operations to existing mm and bmm kernels.

Why: The CPU execution plan has kernels for those operations but cannot select a kernel for the generic matmul nodes in these graphs.

Details

  • Rewrite rank-two matrices and matched rank-three batches directly to mm or bmm.
  • For higher-rank or broadcasted batches, copy the expanded operands, flatten batch dimensions, run bmm, and restore the original output shape and value ID.
  • Validate operand types, contraction, broadcasting and output metadata; reject vector and empty-matrix cases explicitly.
  • Allocate the executable's buffer slots after lowering has added intermediate values.
  • Leave alias functionalization and its view-to-copy mappings unchanged.

Authored with AI using Metamate on agentcloud.

Differential Revision: D129095332

Summary:
## Ulterior Motive

Unblock matrix multiplication in native Swin and Swin V2 execution.

## Rationale

**What**: Lower supported static FP32 `matmul` operations to existing `mm` and `bmm` kernels.

**Why**: The CPU execution plan has kernels for those operations but cannot select a kernel for the generic `matmul` nodes in these graphs.

## Details

- Rewrite rank-two matrices and matched rank-three batches directly to `mm` or `bmm`.
- For higher-rank or broadcasted batches, copy the expanded operands, flatten batch dimensions, run `bmm`, and restore the original output shape and value ID.
- Validate operand types, contraction, broadcasting and output metadata; reject vector and empty-matrix cases explicitly.
- Allocate the executable's buffer slots after lowering has added intermediate values.
- Leave alias functionalization and its view-to-copy mappings unchanged.

Authored with AI using Metamate on agentcloud.

Differential Revision: D129095332
@pytorch-bot

pytorch-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 New Failures, 2 Unclassified Failures

As of commit 975a85b with merge base 822cb60 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

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 Nov 2, 2026
@meta-codesync

meta-codesync Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@JakeStevens has exported this pull request. If you are a Meta employee, you can view the originating Diff in D129095332.

@github-actions

github-actions Bot commented Nov 2, 2026

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.

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant