mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
The q / k / v / o / gate projections of the CPU backend (matmul_f32) were `parallel for` over the activation rows with `if (M * N >= 4096)`: a one-token decode step ran most of them on ONE thread, and a prompt read every weight row M times from memory. They are parallel over the weight rows now (threshold on M * N * K), each row is read once and reused for all M activation rows from L1; every y[m][n] is the same dot call as before, so the result does not depend on the thread count. The dot itself (CPU backend, attention scores, inkling2_loop.cpp's helpers) is strata::quant::sk::dot_f32, one more function of the run-time tiers: 4 accumulators of the tier's vector width (AVX-512 / AVX2 with FMA / NEON), plain 4-accumulator C++ in the base tier (bit-identical to the sum it replaces: sk_tier_test checks it). The vector tiers sum in lane order, so a CPU-only run differs from 0.2.20 by float rounding (SQ-10 teacher-forced KL(old||new) 4e-4, repeatable run to run). Measured, CPU backend, SQ-10 prefill 128 / decode 8, alternating pairs: Apple M5 Max prefill 3.2 -> 7.7 ppts, decode 1.6 -> 2.5 tok/s (spread under 1 %); Zen 4 16 threads, UD-Q2_K_XL: prefill 11.1 -> 13.0, decode 2.7 -> 4.3.