A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 05:30 UTC
[Hardware][Apple-CPU] Enable native bfloat16 on Apple Silicon (M2 and later) (#24129)
Signed-off-by: ignaciosica <mignacio.sica@gmail.com>
Ignacio Sica committed
Sep 10, 2025 at 00:50 UTC
3c2156b3af0e1fd8060bdfe5980d680ebc550a43
1 file changed
+6
-6
vllm/platforms/cpu.py
+6
-6
@@ -75,12 +75,12 @@ class CpuPlatform(Platform):
75
def supported_dtypes(self) -> list[torch.dtype]:
76
if self.get_cpu_architecture() == CpuArchEnum.POWERPC:
77
return [torch.bfloat16, torch.float32]
78
- elif sys.platform.startswith(
79
- "darwin") and self.get_cpu_architecture() == CpuArchEnum.ARM:
80
- # TODO: change this condition to check if the platform support bf16
81
- # instead of checking the OS. For instance M2 shall supports bf16
82
- # already. But we need to modify `cpu_extension.cmake` to activate
83
- # the feature in the build.
78
+ elif (self.get_cpu_architecture() == CpuArchEnum.ARM
79
+ and sys.platform.startswith("darwin")):
80
+ if (subprocess.check_output(
81
+ ["sysctl -n hw.optional.arm.FEAT_BF16"],
82
+ shell=True).strip() == b"1"):
83
+ return [torch.bfloat16, torch.float16, torch.float32]
84
return [torch.float16, torch.float32]
85
# x86/aarch64 CPU has supported both bf16 and fp16 natively.
86
return [torch.bfloat16, torch.float16, torch.float32]