Skip to content

[executorch][cuda] Optimize short-query INT6 matvec kernels - #21504

Merged
Gasoonjia merged 3 commits into
mainfrom
gh/gasoonjia/179/orig
Jul 30, 2026
Merged

[executorch][cuda] Optimize short-query INT6 matvec kernels#21504
Gasoonjia merged 3 commits into
mainfrom
gh/gasoonjia/179/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #21474 by @Gasoonjia
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/179/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/179/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/178/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/179/orig
Differential Revision: D114032330
@diff-train-skip-merge

Pull Request resolved: #21473

Add compile-time M=2/3/4 fused short-query kernels while preserving the existing M=1 path. The shared ROWS template was reviewed and benchmarked by KernelAgent; KA found no faster safe rewrite, so the validated template is retained.

A100 kernel microbenchmarks versus main:
- M1: 0.10226 -> 0.10228 ms (performance neutral; no regression)
- M2: 0.196 -> 0.127 ms (1.54x)
- M3: 0.289 -> 0.159 ms (1.82x)
- M4: 0.383 -> 0.196 ms (1.95x)

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

Differential Revision: [D114032326](https://our.internmc.facebook.com/intern/diff/D114032326/)
Pull Request resolved: #21474

Add compile-time M=1/2/3/4 short-query paths and share their safe implementation through a ROWS/USE_SUM/GS16 device template. These kernels were generated and tuned with KernelAgent. Dispatch uses the regular gs16 kernels for M=1/2 and the precomputed-activation-sum kernels for M=3/4. The M=3 non-sum entry remains explicit as a performance/correctness comparison because templating that entry increased register pressure.

A100 op-level results (N=6656, gs=16, three seeds):
- M1, generic reference -> gs16: 0.039416 -> 0.038211 ms (1.032x; no regression)
- M2, generic reference -> gs16: 0.055348 -> 0.032540 ms (1.701x)
- M3, optimized non-sum -> activation-sum: 0.040003 -> 0.039949 ms (1.001x; neutral incremental change)
- M4, generic reference -> activation-sum: 0.100204 -> 0.045694 ms (2.193x)

The M3 baseline is intentionally the optimized non-sum kernel rather than the generic reference; this isolates the activation-sum optimization. All candidates are bitwise-correct across the three seeds, and ptxas reports zero spills.
ghstack-source-id: 408539235
@exported-using-ghexport

Differential Revision: [D114032330](https://our.internmc.facebook.com/intern/diff/D114032330/)
@pytorch-bot

pytorch-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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 30, 2026
Base automatically changed from gh/gasoonjia/178/orig to main July 30, 2026 22:36
@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.

@Gasoonjia
Gasoonjia merged commit 6898c99 into main Jul 30, 2026
179 checks passed
@Gasoonjia
Gasoonjia deleted the gh/gasoonjia/179/orig branch July 30, 2026 22:47
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.

2 participants