diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cpp index 22c9579c..0903761e 100644 --- a/src/kernels/cpu/native_expert.cpp +++ b/src/kernels/cpu/native_expert.cpp @@ -98,9 +98,11 @@ void native_gu_rows(const NativeFmt& f, const uint8_t* blob, const void* const* kq256_gu_rows(f.gu_type, blob, f.gu_row, f.up_off, (int) f.n_embd, act, nt, ff, r0, r1); return; } - if (nt >= mt_min && (iq512_supported(f.gu_type) || iq256_supported(f.gu_type))) { - // each kernel only for the formats it implements: IQ4_XS has an AVX-2 one and no AVX-512 one, and - // falling through an empty switch would leave ff unwritten instead of falling back to ggml-cpu. + // A format with only an AVX-2 kernel (IQ4_XS, #415) takes it on AVX-2 CPUs only: an AVX-512 CPU keeps ggml-cpu for + // it, as before (its rows would round differently). Each kernel only for the formats it implements: falling + // through an empty switch would leave ff unwritten instead of falling back to ggml-cpu. + static const bool cpu512 = cpu_avx512_ok(); + if (nt >= mt_min && (iq512_supported(f.gu_type) || (!cpu512 && iq256_supported(f.gu_type)))) { if (avx512 && iq512_supported(f.gu_type)) { iq512_gu_rows(f.gu_type, blob, f.gu_row, f.up_off, (int) f.n_embd, act, nt, ff, r0, r1); return; diff --git a/src/kernels/native_expert_parity.cpp b/src/kernels/native_expert_parity.cpp index e0868100..0183f01b 100644 --- a/src/kernels/native_expert_parity.cpp +++ b/src/kernels/native_expert_parity.cpp @@ -145,8 +145,9 @@ int check_blob(const cpu::NativeFmt& f, const std::vector& blob, int se tag, us1, 2.0 * f.up_off / us1 / 1e3, usg, 2.0 * f.up_off / usg / 1e3); std::printf(" gate+up %d tokens one thread: %s %.0f us vs ggml %d x %.0f us\n", NT, tag, usn, NT, usg); }; - if (cpu::cpu_avx512_ok()) check("avx512", true); // guarded: the binary runs on AVX-2 CPUs too - check("avx2", false); + // guarded: the binary runs on AVX-2 CPUs too, and IQ4_XS has no AVX-512 kernel (an empty switch) + if (cpu::cpu_avx512_ok() && cpu::iq512_supported(f.gu_type)) check("avx512", true); + if (cpu::iq256_supported(f.gu_type)) check("avx2", false); } for (int k = 0; k < NT; ++k) { cpu::native_quant_h(f, ff[k].data(), hq[k].data());