In-Tree AMD Zen CPU Backend via zentorch [1/N] (#35970)
Signed-off-by: Lalithnarayan C <Lalithnarayan.C@amd.com> Signed-off-by: Tyler Michael Smith <tlrmchlsmth@gmail.com> Co-authored-by: Chinmay-Kulkarni-AMD <Chinmay.Kulkarni@amd.com> Co-authored-by: Tyler Michael Smith <tyler@neuralmagic.com> Co-authored-by: Tyler Michael Smith <tlrmchlsmth@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import logging
|
||||
import os
|
||||
import traceback
|
||||
from itertools import chain
|
||||
from typing import TYPE_CHECKING
|
||||
@@ -150,6 +151,15 @@ def xpu_platform_plugin() -> str | None:
|
||||
return "vllm.platforms.xpu.XPUPlatform" if is_xpu else None
|
||||
|
||||
|
||||
def _is_amd_zen_cpu() -> bool:
|
||||
"""Detect AMD CPU with AVX-512 via /proc/cpuinfo."""
|
||||
if not os.path.exists("/proc/cpuinfo"):
|
||||
return False
|
||||
with open("/proc/cpuinfo") as f:
|
||||
cpuinfo = f.read()
|
||||
return "AuthenticAMD" in cpuinfo and "avx512" in cpuinfo
|
||||
|
||||
|
||||
def cpu_platform_plugin() -> str | None:
|
||||
is_cpu = False
|
||||
logger.debug("Checking if CPU platform is available.")
|
||||
@@ -171,7 +181,24 @@ def cpu_platform_plugin() -> str | None:
|
||||
except Exception as e:
|
||||
logger.debug("CPU platform is not available because: %s", str(e))
|
||||
|
||||
return "vllm.platforms.cpu.CpuPlatform" if is_cpu else None
|
||||
if not is_cpu:
|
||||
return None
|
||||
|
||||
if _is_amd_zen_cpu():
|
||||
try:
|
||||
import zentorch # noqa: F401
|
||||
|
||||
logger.debug(
|
||||
"AMD Zen CPU detected with zentorch installed, using ZenCpuPlatform."
|
||||
)
|
||||
return "vllm.platforms.zen_cpu.ZenCpuPlatform"
|
||||
except ImportError:
|
||||
logger.debug(
|
||||
"AMD Zen CPU detected but zentorch not installed, "
|
||||
"falling back to CpuPlatform."
|
||||
)
|
||||
|
||||
return "vllm.platforms.cpu.CpuPlatform"
|
||||
|
||||
|
||||
builtin_platform_plugins = {
|
||||
@@ -269,4 +296,11 @@ def __setattr__(name: str, value):
|
||||
raise AttributeError(f"No attribute named '{name}' exists in {__name__}.")
|
||||
|
||||
|
||||
__all__ = ["Platform", "PlatformEnum", "current_platform", "CpuArchEnum", "_init_trace"]
|
||||
__all__ = [
|
||||
"Platform",
|
||||
"PlatformEnum",
|
||||
"current_platform",
|
||||
"CpuArchEnum",
|
||||
"_init_trace",
|
||||
"_is_amd_zen_cpu",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user