Repository navigation
[CUDA][WebGPU] Add packed sparse attention indexer for continuous batching - #32618
kunal-vaishnavi merged 103 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>
β¦on-indexer' into copilot/implement-sparse-attention-indexer-again 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>
β¦on-indexer' into copilot/implement-sparse-attention-indexer-again # Conflicts: # onnxruntime/test/contrib_ops/sparse_attention_indexer_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>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦_infer.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
β¦on-indexer' into copilot/implement-sparse-attention-indexer-again # Conflicts: # docs/contrib_ops/cuda/sparse_attention_indexer.md # onnxruntime/test/contrib_ops/sparse_attention_indexer_op_test.cc # onnxruntime/test/python/onnxruntime_test_python_symbolic_shape_infer.py 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>
β¦on-indexer' into copilot/implement-sparse-attention-indexer-again 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>
β¦_infer.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@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>
β¦on-indexer' into copilot/implement-sparse-attention-indexer-again # Conflicts: # docs/contrib_ops/cuda/sparse_attention_indexer.md # onnxruntime/test/contrib_ops/sparse_attention_indexer_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>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦rse-attention-indexer # Conflicts: # onnxruntime/test/python/transformers/test_paged_attention_int4.py Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦on-indexer' into copilot/implement-sparse-attention-indexer-again # Conflicts: # onnxruntime/contrib_ops/webgpu/webgpu_contrib_kernels.cc # onnxruntime/test/python/transformers/test_paged_attention_int4.py Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
β¦ent-packed-sparse-attention-indexer # Conflicts: # onnxruntime/contrib_ops/webgpu/webgpu_contrib_kernels.cc Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
|
I found four issues at the current head:
|
β¦ent-packed-sparse-attention-indexer 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>
|
Thanks for adding an explicit storage-binding limit check. It improves the error, but does not make the WebGPU kernel usable on adapters exposing the spec-guaranteed limit of eight bindings: QSA update needs nine, and CSA update/selection need ten. Because the node is already assigned to WebGPU, returning |
β¦ent-packed-sparse-attention-indexer Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Addressed all four findings and synced with current
Fixed by reducing the dispatches rather than relying only on runtime rejection. Related tensors are now packed so QSA update/selection and CSA update/selection each require no more than eight logical storage buffers. CSA selection recomputes rejection from packed immutable metadata, eliminating its separate overflow binding. Added QSA and CSA WebGPU numerical tests with |
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com>
Description
Adds
com.microsoft.PackedSparseAttentionIndexerversion 1 for packed, variable-length continuous batching, with CUDA and WebGPU implementations.The operator supports both QSA and CSA policies over flattened token inputs and per-request metadata while preserving fixed-capacity state across prefill and decode calls. It is designed to produce selection metadata compatible with
SparsePagedAttentionwithout changing the existing denseSparseAttentionIndexerABI or behavior.Key changes:
Validation performed:
onnxruntime_provider_testCPU build completed successfully.PackedSparseAttentionIndexerShapeInferenceTesttests passed.Motivation and Context
The existing
SparseAttentionIndexercontract uses dense[B, S, ...]inputs, dense masking, and growing contiguous state. OgaEngine-compatible paged-attention models instead use flattened packed tokens,cumulative_sequence_lengths, per-request past lengths, dynamic request scheduling, and fixed-address state.This separate operator bridges that contract mismatch for sparse paged attention while keeping the existing dense operator stable. QSA selections reference request-local positions in the main paged cache; CSA selections reference fixed-capacity auxiliary compressed state suitable for
SparsePagedAttentionlocal-plus-selected execution.Built on the sparse attention indexer work from #32528.