Skip to content

[webgpu] Fused SplitPackedQKV with FusedQKRotaryEmbedding - #26447

Merged
Xiaofei Han (xiaofeihan1) merged 5 commits into
microsoft:mainfrom
xiaofeihan1:xiaofeihan/fused_splitQKV
Nov 11, 2025
Merged

[webgpu] Fused SplitPackedQKV with FusedQKRotaryEmbedding#26447
Xiaofei Han (xiaofeihan1) merged 5 commits into
microsoft:mainfrom
xiaofeihan1:xiaofeihan/fused_splitQKV

Conversation

@xiaofeihan1

Copy link
Copy Markdown
Contributor

Description

When is_packed_qkv_ and do_rotary_, call a new SplitPackedQKVWithRotaryEmbedding which fused SplitPackedQKV with FusedQKRotaryEmbedding.

Dispatch size is BSN*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

@xiaofeihan1
Xiaofei Han (xiaofeihan1) merged commit cf8476b into microsoft:main Nov 11, 2025
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  |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ep:WebGPU ort-web webgpu provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants