[Attention] Integrate FlashAttention 4 SM100 headdim 256 support (#42669)
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
parent
8112b6c997
commit
bf2b45b5d6
@@ -134,6 +134,7 @@ def get_flash_attn_version(
|
||||
head_size: int | None = None,
|
||||
head_size_v: int | None = None,
|
||||
has_sinks: bool = False,
|
||||
requires_local_attention: bool = False,
|
||||
) -> int | None:
|
||||
if current_platform.is_xpu():
|
||||
return 2
|
||||
@@ -230,17 +231,28 @@ def get_flash_attn_version(
|
||||
)
|
||||
fa_version = 2
|
||||
|
||||
if (
|
||||
fa_version == 4
|
||||
and device_capability.major >= 10
|
||||
and head_size == 256
|
||||
and requires_local_attention
|
||||
):
|
||||
logger.warning_once(
|
||||
"FA4 on Blackwell does not support local attention with "
|
||||
"head_size=256, defaulting to FA version 2."
|
||||
)
|
||||
fa_version = 2
|
||||
|
||||
# FA4 on SM100 (Blackwell) has TMEM capacity limits that restrict
|
||||
# supported head dimensions.
|
||||
# See: https://github.com/Dao-AILab/flash-attention/issues/1959
|
||||
# Exception: hdim 192 is supported for MLA's diff-headdim case
|
||||
# (qk=192, v=128), added upstream in commits 1a15733e/1b36ab19.
|
||||
# supported head dimensions to ≤128, with exceptions for 256 and 192/128 (MLA
|
||||
# prefill). Development of symmetric 192, 384, and 512 support is being tracked
|
||||
# in https://github.com/Dao-AILab/flash-attention/issues/2456
|
||||
if (
|
||||
fa_version == 4
|
||||
and device_capability.major >= 10
|
||||
and head_size is not None
|
||||
and head_size > 128
|
||||
and head_size != 192
|
||||
and not (head_size == 256 or (head_size == 192 and head_size_v == 128))
|
||||
):
|
||||
logger.warning_once(
|
||||
"FA4 on Blackwell does not support head_size=%d due to TMEM "
|
||||
|
||||
Reference in New Issue
Block a user