[Kernel] Centralize platform kernel import in current_platform.import_kernels (#26286)

Signed-off-by: NickLucche <nlucches@redhat.com>
This commit is contained in:
Nicolò Lucchesi
2025-10-08 20:25:31 +00:00
committed by GitHub
parent e1ba235668
commit 4ebc9108a7
4 changed files with 13 additions and 15 deletions
+1 -8
View File
@@ -170,22 +170,15 @@ class Platform:
return device_id
@classmethod
def import_core_kernels(cls) -> None:
def import_kernels(cls) -> None:
"""Import any platform-specific C kernels."""
try:
import vllm._C # noqa: F401
except ImportError as e:
logger.warning("Failed to import from vllm._C: %r", e)
@classmethod
def try_import_moe_kernels(cls) -> bool:
"""Import any platform-specific MoE kernels."""
with contextlib.suppress(ImportError):
import vllm._moe_C # noqa: F401
return True
return False
@classmethod
def get_vit_attn_backend(cls, head_size: int, dtype: torch.dtype) -> "_Backend":
from vllm.attention.backends.registry import _Backend