Skip to content

[executorch][cuda] Optimize short-query INT5 matvec kernels - #21475

Open
Gasoonjia wants to merge 2 commits into
gh/gasoonjia/180/basefrom
gh/gasoonjia/180/head
Open

[executorch][cuda] Optimize short-query INT5 matvec kernels#21475
Gasoonjia wants to merge 2 commits into
gh/gasoonjia/180/basefrom
gh/gasoonjia/180/head

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Add specialized M=1 and M=4 short-query paths for the planar INT5 W5A8 matvec operator. These are the latency-sensitive single-row and four-row shapes. M=2/M=3 retain the generic fallback path; this change does not claim those shapes as optimized.

The M=1 implementation shares safe gs32 decode/accumulate logic through a compile-time ROWS device template. M=4 remains explicit because KernelAgent experiments with the generalized template increased register pressure and regressed latency. The final kernels were generated and tuned with KernelAgent.

A100 kernel microbenchmarks versus the previous generic path:

  • M1: 1.09971 -> 0.70441 ms (1.56x; no regression)
  • M4: 1.96445 -> 1.12976 ms (1.74x)
  • M2/M3: no specialized dispatch; generic fallback remains unchanged

Correctness tests cover M=1,2,3,4 with three randomized seeds; ptxas reports zero spills.

Differential Revision: D114032323

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 Jul 29, 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.

[ghstack-poisoned]
Gasoonjia added a commit that referenced this pull request Jul 30, 2026
Pull Request resolved: #21475

Add specialized M=1 and M=4 short-query paths for the planar INT5 W5A8 matvec operator. These are the latency-sensitive single-row and four-row shapes. M=2/M=3 retain the generic fallback path; this change does not claim those shapes as optimized.

The M=1 implementation shares safe gs32 decode/accumulate logic through a compile-time ROWS device template. M=4 remains explicit because KernelAgent experiments with the generalized template increased register pressure and regressed latency. The final kernels were generated and tuned with KernelAgent.

A100 kernel microbenchmarks versus the previous generic path:
- M1: 1.09971 -> 0.70441 ms (1.56x; no regression)
- M4: 1.96445 -> 1.12976 ms (1.74x)
- M2/M3: no specialized dispatch; generic fallback remains unchanged

Correctness tests cover M=1,2,3,4 with three randomized seeds; ptxas reports zero spills.
ghstack-source-id: 408520032
@exported-using-ghexport

Differential Revision: [D114032323](https://our.internmc.facebook.com/intern/diff/D114032323/)

@digantdesai digantdesai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

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.

2 participants