Skip to content

[executorch][cuda] Add a length-aware Triton SDPA over per-sequence KV columns - #24879

Open
pytorchbot wants to merge 1 commit into
mainfrom
gh/Gasoonjia/90/orig
Open

pytorchbot wants to merge 1 commit into
mainfrom
gh/Gasoonjia/90/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: #24072 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/90/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/90/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/90/orig
Differential Revision: D125987296
@diff-train-skip-merge

…V columns

Pull Request resolved: #24072

Adds `triton::sdpa_varlen`, the attention kernel the CUDA batched-sequence KV cache needs. Each resident sequence owns one column of a `[rows, cols, H, D]` store, and a device segment table `seq_info Int32[S, 4] = (q_start, q_len, col, kv_end)` says which packed query rows belong to which column and how long that sequence is. Lengths are read on device, so one captured CUDA graph serves any mix of sequence lengths, as the MLX per-sequence SDPA does per group.

Covers causal, non-causal (DFlash draft blocks), sliding window and ring storage, GQA, rows no segment covers (zeroed), and split-K for short steps. A symbolic query length takes the generic path without host-side length branches, so exporting it with a dynamic step width does not pin that width.

It is a new op in its own file; `triton::sdpa` and its dispatch are untouched.
ghstack-source-id: 469359730
@exported-using-ghexport

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

pytorch-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Pending, 8 Unrelated Failures

As of commit 020a10c with merge base 4eb094b (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 11, 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.

This branch was successfully deployed

1 active and 1 inactive deployments
upload-benchmark-results — 020a10c4 Deployed Nov 11, 2026 by pytorchbot via upload-benchmark-results #22288
cadence — 020a10c4 Deployed Nov 11, 2026 by pytorchbot via hifi-op-test / hifi4 #37749
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