Files
leleka/crates/cpu-kernels
Pavlo RatushnyiandClaude Sonnet 5.5 330b31b902 perf: run the router and the expert activation on AVX2 kernels (STRA-214)
The router's 32 single-precision dot products (2,880 elements each) and the expert activation (a scalar exp
per element) were the largest serial pieces left outside the matrix products. cpu-sys gains a vector
swiglu-oai kernel (portable and AVX2 + FMA, using the same vector exp as the softmax, relative error below
3e-6 in the tests, including gates far beyond the clamps), and the router reuses the strided dot kernel.

Measured on gpt-oss-20b, 10 threads, one run each on a noisy machine (not paired): router 3.0 -> 1.3 ms
and activation 3.0 -> 1.3 ms per decoded token; in prefill (chunk 64) router 2.5 -> 0.6 ms and activation
2.5 -> 1.6 ms per token. Decode 86 ms per token (11.6 tokens/s) over 19 tokens. Teacher-forced gate against
llama.cpp: best token 97.4%, mean KL 0.0088 (criterion <= 0.012; the previous build gave 0.0077, the
difference between the two builds is 0.0050, at the noise floor).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 22:46:09 +02:00
..