[CI] Select mirror_hardwares presets via MIRROR_HW (H100/B200) (#5543)
Signed-off-by: wangyu <410167048@qq.com> Signed-off-by: lishunyang12 <lishunyang12@163.com> Signed-off-by: [Your Name] <your.email@example.com> Signed-off-by: wangyu <53896905+yenuo26@users.noreply.github.com> Signed-off-by: Bo Li <22713281+bobboli@users.noreply.github.com> Co-authored-by: lishunyang12 <lishunyang12@163.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Bo Li <22713281+bobboli@users.noreply.github.com>
This commit is contained in:
77 files changed
+3470
-1077
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Diffusers backend adapter for vLLM-Omni.
|
||||
|
||||
Provides a black-box wrapper around any 🤗 Diffusers pipeline, enabling
|
||||
@@ -44,13 +44,21 @@ logger = logging.getLogger(__name__)
|
||||
# with the accuracy tests' diffusers reference runs so both sides of a
|
||||
# similarity comparison resolve to the same backend on any given image
|
||||
# (hub kernels may lack a build variant for the image's torch).
|
||||
CUDA_FLASH_ATTENTION_BACKEND_ATTEMPTS: list[str] = [
|
||||
# Automatic / FLASH_ATTN selection walks the full chain. Explicit Hub
|
||||
# options attempt only their matching Diffusers backend names.
|
||||
CUDA_FLASH_ATTN_3_HUB_ATTEMPTS: list[str] = [
|
||||
"_flash_3_hub",
|
||||
"_flash_3_varlen_hub",
|
||||
"_flash_3",
|
||||
"_flash_varlen_3",
|
||||
]
|
||||
CUDA_FLASH_ATTN_HUB_ATTEMPTS: list[str] = [
|
||||
"flash_hub",
|
||||
"flash_varlen_hub",
|
||||
]
|
||||
CUDA_FLASH_ATTENTION_BACKEND_ATTEMPTS: list[str] = [
|
||||
*CUDA_FLASH_ATTN_3_HUB_ATTEMPTS,
|
||||
"_flash_3",
|
||||
"_flash_varlen_3",
|
||||
*CUDA_FLASH_ATTN_HUB_ATTEMPTS,
|
||||
"flash",
|
||||
"flash_varlen",
|
||||
"_native_flash",
|
||||
@@ -293,6 +301,24 @@ class DiffusersAdapterPipeline(nn.Module, DiffusionPipelineProfilerMixin):
|
||||
# Wrap settings, inputs, and outputs
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@staticmethod
|
||||
def _is_blackwell_gpu() -> bool:
|
||||
"""Return True on Blackwell-class CUDA GPUs (sm_10x / sm_11x / sm_12x)."""
|
||||
capability = None
|
||||
try:
|
||||
capability = current_omni_platform.get_device_capability()
|
||||
except Exception:
|
||||
capability = None
|
||||
if capability is not None:
|
||||
return capability.major in (10, 11, 12)
|
||||
if torch.cuda.is_available():
|
||||
try:
|
||||
major, _ = torch.cuda.get_device_capability()
|
||||
return major in (10, 11, 12)
|
||||
except Exception:
|
||||
return False
|
||||
return False
|
||||
|
||||
def _set_attention_backend(self) -> None:
|
||||
"""Set the attention backend.
|
||||
|
||||
@@ -308,6 +334,20 @@ class DiffusersAdapterPipeline(nn.Module, DiffusionPipelineProfilerMixin):
|
||||
attention_backend_config = default_spec.backend if default_spec is not None else None
|
||||
attention_backend_attempts: list[str] = []
|
||||
match attention_backend_config:
|
||||
case "FLASH_ATTN_3_HUB":
|
||||
if self._is_blackwell_gpu():
|
||||
raise ValueError(
|
||||
"FLASH_ATTN_3_HUB was explicitly selected for a Diffusers adapter on "
|
||||
"Blackwell, but no runnable sm_10x+ Flash Attention kernel is available."
|
||||
)
|
||||
attention_backend_attempts.extend(CUDA_FLASH_ATTN_3_HUB_ATTEMPTS)
|
||||
case "FLASH_ATTN_HUB":
|
||||
if self._is_blackwell_gpu():
|
||||
raise ValueError(
|
||||
"FLASH_ATTN_HUB was explicitly selected for a Diffusers adapter on "
|
||||
"Blackwell, but no runnable sm_10x+ Flash Attention kernel is available."
|
||||
)
|
||||
attention_backend_attempts.extend(CUDA_FLASH_ATTN_HUB_ATTEMPTS)
|
||||
case "FLASH_ATTN" | None:
|
||||
if current_omni_platform.is_rocm():
|
||||
attention_backend_attempts.append("aiter")
|
||||
@@ -318,17 +358,31 @@ class DiffusersAdapterPipeline(nn.Module, DiffusionPipelineProfilerMixin):
|
||||
"Unknown diffusers attention backend option for MUSA platform. Falling back to SDPA."
|
||||
)
|
||||
attention_backend_attempts.append("native")
|
||||
elif self._is_blackwell_gpu():
|
||||
# Installed FA2/FA3 (and HF FA3 hub) wheels are typically Hopper-only.
|
||||
# set_attention_backend("_flash_3*") can succeed on import, then crash
|
||||
# at runtime with "no kernel image is available for execution on the device".
|
||||
if attention_backend_config is not None:
|
||||
raise ValueError(
|
||||
f"{attention_backend_config} was explicitly selected for a Diffusers adapter on "
|
||||
"Blackwell, but no runnable sm_10x+ Flash Attention kernel is available."
|
||||
)
|
||||
attention_backend_attempts.append("native")
|
||||
else:
|
||||
attention_backend_attempts.extend(CUDA_FLASH_ATTENTION_BACKEND_ATTEMPTS)
|
||||
case "SAGE_ATTN":
|
||||
attention_backend_attempts.extend(["sage_hub", "sage", "sage", "sage_varlen"])
|
||||
attention_backend_attempts.extend(["sage_hub", "sage", "sage_varlen"])
|
||||
case "ASCEND":
|
||||
attention_backend_attempts.append("_native_npu")
|
||||
case "TORCH_SDPA":
|
||||
attention_backend_attempts.append("native")
|
||||
case "CUDNN_ATTN" | "FLASHINFER_ATTN" | "TRTLLM_ATTN":
|
||||
raise ValueError(
|
||||
f"{attention_backend_config} was explicitly selected, but Diffusers adapters do not "
|
||||
"provide a binding for this vLLM-Omni backend. Select TORCH_SDPA or a Diffusers-native backend."
|
||||
)
|
||||
case _:
|
||||
logger.warning(f"Invalid attention backend: {attention_backend_config}. Falling back to SDPA.")
|
||||
attention_backend_attempts.append("native")
|
||||
raise ValueError(f"Invalid Diffusers attention backend: {attention_backend_config}.")
|
||||
|
||||
attempt_errors: list[str] = []
|
||||
set_backend: str | None = None
|
||||
@@ -340,8 +394,15 @@ class DiffusersAdapterPipeline(nn.Module, DiffusionPipelineProfilerMixin):
|
||||
except Exception as e:
|
||||
attempt_errors.append(str(e))
|
||||
|
||||
# If all attempts fail, fallback to SDPA and warn the user about the failures
|
||||
# Automatic selection may use native SDPA as its final safe choice. An
|
||||
# explicitly configured backend must either be installed or raise.
|
||||
if len(attempt_errors) == len(attention_backend_attempts):
|
||||
if attention_backend_config is not None:
|
||||
raise RuntimeError(
|
||||
f"Failed to set explicitly selected attention backend '{attention_backend_config}' for "
|
||||
f"diffusers pipeline {self._pipeline.__class__.__name__}. Attempts: "
|
||||
f"{dict(zip(attention_backend_attempts, attempt_errors))}"
|
||||
)
|
||||
self._pipeline.transformer.set_attention_backend("native")
|
||||
logger.warning(
|
||||
f"Failed to set attention backend '{attention_backend_config}' for "
|
||||
|
||||
Reference in new issue
Block a user