[cpu/arm64] support run sglang on arm64 cpu (#14867)

This commit is contained in:
Yibo Cai
2026-01-11 04:27:19 -08:00
committed by GitHub
parent f9fc50acd6
commit 2f4a6addf3
5 changed files with 17 additions and 26 deletions
+12 -2
View File
@@ -165,9 +165,19 @@ def is_host_cpu_x86() -> bool:
)
def is_host_cpu_arm64() -> bool:
machine = platform.machine().lower()
return (
machine in ("aarch64", "arm64")
and hasattr(torch, "cpu")
and torch.cpu.is_available()
)
@lru_cache(maxsize=1)
def is_cpu() -> bool:
return os.getenv("SGLANG_USE_CPU_ENGINE", "0") == "1" and is_host_cpu_x86()
is_host_cpu_supported = is_host_cpu_x86() or is_host_cpu_arm64()
return os.getenv("SGLANG_USE_CPU_ENGINE", "0") == "1" and is_host_cpu_supported
def is_float4_e2m1fn_x2(dtype) -> bool:
@@ -3166,7 +3176,7 @@ def get_cpu_ids_by_node():
def is_shm_available(dtype, world_size, local_size):
return (
cpu_has_amx_support()
(cpu_has_amx_support() or is_host_cpu_arm64())
and dtype in [torch.bfloat16, torch.float16, torch.float]
and world_size >= 1
and world_size == local_size