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
8 changes: 6 additions & 2 deletions csrc/sparse_mla_sm120_decode_dsv4.cu
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ static bool launch_decode_dsv4_impl(const bf16* Q, const uint8_t* KV_cache, cons
}

// Public surface — explicit instantiation switch over the PR-body bench grid.
// DSV4 only, page_block_size=64 only. NUM_HEADS ∈ {8, 16, 32, 64, 128},
// TOPK ∈ {128, 512, 1024}.
// TOPK=256 covers DeepSeek-V4 DSpark's 128-token context plus padded draft
// block when vLLM builds the non-causal sparse-attention metadata.
bool launch_sparse_mla_decode_dsv4(ModelType mt, int num_heads, int topk, int page_block_size,
int num_tokens, int num_splits, const bf16* Q,
const uint8_t* KV_cache, const int32_t* indices, bf16* mid_out,
Expand All @@ -154,15 +154,19 @@ bool launch_sparse_mla_decode_dsv4(ModelType mt, int num_heads, int topk, int pa
stride_kv_block, stream); \
}
DSV4_DISPATCH(8, 128)
DSV4_DISPATCH(8, 256)
DSV4_DISPATCH(8, 512)
DSV4_DISPATCH(8, 1024)
DSV4_DISPATCH(16, 128)
DSV4_DISPATCH(16, 256)
DSV4_DISPATCH(16, 512)
DSV4_DISPATCH(16, 1024)
DSV4_DISPATCH(32, 128)
DSV4_DISPATCH(32, 256)
DSV4_DISPATCH(32, 512)
DSV4_DISPATCH(32, 1024)
DSV4_DISPATCH(64, 128)
DSV4_DISPATCH(64, 256)
DSV4_DISPATCH(64, 512)
DSV4_DISPATCH(64, 1024)
DSV4_DISPATCH(128, 128)
Expand Down
12 changes: 12 additions & 0 deletions flashinfer/mla/_sparse_mla_sm120.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@
_DECODE_DSV4_DISPATCH = frozenset(
{
(8, 128),
(8, 256),
(8, 512),
(8, 1024),
(16, 128),
(16, 256),
(16, 512),
(16, 1024),
(32, 128),
(32, 256),
(32, 512),
(32, 1024),
(64, 128),
(64, 256),
(64, 512),
(64, 1024),
(128, 128),
Expand Down Expand Up @@ -377,6 +381,14 @@ def _paged_attention(
)
return

if num_tokens <= _DECODE_MAX_TOKENS:
raise RuntimeError(
"Unsupported SM120 sparse-MLA decode shape: "
f"model_type={model_type}, num_tokens={num_tokens}, "
f"num_heads={num_heads}, topk={topk}, d_qk={d_qk}, "
f"page_block_size={kv_pbs}, extra_topk={extra_topk}"
)

module.sparse_mla_sm120_paged_attention(
q,
kv_cache,
Expand Down
1 change: 1 addition & 0 deletions tests/attention/test_sparse_mla_sm120.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def _make_decode_scratch(
(8, 512),
(8, 1024),
(16, 128),
(32, 256),
(32, 512),
(64, 1024),
(128, 1024),
Expand Down
Loading