Skip to content

Conversation

ignaciosica
Copy link
Contributor

@ignaciosica ignaciosica commented Sep 2, 2025

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:

Your device 'cpu' doesn't support torch.bfloat16. 
Falling back to torch.float16 for compatibility.

With this update, bf16 models now run natively on supported M-series CPUs.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@ignaciosica ignaciosica force-pushed the darwin_arm_bf16_support branch from a233651 to ae3b4f3 Compare September 2, 2025 23:15
@ignaciosica ignaciosica force-pushed the darwin_arm_bf16_support branch from d0e1db1 to 729ac9c Compare September 3, 2025 13:59
@ignaciosica ignaciosica force-pushed the darwin_arm_bf16_support branch from 729ac9c to 1c9d871 Compare September 4, 2025 18:30
@ignaciosica
Copy link
Contributor Author

cc @bigPYJ1151
any feedback?

@bigPYJ1151
Copy link
Member

@ignaciosica sorry for the late. Please fix the failed format check https://github.com/vllm-project/vllm/actions/runs/17473335720/job/49626975155?pr=24129

@ignaciosica ignaciosica force-pushed the darwin_arm_bf16_support branch from 2f94100 to bddf531 Compare September 9, 2025 21:22
@ignaciosica
Copy link
Contributor Author

no worries!
sure, fixed linting issues

@bigPYJ1151 bigPYJ1151 enabled auto-merge (squash) September 10, 2025 01:54
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 10, 2025
@bigPYJ1151 bigPYJ1151 merged commit 3c2156b into vllm-project:main Sep 10, 2025
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants