You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Handles batched inputs, long sequences, and strided channel processing.
Validation and coverage
Rejects non-positive attention-head counts during graph resolution and execution.
Adds reference-based coverage for QSA, CSA, cache-only steps, batch strides, and multi-tile scans.
Documentation
Documents policy semantics, tensor contracts, cache behavior, and kernel pipelines.
Motivation and Context
Recent sparse-attention decoders require either token-level QSA indexing or stateful CSA compressed-block indexing. This operator provides both policies through one validated CUDA interface while preserving the cache state required by subsequent decoding steps.
token_budget and index_topk also remain unchecked int64 values even though capacity/top-k fields are later narrowed to int. For example, index_topk = 2^32 passes validation but becomes zero, producing an output shape and selection behavior that disagree with the schema-inferred capacity. Add representability checks before accepting these attributes and mirror them in shape inference.
The shared-cache tests check capacity, but never alias past_key and present_key. They supply past_key as a graph input and leave the output unbound; graph inputs are not reused by the allocation planner (allocation_planner.cc:643β659). Consequently, neither policy tests the copy-skipping branch or updates to the caller's cache. Add CUDA-backed QSA and CSA tests that bind both cache tensors to the same device buffer, assert pointer equality, and compare successive decoding steps with the reference, including preservation of untouched cache rows.
Test candidate selection beyond 128 entries and tie ordering
The largest QSA numeric case has only 100 complete visible blocks, and CSA cases have at most four entries. With 128 selection threads, none reaches a second iteration of ScanForNext, so later-candidate selection and tie ordering are untested for both policies. Add reference-based cases with more than 128 visible candidates: make entries beyond index 127 win, and use equal scores with enough selected entries to cross that boundary. The suggested fixtures exercise both scenarios while retaining QSA's strided-channel coverage.
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
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
Adds
com.microsoft.SparseAttentionIndexerwith CUDA implementations for QSA token selection and CSA compressed-block selection.Motivation and Context
Recent sparse-attention decoders require either token-level QSA indexing or stateful CSA compressed-block indexing. This operator provides both policies through one validated CUDA interface while preserving the cache state required by subsequent decoding steps.