[webgpu] Fused SplitPackedQKV with FusedQKRotaryEmbedding - #26447
Merged
Xiaofei Han (xiaofeihan1) merged 5 commits intoNov 11, 2025
Merged
Conversation
Jiajia Qin (qjia7)
previously approved these changes
Nov 7, 2025
Jiajia Qin (qjia7)
requested review from
Yulong Wang (fs-eire) and
Guenther Schmuelling (guschmue)
November 7, 2025 09:53
Jiajia Qin (qjia7)
approved these changes
Nov 10, 2025
Guenther Schmuelling (guschmue)
approved these changes
Nov 10, 2025
Xiaofei Han (xiaofeihan1)
merged commit Nov 11, 2025
cf8476b
into
microsoft:main
91 of 92 checks passed
Rohanjames1997
pushed a commit
to Rohanjames1997/onnxruntime
that referenced
this pull request
Dec 4, 2025
…26447) ### Description <!-- Describe your changes. --> When `is_packed_qkv_` and `do_rotary_`, call a new `SplitPackedQKVWithRotaryEmbedding` which fused SplitPackedQKV with FusedQKRotaryEmbedding. Dispatch size is B*S*N*work_per_head. (work_per_head is `head_size - half_rotary_embedding_dim`, is equal `half_rotary_embedding_dim + need_copy_dim`) - For `half_rotary_embedding_dim`, we split packedQKV and then do rotary for pairs q/k and directly store v. - For `need_copy_dim`, we split packedQKV and then directly store q/k/v ### Motivation and Context On NV5080, the token generation speed improve ~3%. | generation tps | Before | After | |--------|--------|-------| | NV5080 | 129 | **133** | | Intel | 15.4 | 15.5 | | Mac | 69.0 | 71.0 |
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
When
is_packed_qkv_anddo_rotary_, call a newSplitPackedQKVWithRotaryEmbeddingwhich fused SplitPackedQKV with FusedQKRotaryEmbedding.Dispatch size is BSN*work_per_head. (work_per_head is
head_size - half_rotary_embedding_dim, is equalhalf_rotary_embedding_dim + need_copy_dim)half_rotary_embedding_dim, we split packedQKV and then do rotary for pairs q/k and directly store v.need_copy_dim, we split packedQKV and then directly store q/k/vMotivation and Context
On NV5080, the token generation speed improve ~3%.