Milestone: SIMD kernels — break the compute wall (issue #3)
Measured on the real checkpoint (issue #2, comment 5182023384):
7.47 s/token, 1.08e9 decoded elements/token, ~290 MFLOP/s, effective
read ~115 MB/s — compute-bound, not read-bound. Single-threaded
scalar decode+matvec is the wall; the NVMe has 10-20x headroom.
Goal
AVX2 (acer) + NEON (Mac) paths for the three hot kernels, verified
bit-identical to scalar on fixtures before they may replace them
(the determinism invariant — the state dump is the reference, both
backends must match it exactly).
ds4f_mxfp4_decode — nibble unpack (2 elems/byte), E8M0 scale, E2M1
magnitude table. pshufb/NEON tbl LUTs; scale per 32-block broadcast.
ds4f_mxfp4_matvec — decode into fp32 lanes, FMA accumulate, rows
independent → vectorize + parallelize across the 6 topk experts
(the compute threads lever has never been applied — reads had 4
threads, math has 1).
ds4f_bf16_matvec — shift-left-16 decode, FMA.
Dispatch
Runtime: __builtin_cpu_supports("avx2") on x86, #if defined __aarch64__ for NEON; scalar fallback everywhere. One source of truth
per kernel; the gate suite always tests scalar (portable CI), plus a
--bench-kernels tool to run all three paths on the acer.
Acceptance
- Fixture: SIMD output byte-identical to scalar (test_kernels extended).
- acer
--bench-kernels: decode+matvec ≥ 10x scalar.
- Real checkpoint rerun: expect ~1-2 s/token (from 7.47), same
GB/token 0.86, same state.bin.
The follow-on (separate issue): GPU backend — at which point the wall
becomes the disk (~0.2-0.4 s/token floor on the acer's NVMe with the
trunk pinned).
Milestone: SIMD kernels — break the compute wall (issue #3)
Measured on the real checkpoint (issue #2, comment 5182023384):
7.47 s/token, 1.08e9 decoded elements/token, ~290 MFLOP/s, effective
read ~115 MB/s — compute-bound, not read-bound. Single-threaded
scalar decode+matvec is the wall; the NVMe has 10-20x headroom.
Goal
AVX2 (acer) + NEON (Mac) paths for the three hot kernels, verified
bit-identical to scalar on fixtures before they may replace them
(the determinism invariant — the state dump is the reference, both
backends must match it exactly).
ds4f_mxfp4_decode— nibble unpack (2 elems/byte), E8M0 scale, E2M1magnitude table. pshufb/NEON tbl LUTs; scale per 32-block broadcast.
ds4f_mxfp4_matvec— decode into fp32 lanes, FMA accumulate, rowsindependent → vectorize + parallelize across the 6 topk experts
(the compute threads lever has never been applied — reads had 4
threads, math has 1).
ds4f_bf16_matvec— shift-left-16 decode, FMA.Dispatch
Runtime:
__builtin_cpu_supports("avx2")on x86,#if defined __aarch64__for NEON; scalar fallback everywhere. One source of truthper kernel; the gate suite always tests scalar (portable CI), plus a
--bench-kernelstool to run all three paths on the acer.Acceptance
--bench-kernels: decode+matvec ≥ 10x scalar.GB/token 0.86, same state.bin.
The follow-on (separate issue): GPU backend — at which point the wall
becomes the disk (~0.2-0.4 s/token floor on the acer's NVMe with the
trunk pinned).