[Engine] AVX-only CPUs: a native pack's Q2_0 layers on Strata's AVX1 Q2_0 rows instead of ggml-cpu's vec_dot

q2_native_kernels() admitted AVX2 only, so on a CPU with AVX but no AVX2 (Sandy / Ivy Bridge, an older-CPU build with
STRATA_ISA_FLOOR=avx) a native pack's Q2_0 layers took ggml-cpu's Q2_0 vec_dot, although q2_rows_any / act_quant_any
have had an AVX1 rung since #1699 (q2_avx1.cpp).  An AVX-only CPU now takes that rung; a CPU without AVX keeps ggml-cpu.

kq_cpu_bench --pairs q2_0/q2_0 --mb 1024 --reps 3 on an i7-3770 (AVX, DDR3-1600), ms per expert per thread at 1 / 3 / 4
tokens: ggml-cpu 0.975 / 2.89 / 3.78; the AVX1 rows 0.517 / 1.13 / 1.40, and with STRATA_Q2_BITPLANE=1
0.418 / 0.807 / 0.954.

The AVX1 rows sum their floats in q2_avx1's own order, so on these CPUs the bits change against ggml-cpu's, as they
already do on an AVX2 CPU, which takes Strata's rows.  AVX2 / AVX-512 CPUs and the release engines (AVX2 baseline) are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
KeoianandClaude Opus 5.5 committed 2026-10-30 15:31:06 +00:00
1 parent 870aedd9e1
commit 43e390e0e3
1 file changed
+5 -4
+5 -4
View File
@@ -75,10 +75,11 @@ bool cpu_gather_fast_here();
/// STRATA_FORCE_ISA, and not an older-CPU build (STRATA_ISA_FLOOR, which stays on its floor and AVX2).
/// STRATA_NO_AVXVNNI=1 answers no.
bool cpu_avxvnni_ok();
/// Whether a native pack's layer of this ggml type runs on Strata's own Q2_0 kernels (AVX2 / AVX-512). On a
/// CPU without AVX2 (a native, non-portable build: ggml-cpu compiled for this CPU's SSE) a Q2_0 layer takes
/// ggml-cpu's own Q2_0 vec_dot like every other native type: slower, but it runs.
inline bool q2_native_kernels(int type) { return type == 42 && cpu_avx2_ok(); }
/// Whether a native pack's layer of this ggml type runs on Strata's own Q2_0 kernels (AVX-512 / AVX2, and the AVX1
/// rung of q2_rows_any / act_quant_any on a CPU with AVX but no AVX2: Sandy / Ivy Bridge). Only a CPU without AVX
/// (STRATA_ISA_FLOOR=none) takes ggml-cpu's own Q2_0 vec_dot, which on an i7-3770 took 0.98 ms per expert at one
/// token against 0.52 ms for the AVX1 rows (0.42 with STRATA_Q2_BITPLANE=1; kq_cpu_bench --pairs q2_0/q2_0).
inline bool q2_native_kernels(int type) { return type == 42 && (cpu_avx2_ok() || cpu_avx1_ok()); }
/// The CPU's brand string (CPUID 0x80000002..4), for messages; "unknown" when it has none.
std::string cpu_name();
/// Q2_0 GGUF rows / activation quantizer on the kernels this CPU has.