Repository navigation
Add Arm BF16 (BFDOT) bf16_f32 GEMM micro-kernels - #11949
Open
JakeStevens wants to merge 1 commit into
Open
JakeStevens wants to merge 1 commit into
JakeStevens wants to merge 1 commit into
Conversation
JakeStevens
force-pushed
the
bf16-fc-2
branch
from
November 23, 2026 16:57
e69c23a to
a7bdea4
Compare
Adds BFDOT c2 bf16_f32 GEMM micro-kernels and an AArch64 bf16_f32 GEMM config
that uses them on cores with FEAT_BF16, so the subgraph now keeps bf16
fully-connected nodes native there. Apple cores keep the fp32 fallback: on an
M4 (Apple clang 17.0.0, 1 thread, native forced by temporarily dropping the
Apple clause) native BFDOT is 1.05-1.15x faster at M=1 but 0.64-0.66x at M=16
and 128. The bf16_f32 GEMM tester now passes a real cn_stride (the existing
kernels ignore it), and the test is registered in CMake.
Pixel 10 (Tensor G5, Cortex-X4 core, NDK r29 clang 21.0.0), 1 thread pinned,
BF16FullyConnected, median of 3; "before" is master, which rewrites the node
to fp32:
| M | K | N | before | after | speedup | peak memory |
|--:|--:|--:|---:|---:|---:|---|
| 1 | 4096 | 512 | 216 us | 124 us | 1.74x | 16 -> 4 MiB |
| 1 | 512 | 4096 | 171 us | 114 us | 1.50x | 16 -> 4 MiB |
| 16 | 4096 | 512 | 1273 us | 690 us | 1.84x | 16 -> 4 MiB |
| 16 | 512 | 4096 | 1145 us | 701 us | 1.63x | 16 -> 4 MiB |
| 128 | 4096 | 512 | 7230 us | 5089 us | 1.42x | 18 -> 4 MiB |
| 128 | 512 | 4096 | 7576 us | 5227 us | 1.45x | 16 -> 4 MiB |
bf16-f32-gemm-minmax-test # Apple M4 Max: [ PASSED ] 132 tests.
fully-connected-test # Apple M4 Max: [ PASSED ] 83 tests.
bf16-f32-gemm-minmax-test # Pixel 10: [ PASSED ] 132 tests.
fully-connected-test # Pixel 10: [ PASSED ] 72 tests.
JakeStevens
force-pushed
the
bf16-fc-2
branch
from
November 24, 2026 15:16
a7bdea4 to
2dae203
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #11948; only the last commit is new here.
Adds BFDOT
bf16_f32GEMM micro-kernels and an AArch64bf16_f32GEMM config that uses them on cores with FEAT_BF16, so bf16 fully-connected nodes stay native there. Apple cores keep the fp32 fallback: on an M4 (Apple clang 17.0.0, 1 thread, native forced by temporarily dropping the Apple clause) native BFDOT is 1.05-1.15x faster at M=1 but 0.64-0.66x at M=16 and 128. Thebf16_f32GEMM tester now passes a realcn_stride, and the test is registered in CMake.Pixel 10 (Tensor G5, Cortex-X4 core, NDK r29 clang 21.0.0),
BF16FullyConnected, 1 thread pinned, median of 3; "before" is master, which rewrites the node to fp32:Tests:
bf16-f32-gemm-minmax-test(132 tests) and the fully-connected and batch-matrix-multiply subgraph and operator tests pass on Apple M4 Max. On the Pixel 10, where the native path runs,bf16-f32-gemm-minmax-test(132 tests) andfully-connected-test(72 tests) pass.Authored with Claude Code.