[Apple Silicon] Add Metal kernel support in sgl-kernel (#23449)

Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
This commit is contained in:
R0CKSTAR
2026-05-11 17:54:27 -07:00
committed by GitHub
parent de098f4f4d
commit 74d70af09a
10 changed files with 585 additions and 202 deletions
+3 -1
View File
@@ -3,9 +3,10 @@
# Install stubs early for platforms where certain dependencies are unavailable
# (e.g. macOS/MPS has no triton, and torch.mps lacks Stream / set_device /
# get_device_properties). This must run before any downstream imports.
import platform as _platform
import sys as _sys
if _sys.platform == "darwin":
if _sys.platform == "darwin" and _platform.machine() == "arm64":
try:
import torch as _torch
@@ -22,6 +23,7 @@ if _sys.platform == "darwin":
del _torch
except ImportError:
pass
del _platform
del _sys
from sglang.srt.utils.hf_transformers_patches import apply_all as _apply_hf_patches