[ROCm] Remove stale SDPA and skinny GEMM workarounds (#50907)

Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com>
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Andreas Karatzas
2026-08-11 14:19:16 -04:00
committed by GitHub
co-authored by OpenAI Codex
parent 4f2f31b82e
commit 1ab2801dde
56 changed files with 500 additions and 558 deletions
+82
View File
@@ -1,12 +1,15 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import ctypes
import functools
import os
from collections.abc import Callable
import torch
from torch._ops import OpOverload
import vllm.envs as envs
from vllm.logger import init_logger
from vllm.platforms import current_platform
from vllm.utils.import_utils import PlaceholderModule
from vllm.utils.torch_utils import direct_register_custom_op
@@ -15,6 +18,8 @@ from vllm.v1.attention.ops.rocm_aiter_mla_sparse import (
rocm_aiter_sparse_attn_indexer_fake,
)
logger = init_logger(__name__)
try:
import pandas as pd
except ImportError:
@@ -49,6 +54,83 @@ def is_aiter_found() -> bool:
IS_AITER_FOUND = is_aiter_found()
class _DlInfo(ctypes.Structure):
_fields_ = [
("dli_fname", ctypes.c_char_p),
("dli_fbase", ctypes.c_void_p),
("dli_sname", ctypes.c_char_p),
("dli_saddr", ctypes.c_void_p),
]
_HIP_RUNTIME_HANDLE: ctypes.CDLL | None = None
def _find_torch_hip_runtime_path() -> str | None:
"""Find the HIP runtime already selected by PyTorch's extension graph."""
try:
torch_extension = ctypes.CDLL(torch._C.__file__)
hip_symbol = torch_extension.hipGetDeviceCount
dladdr = ctypes.CDLL(None).dladdr
dladdr.argtypes = [ctypes.c_void_p, ctypes.POINTER(_DlInfo)]
dladdr.restype = ctypes.c_int
info = _DlInfo()
if not dladdr(ctypes.cast(hip_symbol, ctypes.c_void_p), ctypes.byref(info)):
return None
except (AttributeError, OSError, TypeError, ctypes.ArgumentError):
return None
if info.dli_fname is None:
return None
runtime_path = os.fsdecode(info.dli_fname)
if "libamdhip64.so" not in os.path.basename(runtime_path):
return None
return runtime_path
def _promote_torch_hip_runtime() -> None:
"""Make PyTorch's HIP runtime symbols visible to AITER JIT extensions.
PyTorch loads its native extension with ``RTLD_LOCAL``. Some AITER JIT
extensions rely on HIP registration and launch symbols being available in
the process-global lookup scope. Reopening the exact runtime that provides
PyTorch's ``hipGetDeviceCount`` symbol promotes the existing DSO instead of
selecting or initializing a second HIP runtime.
"""
global _HIP_RUNTIME_HANDLE
if _HIP_RUNTIME_HANDLE is not None:
return
runtime_path = _find_torch_hip_runtime_path()
if runtime_path is None:
logger.warning_once(
"Could not locate PyTorch's HIP runtime; AITER JIT extensions may "
"fail to resolve HIP symbols."
)
return
try:
# Retain the handle for the process lifetime. Besides preventing a
# future dlclose, this documents that the RTLD_GLOBAL promotion is
# intentional and must outlive every lazily imported AITER extension.
_HIP_RUNTIME_HANDLE = ctypes.CDLL(runtime_path, mode=ctypes.RTLD_GLOBAL)
except OSError as err:
logger.warning_once(
"Could not promote PyTorch's HIP runtime at %s; AITER JIT "
"extensions may fail to resolve HIP symbols: %s",
runtime_path,
err,
)
def _maybe_promote_torch_hip_runtime() -> None:
if current_platform.is_rocm() and IS_AITER_FOUND:
_promote_torch_hip_runtime()
_maybe_promote_torch_hip_runtime()
def is_aiter_found_and_supported() -> bool:
"""Check if AITER library is available and platform supports it.