[Spec Decode] Enable adaptive DSpark on SM100 sparse MLA (#52783)

Signed-off-by: mgoin <mgoin64@gmail.com>
This commit is contained in:
Misha Goin
2026-08-25 13:31:15 -04:00
committed by GitHub
parent 70021a0081
commit 7de96050c5
7 changed files with 293 additions and 18 deletions
+27 -7
View File
@@ -130,8 +130,6 @@ def init_attn_backend(
# Phase 3: create metadata builders and determine cudagraph support.
attn_backend_workspace: torch.Tensor | None = None
min_cg_support = AttentionCGSupport.ALWAYS
min_cg_attn_backend = None
for kv_cache_group_id, groups in enumerate(attn_groups):
kernel_block_size = None
if kv_cache_group_id < len(kernel_block_sizes):
@@ -150,7 +148,25 @@ def init_attn_backend(
else:
if hasattr(builder, "set_workspace_buffer"):
builder.set_workspace_buffer(attn_backend_workspace)
# Check cudagraph support for the attention backend
attn_cg_support_info = get_attn_cg_support(attn_groups, vllm_config)
return attn_groups, attn_cg_support_info, kernel_block_sizes
def get_attn_cg_support(
attn_groups: list[list[AttentionGroup]],
vllm_config: VllmConfig,
checked_layer_names: set[str] | None = None,
) -> AttentionCGSupportInfo:
"""Return the weakest CUDA graph support among the checked layers."""
min_cg_support = AttentionCGSupport.ALWAYS
min_cg_attn_backend = None
for groups in attn_groups:
for group in groups:
if checked_layer_names is not None and checked_layer_names.isdisjoint(
group.layer_names
):
continue
builder = group.get_metadata_builder(0)
cg_support = builder.get_cudagraph_support(
vllm_config,
group.kv_cache_spec,
@@ -158,15 +174,15 @@ def init_attn_backend(
if cg_support.value < min_cg_support.value:
min_cg_support = cg_support
min_cg_attn_backend = group.backend.__name__
attn_cg_support_info = AttentionCGSupportInfo(
min_cg_support=min_cg_support, min_cg_attn_backend=min_cg_attn_backend
return AttentionCGSupportInfo(
min_cg_support=min_cg_support,
min_cg_attn_backend=min_cg_attn_backend,
)
return attn_groups, attn_cg_support_info, kernel_block_sizes
def get_query_lens_mismatch_unsupported_backend(
attn_groups: list[list[AttentionGroup]],
checked_layer_names: set[str] | None = None,
) -> str | None:
"""Name the first backend needing the CPU query lengths to be exact, if any.
@@ -176,6 +192,10 @@ def get_query_lens_mismatch_unsupported_backend(
"""
for groups in attn_groups:
for group in groups:
if checked_layer_names is not None and checked_layer_names.isdisjoint(
group.layer_names
):
continue
if not group.backend.supports_device_cpu_query_lens_mismatch():
return group.backend.__name__
return None