Enable gfx1250 ROCm architecture (#46516)
Signed-off-by: Douglas Lehr <Doug.Lehr@amd.com> Signed-off-by: jpvillam <juan.villamizar@amd.com> Signed-off-by: Daniel <danichan@amd.com> Signed-off-by: Jaden Mathias <jaden.mathias@amd.com> Signed-off-by: jpvillam <jpvillam@amd.com> Signed-off-by: Juan Villamizar <100237675+jpvillam-amd@users.noreply.github.com> Signed-off-by: Douglas Lehr <91553416+dllehr-amd@users.noreply.github.com> Signed-off-by: Jaden Mathias <Jaden.Mathias@amd.com> Co-authored-by: Douglas Lehr <Doug.Lehr@amd.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Daniel <danichan@amd.com> Co-authored-by: Jaden Mathias <jaden.mathias@amd.com> Co-authored-by: jpvillam <jpvillam@amd.com> Co-authored-by: root <root@ctheliosr-1b114-f01-2.mnb.dcgpu> Co-authored-by: Douglas Lehr <91553416+dllehr-amd@users.noreply.github.com> Co-authored-by: dllehr <douglehr@amd.com> Co-authored-by: Daniel Chan <Daniel.Chan@amd.com> Co-authored-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
co-authored by
Douglas Lehr
Claude Opus 4.7
Daniel
Jaden Mathias
jpvillam
root
Douglas Lehr
dllehr
Daniel Chan
Andreas Karatzas
parent
553fcb82d5
commit
4f1da84eb5
@@ -35,23 +35,31 @@ elif current_platform.is_xpu():
|
||||
compile_flash_attn_varlen_func_from_specs = None # type: ignore[assignment]
|
||||
get_scheduler_metadata = xpu_ops.get_scheduler_metadata # type: ignore[assignment]
|
||||
elif current_platform.is_rocm():
|
||||
# On ROCm we use AITER's Triton flash-attention; the upstream flash-attn
|
||||
# package is not installed/available. (Same source as aiter_triton_mla.py.)
|
||||
# The FA4 compile-from-specs API is CUDA-only, so it is unavailable on ROCm
|
||||
# regardless of whether AITER is present.
|
||||
from vllm.platforms.rocm import on_gfx1250
|
||||
|
||||
compile_flash_attn_varlen_func_from_specs = None # type: ignore[assignment]
|
||||
try:
|
||||
from flash_attn import flash_attn_varlen_func # type: ignore[no-redef]
|
||||
if on_gfx1250():
|
||||
from aiter.ops.triton.mha import ( # type: ignore[no-redef]
|
||||
flash_attn_varlen_func,
|
||||
)
|
||||
else:
|
||||
from flash_attn import flash_attn_varlen_func # type: ignore[no-redef]
|
||||
|
||||
compile_flash_attn_varlen_func_from_specs = None # type: ignore[assignment]
|
||||
|
||||
# Mark that upstream flash-attn is available on ROCm
|
||||
_ROCM_FLASH_ATTN_AVAILABLE = True
|
||||
except ImportError:
|
||||
|
||||
def flash_attn_varlen_func(*args: Any, **kwargs: Any) -> Any: # type: ignore[no-redef,misc]
|
||||
package = "aiter" if on_gfx1250() else "flash-attn"
|
||||
raise ImportError(
|
||||
"ROCm platform requires upstream flash-attn "
|
||||
"to be installed. Please install flash-attn first."
|
||||
f"ROCm platform requires upstream {package} "
|
||||
f"to be installed. Please install {package} first."
|
||||
)
|
||||
|
||||
compile_flash_attn_varlen_func_from_specs = None # type: ignore[assignment]
|
||||
|
||||
# ROCm doesn't use scheduler metadata (FA3 feature), provide stub
|
||||
def get_scheduler_metadata(*args: Any, **kwargs: Any) -> None: # type: ignore[misc]
|
||||
return None
|
||||
@@ -348,7 +356,8 @@ def is_flash_attn_varlen_func_available() -> bool:
|
||||
Platform-specific sources:
|
||||
- CUDA: vllm.vllm_flash_attn.flash_attn_varlen_func
|
||||
- XPU: xpu_ops.flash_attn_varlen_func
|
||||
- ROCm: upstream flash_attn.flash_attn_varlen_func (if available)
|
||||
- ROCm: aiter.ops.triton.mha.flash_attn_varlen_func (if AITER available) or
|
||||
upstream flash_attn.flash_attn_varlen_func
|
||||
|
||||
Note: This is separate from the AITER flash attention backend (rocm_aiter_fa.py)
|
||||
which uses rocm_aiter_ops.flash_attn_varlen_func. The condition to use AITER is
|
||||
|
||||
@@ -776,12 +776,12 @@ class AiterFlashAttentionBackend(AttentionBackend):
|
||||
|
||||
@classmethod
|
||||
def supports_compute_capability(cls, capability: DeviceCapability) -> bool:
|
||||
from vllm.platforms.rocm import on_mi3xx
|
||||
from vllm.platforms.rocm import get_cdna_version
|
||||
|
||||
# DeviceCapability is currently created using torch.cuda.get_device_capability()
|
||||
# which is known to be buggy on rocm systems. on_mi3xx uses amd-smi which is
|
||||
# which is known to be buggy on rocm systems. on CDNA uses amd-smi which is
|
||||
# more reliable.
|
||||
return on_mi3xx()
|
||||
return get_cdna_version() > 2
|
||||
|
||||
@classmethod
|
||||
def supports_non_causal(cls) -> bool:
|
||||
|
||||
@@ -18,6 +18,13 @@ if HAS_TRITON:
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
def _skip_aiter_sampler_on_gfx1250() -> bool:
|
||||
# Lazy ROCm-only import; keeps arch detection out of import time on CUDA/CPU.
|
||||
from vllm.platforms.rocm import on_gfx1250
|
||||
|
||||
return on_gfx1250()
|
||||
|
||||
|
||||
def flashinfer_sampler_supported() -> bool:
|
||||
"""Decide whether FlashInfer's top-p/top-k sampler can be used.
|
||||
|
||||
@@ -110,6 +117,7 @@ class TopKTopPSampler(nn.Module):
|
||||
elif (
|
||||
logprobs_mode not in PROCESSED_LOGPROBS_MODES
|
||||
and rocm_aiter_ops.is_enabled()
|
||||
and not _skip_aiter_sampler_on_gfx1250() # TODO (JPVILLAM): Enable
|
||||
):
|
||||
self.aiter_ops = None
|
||||
self._aiter_ops_import_failed = False
|
||||
|
||||
Reference in New Issue
Block a user