Skip to content

Reorder channelwise gated delta rule chunked hot loops for autovectorization (#21021)#21021

Open
JakeStevens wants to merge 3 commits into
pytorch:mainfrom
JakeStevens:export-D112598714
Open

Reorder channelwise gated delta rule chunked hot loops for autovectorization (#21021)#21021
JakeStevens wants to merge 3 commits into
pytorch:mainfrom
JakeStevens:export-D112598714

Conversation

@JakeStevens

@JakeStevens JakeStevens commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary:

Reorder the chunked prefill inner loops (steps 1, 4, 5, 6) so the innermost loop runs contiguously over the head dimension (k or v) instead of striding down a column of the state / pv. This lets the compiler autovectorize the now-unit-stride AXPYs; hand-written at::vec was tried and was slower than the compiler output, so the loops stay scalar.

Differential Revision: D112598714

@pytorch-bot

pytorch-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 2 Active SEVs

There are 2 currently active SEVs. If your PR is affected, please view them below:

❌ 129 New Failures, 6 Unclassified Failures

As of commit b8d62b5 with merge base 931ba24 (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 Jul 17, 2026
@meta-codesync

meta-codesync Bot commented Jul 17, 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 D112598714.

@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.

…h#21020)

Summary:

Reduce the channelwise gated delta rule kernel from four state traversals to two per token. The first pass computes the predicted value while folding in decay; the second applies decay and the rank-one update while accumulating the output. This preserves operation grouping and numerical behavior while reducing state-memory traffic. Add a standalone microbenchmark covering decode and representative prefill lengths.

Differential Revision: D112596724
Summary:
Route the channelwise gated delta rule by sequence length: T == 1 keeps the two-pass token recurrence for autoregressive decode, while T != 1 uses a chunkwise WY/UT formulation for prefill.

The chunked path computes per-channel log-decay prefixes, causal query/key terms, the beta-folded triangular transform, WY pseudo-keys and pseudo-values, and inter-chunk state carry. It handles a ragged final chunk without a separate tail implementation.

Parallelize independent (batch, head) work across the ExecuTorch threadpool. Each worker receives a disjoint slice of one temporary scratch arena, avoiding shared mutable buffers while amortizing allocation across chunks.

Differential Revision: D112597348
…ization (pytorch#21021)

Summary:

Reorder the chunked prefill inner loops (steps 1, 4, 5, 6) so the innermost loop runs contiguously over the head dimension (k or v) instead of striding down a column of the state / pv. This lets the compiler autovectorize the now-unit-stride AXPYs; hand-written at::vec was tried and was slower than the compiler output, so the loops stay scalar.

Differential Revision: D112598714
@meta-codesync meta-codesync Bot changed the title Reorder channelwise gated delta rule chunked hot loops for autovectorization Reorder channelwise gated delta rule chunked hot loops for autovectorization (#21021) Jul 17, 2026
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