[Attention] Require explicit DCP support from attention implementations (#55780)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Andreas Karatzas
2026-09-08 14:04:27 -07:00
committed by GitHub
co-authored by OpenAI Codex
parent cb22234687
commit db3814a4f2
15 changed files with 199 additions and 19 deletions
+1 -1
View File
@@ -819,7 +819,7 @@ class AttentionImplBase(ABC, Generic[T]):
# Whether the attention impl supports Prefill Context Parallelism.
supports_pcp: bool = False
# Whether the attention impl supports Decode Context Parallelism.
supports_dcp: bool = True
supports_dcp: bool = False
# Whether the attention impl(or ops) supports MTP
# when cp_kv_cache_interleave_size > 1
supports_mtp_with_cp_non_trivial_interleave_size: bool = False
+1
View File
@@ -832,6 +832,7 @@ class FlashAttentionMetadataBuilder(AttentionMetadataBuilder[FlashAttentionMetad
class FlashAttentionImpl(AttentionImpl):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
def __init__(
self,
+1
View File
@@ -1779,6 +1779,7 @@ class FlashInferMetadataBuilder(AttentionMetadataBuilder[FlashInferMetadata]):
class FlashInferImpl(AttentionImpl):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
def __init__(
self,
@@ -103,6 +103,7 @@ MAX_HEADS = 128
class CutlassMLAImpl(MLACommonImpl[MLACommonMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
def __init__(
self,
@@ -255,6 +255,7 @@ class FlashAttnMLAMetadataBuilder(MLACommonMetadataBuilder[FlashAttnMLAMetadata]
class FlashAttnMLAImpl(MLACommonImpl[FlashAttnMLAMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
def __init__(
self,
@@ -210,6 +210,7 @@ class FlashInferMLABackend(MLACommonBackend):
class FlashInferMLAImpl(MLACommonImpl[MLACommonMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
# DCP is the only path that consumes LSE. It uses monolithic CuTeDSL,
# whose public LSE contract is natural-log.
lse_base_on_e: bool = True
@@ -319,6 +319,7 @@ class FlashInferMLASparseImpl(SparseMLACommonImpl[FlashInferMLASparseMetadata]):
"""
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
lse_base_on_e: bool = False
def __init__(
@@ -207,6 +207,7 @@ class FlashMLAMetadataBuilder(MLACommonMetadataBuilder[FlashMLAMetadata]):
class FlashMLAImpl(MLACommonImpl[FlashMLAMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
def __init__(
self,
@@ -582,6 +582,7 @@ class FlashMLASparseMetadataBuilder(
class FlashMLASparseImpl(SparseMLACommonImpl[FlashMLASparseMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
@staticmethod
def _compute_fp8_decode_padded_heads(num_heads: int) -> int:
@@ -1421,6 +1421,7 @@ class AiterMLAHelper:
class AiterMLAImpl(MLACommonImpl[AiterMLAMetadata]):
# DCP decode paths return natural-log softmax LSE for the cross-rank merge.
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
# Measured on gfx950: aiter.mla.mla_decode_fwd(return_lse=True) matches
# logsumexp to fp32 exactly, and merge_mla_segments_triton converts AITER's
# base-2 segment statistics with LOGE2. Stated rather than inherited because
@@ -154,6 +154,7 @@ class TokenspeedMLABackend(MLACommonBackend):
class TokenspeedMLAImpl(MLACommonImpl[MLACommonMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
# tokenspeed_mla_decode returns LSE in log2 units; its own DCP test merges
# partial outputs with exp2(lse).
lse_base_on_e: bool = False
@@ -181,6 +181,7 @@ class TritonMLABackend(MLACommonBackend):
class TritonMLAImpl(MLACommonImpl[MLACommonMetadata]):
can_return_lse_for_decode: bool = True
supports_dcp: bool = True
def __init__(
self,