Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
cpu: IQ2_S in the bit-exact singleton rows; the singleton path only below the #152 rule
Stuart Chapin77ddc2ff147d
diff --git a/src/kernels/cpu/iq_avx2.cpp b/src/kernels/cpu/iq_avx2.cppindex 69bd67526..3e10aa6ee 100644--- a/src/kernels/cpu/iq_avx2.cpp+++ b/src/kernels/cpu/iq_avx2.cpp@@ -466,6 +466,9 @@ void iq256_gu_rows_exact_one(int type, const uint8_t* blob, size_t gu_row, size_} else if (type == 21) {if (iq256_variant() & kIq256Gather) vnni::gu_ggml_one<121>(blob, gu_row, up_off, n, y, ff, r0, r1);else vnni::gu_ggml_one<21>(blob, gu_row, up_off, n, y, ff, r0, r1);+ } else if (type == 22) {+ if (iq256_variant() & kIq256Gather) vnni::gu_ggml_one<122>(blob, gu_row, up_off, n, y, ff, r0, r1);+ else vnni::gu_ggml_one<22>(blob, gu_row, up_off, n, y, ff, r0, r1);}return;}@@ -478,6 +481,9 @@ void iq256_gu_rows_exact_one(int type, const uint8_t* blob, size_t gu_row, size_} else if (type == 21) {if (iq256_variant() & kIq256Gather) plain::gu_ggml_one<121>(blob, gu_row, up_off, n, y, ff, r0, r1);else plain::gu_ggml_one<21>(blob, gu_row, up_off, n, y, ff, r0, r1);+ } else if (type == 22) {+ if (iq256_variant() & kIq256Gather) plain::gu_ggml_one<122>(blob, gu_row, up_off, n, y, ff, r0, r1);+ else plain::gu_ggml_one<22>(blob, gu_row, up_off, n, y, ff, r0, r1);}}diff --git a/src/kernels/cpu/iq_avx2_parity.cpp b/src/kernels/cpu/iq_avx2_parity.cppindex bc5f67bf7..67544c9d0 100644--- a/src/kernels/cpu/iq_avx2_parity.cpp+++ b/src/kernels/cpu/iq_avx2_parity.cpp@@ -248,7 +248,7 @@ int check_gate_up(int type) {const double r_ggml = rel(one_g.data(), ref.data(), one_g.size());std::printf(" %-8s gate rows vs ggml vec_dot: rel %.2e\n", type_name(type), r_ggml);if (!(r_ggml <= 1e-5)) { std::printf(" %-8s MISMATCH against ggml\n", type_name(type)); ++failures; }- if (type == 16 || type == 17 || type == 18 || type == 21) {+ if (type == 16 || type == 17 || type == 18 || type == 21 || type == 22) {size_t different = 0;std::vector<float> exact(R);const ggml_vec_dot_t dot = traits_cpu(type)->vec_dot;@@ -468,7 +468,7 @@ int bench(const std::vector<std::string>& pairs, const std::vector<int>& nts, infor (int t = 0; t < nt; ++t)ddot((int) kFF, &out[t][r], 0, blob + f.down_off + (size_t) r * f.d_row, 0, a.dnp[t], 0, 1);}});- if (gt == 16 || gt == 17 || gt == 18 || gt == 21)+ if (gt == 16 || gt == 17 || gt == 18 || gt == 21 || gt == 22)ms.push_back({"exact1", [&, gt](const uint8_t* blob, int nt) {for (int t = 0; t < nt; ++t)cpu::iq256_gu_rows_exact_one(gt, blob, f.gu_row, f.up_off, (int) kH,diff --git a/src/kernels/cpu/iq_avx2_rows.inl b/src/kernels/cpu/iq_avx2_rows.inlindex 48d4dea01..5489d8eee 100644--- a/src/kernels/cpu/iq_avx2_rows.inl+++ b/src/kernels/cpu/iq_avx2_rows.inl@@ -63,7 +63,7 @@ inline float row_dot_ggml_one(const uint8_t* row, int nblocks, const block_q8_K*const float d = h2f(u16(blk)) * y[i].d;accum = _mm256_fmadd_ps(_mm256_set1_ps(d), _mm256_cvtepi32_ps(_mm256_add_epi32(sums[0], sums[1])), accum);}- if constexpr (TY == 16 || TY == 17) return 0.125f * ggml_hsum8(accum);+ if constexpr (TY == 16 || TY == 17 || TY == 22 || TY == 122) return 0.125f * ggml_hsum8(accum);else if constexpr (TY == 18 || TY == 118) return 0.25f * ggml_hsum8(accum);else return ggml_hsum8(accum);}diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cppindex e869d1ae5..501530025 100644--- a/src/kernels/cpu/native_expert.cpp+++ b/src/kernels/cpu/native_expert.cpp@@ -169,8 +169,10 @@ void native_gu_rows(const NativeFmt& f, const uint8_t* blob, const void* const*const char* v = std::getenv("STRATA_CPU_IQ_ALL_EXACT1");return v && v[0] == '1' && v[1] == '\0';}();- if (exact_one && nt == 1 && avx2 && !cpu_avx512_ok() &&- (f.gu_type == 16 || f.gu_type == 17 || f.gu_type == 18 || f.gu_type == 21)) {+ // 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+ if (exact_one && nt == 1 && nt < native_gu_mt_min(f.gu_type) && avx2 && !cpu_avx512_ok() &&+ (f.gu_type == 16 || f.gu_type == 17 || f.gu_type == 18 || f.gu_type == 21 || f.gu_type == 22)) {static std::once_flag announced;std::call_once(announced, [] { std::fprintf(stderr, "strata ab: GATE=STRATA_CPU_IQ_ALL_EXACT1 active=1\n"); });iq256_gu_rows_exact_one(f.gu_type, blob, f.gu_row, f.up_off, (int) f.n_embd, act[0], ff[0], r0, r1);diff --git a/src/kernels/native_expert_parity.cpp b/src/kernels/native_expert_parity.cppindex 44b8d0b05..bbb1551a8 100644--- a/src/kernels/native_expert_parity.cpp+++ b/src/kernels/native_expert_parity.cpp@@ -100,7 +100,7 @@ int check_blob(const cpu::NativeFmt& f, const std::vector<uint8_t>& blob, int sea[k] = act[k].data();ffp[k] = ff[k].data();}- if ((f.gu_type == 18 || f.gu_type == 21) && cpu::cpu_avx2_ok() && !cpu::cpu_avx512_ok()) {+ if ((f.gu_type == 18 || f.gu_type == 21 || f.gu_type == 22) && cpu::cpu_avx2_ok() && !cpu::cpu_avx512_ok()) {const auto dot = ggml_get_type_traits_cpu((ggml_type) f.gu_type)->vec_dot;size_t differ = 0;std::vector<float> exact((size_t) FF);