-
Notifications
You must be signed in to change notification settings - Fork 4k
[WebGPU EP] Fuse QMoE 1-token decode path to reduce GPU dispatches #27998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dea1448
[WebGPU EP] Fuse QMoE 1-token decode path to reduce GPU dispatches
qjia7 54defba
fix incorrect results
qjia7 5978b03
[WebGPU EP] Add per-row weight indirect support to DP4A SmallM and fi…
qjia7 ac84f9a
Merge branch 'main' into opt/webgpu-qmoe-fused-1token
qjia7 d70f790
Remove ReplicateHidden: broadcast A row 0 via override_M
qjia7 f90d9f1
Remove per_row_weight_indirect: simplify to has_weight_idx_indirect
qjia7 3ae0e4c
Use num_tokens variable in Gate1Token dispatch for clarity
qjia7 4a953a7
Use M consistently for tile optimization checks instead of dispatch_M
qjia7 52d2159
Merge branch 'main' into opt/webgpu-qmoe-fused-1token
qjia7 c630eef
Address PR review: separate dispatch_M uniform, skip zero-init for 1-…
qjia7 96be6b5
Merge branch 'opt/webgpu-qmoe-fused-1token' of https://github.com/Mic…
qjia7 9d75e32
Add WebGPU QMoE tests: EP block in RunQMoETest + 1-token path test
qjia7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
onnxruntime/contrib_ops/webgpu/moe/final_mix_1token.wgsl.template
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
onnxruntime/contrib_ops/webgpu/moe/fused_final_mix_1token.wgsl.template
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| // Fused FinalMix for 1-token MoE: processes all k experts in one dispatch. | ||
| // Each workgroup handles one of the k expert results. | ||
| // in: fc2_outputs [k, hidden_size] — concatenated fc2 results for all k experts | ||
| // in: router_values [1, num_experts] — softmax weights per expert | ||
| // in: indirect_experts [k] — which expert index each row corresponds to | ||
| // out: output [1, hidden_size] — accumulated weighted output | ||
| // uniform: hidden_size, k | ||
|
|
||
| $MAIN { | ||
| let out_idx = workgroup_idx * workgroup_size_x + local_idx; | ||
| if (out_idx >= uniforms.hidden_size) { | ||
| return; | ||
| } | ||
| var acc = output_element_t(0); | ||
| for (var i = 0u; i < uniforms.k; i++) { | ||
| let expert_idx = indirect_experts[i]; | ||
| let router_value = router_values[expert_idx]; | ||
| acc += router_value * fc2_outputs[i * uniforms.hidden_size + out_idx]; | ||
| } | ||
| output[out_idx] = acc; | ||
| } // MAIN | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.