mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
The Q4_K gate/up rows had no 512-bit tier in the default build (the quant layer's Avx2 contract, one token at a time), and the Q5_1 / Q8_0 down rows had a 256-bit VNNI tier per token. kq_avx512.cpp runs the integer part of every block on vpdpbusd (Q4_K: 64-byte vectors, the 6-bit scales through vpdpwssd) with the weights decoded once per row for every token of a group, and keeps the AVX2 contract's float chain (the eight-lane accumulator, the mins term, the hsum) so each token's row is the one-token dot's bit for bit. Dispatch only on a CPU with AVX-512 F/BW/VL/DQ/VNNI/VBMI (cpu_avx512_ok); the old rows stay the fallback; kq512_ok checks the rows against the build's own dot on first use and sends a mismatch back to it; STRATA_NO_KQ512=1 never takes them, STRATA_KQ512_MIN=N moves the token floor (gate/up 3, down 2). kq512_parity (840 cases: 1 to 160 tokens, real and raw-byte activations, row ranges, the SwiGLU of the gate/up rows) is bit-equal on a Xeon 8352V and skips (77) without AVX-512. One thread, 256 rows, Xeon 8352V: Q4_K n=2560 8 tokens 113 us against 182 us for the dot per token and 125 us for the AVX2 multi-token rows, 64 tokens 767 / 1474 / 1054; Q5_1 n=640 8 tokens 44 / 122 / 78; Q8_0 40 / 67 / 48; one token is slower than the dot (Q4_K 68 against 38 us), hence the floors.