Skip to content

SIMD kernels: break the compute wall (milestone 3) #5

Description

@rhCat

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

  1. Fixture: SIMD output byte-identical to scalar (test_kernels extended).
  2. acer --bench-kernels: decode+matvec ≥ 10x scalar.
  3. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions