-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
[Hardware][Apple-CPU] Enable native bfloat16 on Apple Silicon (M2 and later) #24129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hardware][Apple-CPU] Enable native bfloat16 on Apple Silicon (M2 and later) #24129
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request enables native bfloat16 support on Apple Silicon M2 CPUs and later by checking for the hw.optional.arm.FEAT_BF16
sysctl key. This is a valuable addition that was previously marked as a TODO. My main feedback is to make the sysctl check more robust by handling potential exceptions, which would prevent crashes on systems where the check might fail. I've added a specific comment with a code suggestion for this.
a233651
to
ae3b4f3
Compare
d0e1db1
to
729ac9c
Compare
Signed-off-by: ignaciosica <[email protected]>
729ac9c
to
1c9d871
Compare
cc @bigPYJ1151 |
@ignaciosica sorry for the late. Please fix the failed format check https://github.com/vllm-project/vllm/actions/runs/17473335720/job/49626975155?pr=24129 |
Signed-off-by: ignaciosica <[email protected]>
2f94100
to
bddf531
Compare
no worries! |
Purpose
This PR adds bfloat16 (bf16) support for Apple M-series CPUs, based on a sysctl capability check.
According to the LLVM commit, bf16 instructions are supported on Apple Silicon CPUs starting with the M2 generation.
Details
The necessary
cpu_extension.cmake
changes were already addressed in #21195.Previously, basic offline inference in native bf16 (e.g., with Qwen/Qwen3-0.6B) would fall back to float16:
With this update, bf16 models now run natively on supported M-series CPUs.