[Feat][XPU] VLLM_BATCH_INVARIANT support for Dense/MoE models (#55881)

Signed-off-by: Tony Lin <tony.lin@intel.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
Tony Lin
2026-09-22 11:06:54 -04:00
committed by GitHub
co-authored by Flora Feng
parent 1ea7c63f4a
commit e4340e41c9
10 changed files with 619 additions and 8 deletions
+40
View File
@@ -162,6 +162,25 @@ class XPUPlatform(Platform):
if selected_backend == AttentionBackendEnum.TRITON_ATTN:
logger.info_once("Using Triton backend.")
return AttentionBackendEnum.TRITON_ATTN.get_path()
elif attn_selector_config.use_batch_invariant:
# Flash Attention on XPU has not been validated for batch
# invariance. Honor an explicit Flash Attention request;
# otherwise fall back to Triton Attention, which implements
# batch-invariant kernels.
if selected_backend == AttentionBackendEnum.FLASH_ATTN:
logger.warning_once(
"Using Flash Attention on XPU with batch invariance "
"enabled because it was explicitly requested. This "
"backend has not been validated for batch invariance "
"on XPU and may produce non-deterministic results "
"across batch sizes."
)
return AttentionBackendEnum.FLASH_ATTN.get_path()
logger.info_once(
"VLLM_BATCH_INVARIANT is enabled. Using Triton Attention "
"backend on XPU, which implements batch-invariant kernels."
)
return AttentionBackendEnum.TRITON_ATTN.get_path()
elif attn_selector_config.use_mm_prefix:
# Flash Attention on XPU has no FA4 kernel, so it cannot apply the
# multimodal prefix-LM bidirectional mask. Honor an explicit Flash
@@ -283,6 +302,27 @@ class XPUPlatform(Platform):
# lazy import to avoid circular import
from vllm.config import CUDAGraphMode
if envs.VLLM_BATCH_INVARIANT:
model_config = vllm_config.model_config
if model_config is not None and (
model_config.quantization is not None
or vllm_config.quant_config is not None
):
raise ValueError(
"XPU batch invariance currently supports only unquantized "
f"models; got quantization={model_config.quantization!r}. "
"Use an unquantized model or disable VLLM_BATCH_INVARIANT."
)
cache_dtype = vllm_config.cache_config.cache_dtype
if cache_dtype not in ("auto", "float16", "bfloat16"):
raise ValueError(
"XPU batch invariance currently does not support quantized "
f"KV caches; got kv_cache_dtype={cache_dtype!r}. "
"Use an unquantized KV cache dtype or disable "
"VLLM_BATCH_INVARIANT."
)
compilation_config = vllm_config.compilation_config
if compilation_config.compile_sizes is None:
compilation_config.compile_sizes = []