diff --git a/docs/design/attention_backends.md b/docs/design/attention_backends.md index 9d524a489be..8062ce237db 100644 --- a/docs/design/attention_backends.md +++ b/docs/design/attention_backends.md @@ -205,7 +205,7 @@ hardware and configuration. | Backend | Description | Dtypes | Compute Cap. | Notes | | ------- | ----------- | ------ | ------------ | ----- | -| `FLASH_ATTN`‡ | FlashAttention varlen (FA2/FA3/FA4) | fp16, bf16 | Any | (qk_nope_head_dim=128, qk_rope_head_dim=64, v_head_dim=128) (FA2/FA3/FA4) or (qk_nope_head_dim=192, qk_rope_head_dim=64, v_head_dim=256) (FA2/FA3 only) | +| `FLASH_ATTN`‡ | FlashAttention varlen (FA2/FA3/FA4) | fp16, bf16 | Any | (qk_nope_head_dim=128, qk_rope_head_dim=64, v_head_dim=128) (FA2/FA3/FA4) or (qk_nope_head_dim=64, qk_rope_head_dim=64, v_head_dim=128) (FA2/FA3/FA4) or (qk_nope_head_dim=192, qk_rope_head_dim=64, v_head_dim=256) (FA2/FA3 only) | | `TRTLLM_RAGGED` | TensorRT-LLM ragged attention | fp16, bf16 | 10.x | (qk_nope_head_dim=128, qk_rope_head_dim=64, v_head_dim=128) or (qk_nope_head_dim=192, qk_rope_head_dim=64, v_head_dim=256) only | | `FLASHINFER` | FlashInfer CUTLASS backend | fp16, bf16 | 10.x | (qk_nope_head_dim=128, qk_rope_head_dim=64, v_head_dim=128) only | | `TOKENSPEED_MLA` | | fp16, bf16 | 10.x | (qk_nope_head_dim=128, qk_rope_head_dim=64, v_head_dim=128) only | diff --git a/tests/v1/attention/test_mla_prefill_selector.py b/tests/v1/attention/test_mla_prefill_selector.py index 8677197b7a5..d82397591f7 100644 --- a/tests/v1/attention/test_mla_prefill_selector.py +++ b/tests/v1/attention/test_mla_prefill_selector.py @@ -125,8 +125,8 @@ class TestGetMLAPrefillBackend: @pytest.mark.parametrize( ("qk_nope_head_dim", "v_head_dim"), - [(128, 128), (192, 256)], - ids=["deepseek", "glm"], + [(128, 128), (192, 256), (64, 128)], + ids=["deepseek", "glm", "mistral_s4"], ) def test_auto_selection_on_hopper(self, qk_nope_head_dim: int, v_head_dim: int): try: diff --git a/vllm/v1/attention/backends/mla/prefill/flash_attn.py b/vllm/v1/attention/backends/mla/prefill/flash_attn.py index afc4efa1ae9..30c0c6d8a68 100644 --- a/vllm/v1/attention/backends/mla/prefill/flash_attn.py +++ b/vllm/v1/attention/backends/mla/prefill/flash_attn.py @@ -63,11 +63,16 @@ class FlashAttnPrefillBackend(MLAPrefillBackend): qk_rope_head_dim=64, v_head_dim=256, ) + dims_mistral_s4 = MLADimensions( + qk_nope_head_dim=64, + qk_rope_head_dim=64, + v_head_dim=128, + ) fa_version = get_flash_attn_version() if fa_version == 4: - return mla_dimensions == dims_deepseek + return mla_dimensions in [dims_deepseek, dims_mistral_s4] else: - return mla_dimensions in [dims_deepseek, dims_glm] + return mla_dimensions in [dims_deepseek, dims_glm, dims_mistral_s4] def __init__( self,