From b558df67b40ebf98828ccefdfd4b823047e27f3d Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 14 Oct 2026 07:20:05 +0200 Subject: [PATCH] cpu: the exact singleton rows only where ggml-cpu is itself the AVX2 build (not AVX-512, not an ISA-floor build) STRATA_CPU_IQ_ALL_EXACT1 reproduces ggml-cpu's AVX2 single-token dot bit for bit, which only holds if the ggml-cpu in this binary is that dot: a STRATA_ISA_FLOOR build runs ggml's AVX1/SSE dots, and a native build on an AVX-512 CPU run with STRATA_FORCE_AVX2=1 runs its AVX-512 one. The guard is #2215's (ggml_cpu_has_avx2 / ggml_cpu_has_avx512). Co-authored-by: Andy Slater --- src/kernels/cpu/native_expert.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cpp index 50153002..c6cab9fd 100644 --- a/src/kernels/cpu/native_expert.cpp +++ b/src/kernels/cpu/native_expert.cpp @@ -165,9 +165,12 @@ void native_gu_rows(const NativeFmt& f, const uint8_t* blob, const void* const* // as the AVX-2 kernels, and STRATA_IQ_MT_MIN=1 takes the kernel for one token too (its rows are then // independent of the drafting: iq_avx1_parity checks every width bit for bit). static const bool avx1 = !cpu_avx2_ok() && cpu_avx1_ok() && std::getenv("STRATA_NO_IQ128") == nullptr; + // The exact rows are ggml-cpu's AVX2 single-token dot bit for bit, so they need ggml-cpu itself built for AVX2 and + // not AVX-512 (ggml_cpu_has_*): a STRATA_ISA_FLOOR build runs ggml's AVX1/SSE dots, a native build on an AVX-512 CPU + // run with STRATA_FORCE_AVX2=1 runs its AVX-512 one, and both round differently (#2215's guard). static const bool exact_one = [] { const char* v = std::getenv("STRATA_CPU_IQ_ALL_EXACT1"); - return v && v[0] == '1' && v[1] == '\0'; + return v && v[0] == '1' && v[1] == 0 && ggml_cpu_has_avx2() && !ggml_cpu_has_avx512(); }(); // only where ggml's dot runs today (below the #152 multi-token rule): with STRATA_IQ_MT_MIN=1 a lone token keeps the // multi-token kernel, so a token's rows still do not depend on how many tokens share its expert