Optimize CUDA DynamicSparseAttention for large-context inference - #32671
Draft
kunal-vaishnavi with Copilot wants to merge 8 commits into
Draft
kunal-vaishnavi with Copilot wants to merge 8 commits into
kunal-vaishnavi with Copilot wants to merge 8 commits into
Conversation
Copilot created this pull request from a session on behalf of
kunal-vaishnavi
September 17, 2026 09:47
View session
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
kunal-vaishnavi
changed the base branch from
main
to
copilot/copilotadd-cuda-dynamicsparseattention
September 17, 2026 09:48
kunal-vaishnavi
added this pull request to stack #32531
September 17, 2026 09:48
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>
kunal-vaishnavi
force-pushed
the
copilot/optimize-dynamic-sparse-attention
branch
from
September 17, 2026 09:57
f9bc5f9 to
e9c1dd6
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The newly introduced CUDA graph capture path lacks regression coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Optimizes CUDA DynamicSparseAttention for large-context inference.
Changes:
- Adds tiled split attention with stable online softmax reduction.
- Introduces bitmap validation and asynchronous cache initialization.
- Expands CUDA coverage for large, ragged, FP16, and prefill cases.
File summaries
| File | Description |
|---|---|
dynamic_sparse_attention.cc |
Allocates workspaces and supports capture-time execution. |
dynamic_sparse_attention_impl.h |
Extends CUDA implementation interfaces. |
dynamic_sparse_attention_impl.cu |
Implements tiled kernels, reductions, validation, and cache copies. |
dynamic_sparse_attention_op_test.cc |
Adds large-context and split-path tests. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ORT_RETURN_IF_ERROR(ValidateDynamicSparseAttentionOnDevice( | ||
| stream, data.selected_indices, data.selected_counts, data.seqlens_k, | ||
| data.position_ids, parameters, validation_error.get(), true)); | ||
| if (capture_status == cudaStreamCaptureStatusNone) { |
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
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
Motivation and Context
CUDA
DynamicSparseAttentionserialized work across selected tokens, causing decode latency to scale poorly with retained context. The optimized paths increase GPU occupancy, eliminate per-candidate block synchronization and large-context fallback cliffs, and bound temporary memory for production-scale workloads.