[WebGPU] LinearAttention: increase tile_v when subgroups are available - #28519
Merged
Guenther Schmuelling (guschmue) merged 6 commits intoMay 22, 2026
Merged
Conversation
Jianhui Dai (daijh)
marked this pull request as draft
May 15, 2026 03:44
- Scale tile_v by 4x when subgroup is enabled and the vectorized dimension has enough columns, improving data reuse. - Remove redundant zero-initialization of the state tile (WGSL default- initializes private vars to zero).
Jianhui Dai (daijh)
force-pushed
the
linear-attn-dev
branch
from
May 19, 2026 08:39
58a09c7 to
4cb94d5
Compare
Jianhui Dai (daijh)
marked this pull request as ready for review
May 19, 2026 08:40
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the WebGPU LinearAttention kernel by increasing the V-dimension tiling when subgroup reductions are available (to improve data reuse), gating that expansion to longer sequences, and removing redundant per-invocation state zeroing in the WGSL shader.
Changes:
- Adjust
tile_vselection logic and expand it (up to 4×) when subgroups are enabled andseq_length >= 16. - Move
subgroup_min_sizedetermination earlier and pass it into the shader program configuration. - Remove explicit zero-initialization of the per-thread
statetile in the WGSL template.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
onnxruntime/contrib_ops/webgpu/bert/linear_attention.cc |
Adjusts tile selection/expansion heuristics and subgroup configuration passed into the shader. |
onnxruntime/contrib_ops/webgpu/bert/linear_attention.wgsl.template |
Removes explicit state zero-initialization (relies on WGSL default initialization). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Jiajia Qin (@qjia7) Thanks. Fixed the comment, please take another look. |
Guenther Schmuelling (guschmue)
approved these changes
May 22, 2026
Guenther Schmuelling (guschmue)
merged commit May 22, 2026
1053327
into
microsoft:main
92 of 93 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Intel Panther Lake (xe-3lpg)
Motivation and Context
See above.