Conversation
bench_fp4_matmul builds the COLI_V4_UNIT_NATIVE_QUANT unit twice β default flags (SIMD arm active) and with EXTRA_CFLAGS=-mno-avx2 (scalar arm) β verifies the two arms agree bit-exactly on seeded data, and times both at the real DeepSeek-V4-Flash expert shapes (w1/w3 [4096β2048], w2 [2048β4096]). Motivation (JustVugg#1696): on x86-64 (Zen 2, gcc 15, -march=x86-64-v3 vs -mno-avx2) the AVX2 batch arm measures 40β75Γ faster than the scalar arm at those shapes (~141β159 vs ~1.9β3.8 GFLOP/s), with bit-exact identical outputs. This harness reproduces that A/B anywhere and gives arm64 a baseline for the (currently missing) NEON arm. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Owner
|
The bench landed with #1730, which carries the same tools/bench_fp4_matmul.{c,sh} plus the NEON comparison on arm64 that now runs in the ARM CI job. Closing as included; thank you, it is what made the NEON arm checkable. |
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.
What
Adds
c/tools/bench_fp4_matmul.c+bench_fp4_matmul.sh: a self-contained microbench forcoli_fp4_matmul_batch_rows16_orderthat builds theCOLI_V4_UNIT_NATIVE_QUANTunit twice β default flags (SIMD arm) vsEXTRA_CFLAGS=-mno-avx2(scalar arm) β verifies the two arms agree bit-exactly on seeded data, then times both at the real V4-Flash expert shapes.Why (#1696)
To size what a NEON arm is worth on arm64, I measured the A/B on x86-64 (Zen 2 Ryzen 7 3700X, gcc 15.2, repo flags). Numbers in the issue comment:
Outputs bit-exact identical between arms (0/262144 floats differ), consistent with the design note at deepseek_v4.c:~16450 (per-row accumulation order preserved across arms).
The arm64 story: this kernel gates on
__AVX2__only, so Apple Silicon runs the scalar arm β which on an M-series (gcc 15.2,-march=armv8.2-a+dotprod) measures ~10 GFLOP/s vs ~2 on Zen 2 x86-64. The scalar arm is ~1.5β2.5% of SIMD throughput; a NEON arm does not need to match AVX2's absolute numbers to be a large win. The AVX2 arm's structure (pshufb nibble decode β 8Γ8 transpose β column-batched multiply/add) maps closely onto NEON (vqtbl1qlookup decode,vtrn/vziptranspose,vfma/mul+add lanes).Harness details
-O2 -fopenmp -march=β¦,COLI_V4_UNIT_NATIVE_QUANT), GPU-tier entry points stubbed (referenced but never taken on the CPU-only path).MISMATCHβ nonzero exit).S > 128(kernel'ssums[128]batch cap; the caller chunks prefill to β€128 rows) and non-multiple-of-32I.access/_access), arm64 (builds scalar-baseline mode until a NEON arm exists, per [Performance]: DeepSeek V4 on Apple Silicon (CPU path): prefill runs at decode speed, 1.3β1.75 prompt tok/s β 577-token prompt = 6 min TTFTΒ #1696). Prefers real gcc over Apple clang (clang lacks-fopenmp).-Wall -Wextra), run end-to-end on arm64 macOS and x86-64 Windows at SΓIΓO = 128Γ4096Γ2048.How to run
No model files, torch, or GPU needed β CPU-only, ~30 s.