From b8bd773fe415473cb8f3c1b9694559729d8f29fd Mon Sep 17 00:00:00 2001 From: liuzhenwei Date: Tue, 16 Jun 2026 12:31:20 +0800 Subject: [PATCH] [XPU] Fix Triton attn fp8/bf16 check failing (#45758) Signed-off-by: zhenwei-intel --- vllm/v1/attention/backends/triton_attn.py | 43 ++++++++++--------- .../ops/triton_reshape_and_cache_flash.py | 4 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/vllm/v1/attention/backends/triton_attn.py b/vllm/v1/attention/backends/triton_attn.py index 6c67735e9f..714c63ae3c 100644 --- a/vllm/v1/attention/backends/triton_attn.py +++ b/vllm/v1/attention/backends/triton_attn.py @@ -464,26 +464,29 @@ class TritonAttentionImpl(AttentionImpl): else: self.sliding_window = (sliding_window - 1, 0) self.kv_cache_dtype = kv_cache_dtype - cap = current_platform.get_device_capability() - cap_str = cap.as_version_str() if cap is not None else "unknown" - dev = current_platform.get_device_name() - if self.kv_cache_dtype.startswith("fp8") and not ( - current_platform.has_device_capability(89) - ): - suggested = "float16" if (cap is None or cap.to_int() < 80) else "bfloat16" - raise ValueError( - f"FP8 KV cache is not supported by the Triton attention backend " - f"on {dev} (compute capability {cap_str}); native FP8 (fp8e4nv) " - f"requires SM89+. Re-run with --kv-cache-dtype {suggested}." - ) - if self.kv_cache_dtype == "bfloat16" and not ( - current_platform.has_device_capability(80) - ): - raise ValueError( - f"bfloat16 KV cache is not supported on {dev} (compute capability " - f"{cap_str}); bfloat16 requires SM80+. Re-run with " - f"--kv-cache-dtype float16." - ) + if current_platform.is_cuda(): + cap = current_platform.get_device_capability() + cap_str = cap.as_version_str() if cap is not None else "unknown" + dev = current_platform.get_device_name() + if self.kv_cache_dtype.startswith("fp8") and not ( + current_platform.has_device_capability(89) + ): + suggested = ( + "float16" if (cap is None or cap.to_int() < 80) else "bfloat16" + ) + raise ValueError( + f"FP8 KV cache is not supported by the Triton attention backend " + f"on {dev} (compute capability {cap_str}); native FP8 (fp8e4nv) " + f"requires SM89+. Re-run with --kv-cache-dtype {suggested}." + ) + if self.kv_cache_dtype == "bfloat16" and not ( + current_platform.has_device_capability(80) + ): + raise ValueError( + f"bfloat16 KV cache is not supported on {dev} (compute capability " + f"{cap_str}); bfloat16 requires SM80+. Re-run with " + f"--kv-cache-dtype float16." + ) if logits_soft_cap is None: # In flash-attn, setting logits_soft_cap as 0 means no soft cap. logits_soft_cap = 0 diff --git a/vllm/v1/attention/ops/triton_reshape_and_cache_flash.py b/vllm/v1/attention/ops/triton_reshape_and_cache_flash.py index 3959cba575..320b7aa597 100644 --- a/vllm/v1/attention/ops/triton_reshape_and_cache_flash.py +++ b/vllm/v1/attention/ops/triton_reshape_and_cache_flash.py @@ -23,9 +23,9 @@ def _is_supported_kv_cache_dtype(kv_cache_dtype: str) -> bool: ): return False if kv_cache_dtype.startswith("fp8"): - return current_platform.has_device_capability(89) + return current_platform.has_device_capability(89) or current_platform.is_xpu() if kv_cache_dtype == "bfloat16": - return current_platform.has_device_capability(80) + return current_platform.has_device_capability(80) or current_platform.is_xpu() return True