Repository navigation
[WebGPU] Optimize WebGPU SparsePagedAttention softmax execution - #32613
Merged
kunal-vaishnavi merged 83 commits intoOct 3, 2026
Merged
kunal-vaishnavi merged 83 commits into
kunal-vaishnavi merged 83 commits into
Conversation
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ntion' into copilot/copilotadd-cuda-sparsepagedattention Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ntion' into copilot/copilotadd-cuda-sparsepagedattention # Conflicts: # onnxruntime/contrib_ops/cuda/bert/sparse_paged_attention.cc # onnxruntime/contrib_ops/cuda/bert/sparse_paged_attention.h # onnxruntime/contrib_ops/cuda/bert/sparse_paged_attention_impl.cu # onnxruntime/test/contrib_ops/sparse_paged_attention_op_test.cc Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ntion' into copilot/copilotadd-cuda-sparsepagedattention Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ntion' into copilot/copilotadd-cuda-sparsepagedattention Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ntion' into copilot/copilotadd-cuda-sparsepagedattention Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦sepagedattention Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ntion' into copilot/copilotadd-cuda-sparsepagedattention Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦gedattention' into copilot/copilotcopilotadd-cuda-sparsepagedattention-s2-non Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦gedattention' into copilot/copilotcopilotadd-cuda-sparsepagedattention-s2-non Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Sayan Shaw (sayanshaw24)
previously approved these changes
Oct 2, 2026
Base automatically changed from
copilot/copilotadd-cuda-sparsepagedattention
to
main
October 3, 2026 01:02
β¦tadd-cuda-sparsepagedattention-s2-non # Conflicts: # docs/ContribOperators.md # docs/OperatorKernels.md # docs/contrib_ops/webgpu/sparse_paged_attention.md # onnxruntime/contrib_ops/cuda/bert/sparse_paged_attention.cc # onnxruntime/contrib_ops/cuda/bert/sparse_paged_attention_impl.cu # onnxruntime/contrib_ops/webgpu/bert/paged_attention.cc # onnxruntime/contrib_ops/webgpu/bert/sparse_paged_attention.cc # onnxruntime/contrib_ops/webgpu/bert/sparse_paged_attention.h # onnxruntime/contrib_ops/webgpu/bert/sparse_paged_attention_auxiliary.wgsl.template # onnxruntime/contrib_ops/webgpu/bert/sparse_paged_attention_finalize.wgsl.template # onnxruntime/contrib_ops/webgpu/bert/sparse_paged_attention_main.wgsl.template # onnxruntime/contrib_ops/webgpu/bert/sparse_paged_attention_token_meta.wgsl.template # onnxruntime/contrib_ops/webgpu/webgpu_contrib_kernels.cc # onnxruntime/core/graph/contrib_ops/ms_opset.h # onnxruntime/test/contrib_ops/sparse_paged_attention_op_test.cc Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Akshay Sonawane (apsonawane)
approved these changes
Oct 3, 2026
kunal-vaishnavi
deleted the
copilot/copilotcopilotadd-cuda-sparsepagedattention-s2-non
branch
October 3, 2026 18:58
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
Optimize the WebGPU
SparsePagedAttentionexecution pipeline:(token, head)and share merge coefficients across output dimensionsThis follows #32533, which is now merged into
main.Motivation and Context
The original WebGPU implementation always materialized FP32 partial softmax state and launched a separate finalize pass. It also repeated per-head scalar calculations across output lanes. These changes reduce scratch-buffer traffic and dispatch overhead for the common single-source path while reducing redundant work in staged configurations without changing attention semantics.
Validation:
clang-format --dry-run --Werroron the changed C++ filesgit diff --check