Repository navigation
Enable non-causal WebGPU PagedAttention for full-context blocks - #32763
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The causal flag is discarded before shader specialization, and malformed attribute values are not rejected.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Enables non-causal WebGPU PagedAttention for full-context blocks and expands parity coverage.
Changes:
- Stores and propagates
is_causal. - Generalizes reference masking.
- Adds non-causal WebGPU tests.
| File | Review |
|---|---|
onnxruntime/​test/​python/​transformers/​test_paged_attention.py |
Adds non-causal parity and invalid local-window coverage. |
onnxruntime/​test/​contrib_ops/​paged_attention_op_test.cc |
Generalizes reference masking and adds focused WebGPU tests. |
onnxruntime/​contrib_ops/​webgpu/​bert/​paged_attention.h |
Stores causal-mode state. |
onnxruntime/​contrib_ops/​webgpu/​bert/​paged_attention.cc |
Critical: parameter conversion still forces causal masking, so non-causal execution remains broken. Moderate: is_causal must reject values other than 0 or 1. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…oft/onnxruntime into aciddelgado/qwen38_webgpu
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Invalid is_causal values can silently produce incorrect non-causal behavior.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (1)
Added enforcement for is_causal attribute values and updated its assignment. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Baiju Meswani (baijumeswani)
approved these changes
Sep 24, 2026
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
Enable  com.microsoft::PagedAttention on the WebGPU EP with  is_causal=0 when  local_window_size <= 0 .
This is needed by block-drafting models such as DFlash2, where all query tokens submitted in one speculative block must attend bidirectionally to the complete live context. Previously, the WebGPU kernel rejected every non-causal configuration and then hard-coded causal behavior when constructing  WebgpuAttentionParameters .
Changes
No WGSL redesign is required: the dense and paged FlashAttention shaders already support causal and non-causal specializations. This change only restores the missing host-side attribute plumbing.
Masking behavior
Validation