Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/contrib_ops/cuda/dynamic_sparse_attention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CUDA DynamicSparseAttention grouped decode

`ORT_DSA_INT8_GROUPED_MAX_ROWS` controls the maximum query rows eligible for
the existing grouped INT8 decode kernel. The default is 2, preserving existing
dispatch. Set it to 4 before starting the process to allow three- and four-row
speculative verification; the supported range is 2 through 4.

All other grouped-kernel eligibility conditions still apply. Ineligible cache
formats, shapes, and devices retain their existing dispatch. This does not
change the operator schema, cache layout, or sparse-index selection semantics.

The INT8 grouped-decode and vector-staging reference tests cover one through
four query rows. To exercise the opt-in path, run the INT8 grouped-decode tests
in a fresh process with `ORT_DSA_INT8_GROUPED_MAX_ROWS=4`.
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,12 @@ bool UseGroupedDecodeAttention(const DynamicSparseAttentionParameters& parameter
size_t element_size,
size_t max_shared_memory_per_block,
bool quantized_cache = false) {
static const int max_decode_rows =
ParseEnvironmentVariableWithDefault<int>("ORT_DSA_INT8_GROUPED_MAX_ROWS", 2);
ORT_ENFORCE(max_decode_rows >= 2 && max_decode_rows <= 4,
"ORT_DSA_INT8_GROUPED_MAX_ROWS must be in [2, 4].");
return (parameters.sequence_length == 1 ||
(quantized_cache && parameters.sequence_length == 2)) &&
(quantized_cache && parameters.sequence_length <= max_decode_rows)) &&
parameters.num_heads / parameters.kv_num_heads >= 4 &&
GetCandidateCapacity(parameters) > kSplitCandidateSize &&
SupportsGroupedAttention(parameters, element_size, max_shared_memory_per_block) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ TEST(DynamicSparseAttentionTest, FloatingCacheGroupedSingleSplitWorkspace_CUDA)
}

TEST(DynamicSparseAttentionTest, Int8CacheGroupedDecode_CUDA) {
for (int sequence_length : {1, 2}) {
for (int sequence_length : {1, 2, 3, 4}) {
for (bool auxiliary : {false, true}) {
SCOPED_TRACE("sequence_length=" + std::to_string(sequence_length) +
", auxiliary=" + std::to_string(auxiliary));
Expand All @@ -603,7 +603,7 @@ TEST(DynamicSparseAttentionTest, Int8CacheGroupedDecodeFloat16_CUDA) {
}

TEST(DynamicSparseAttentionTest, Int8CacheGroupedDecodeVectorStagingChannels_CUDA) {
for (int sequence_length : {1, 2}) {
for (int sequence_length : {1, 2, 3, 4}) {
for (bool auxiliary : {false, true}) {
SCOPED_TRACE("sequence_length=" + std::to_string(sequence_length) +
", auxiliary=" + std::to_string(auxiliary));
Expand Down
Loading