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 experts: the multi-token kernels from one token on (#152): a token's expert rows round the same whatever its verify window held, so output no longer depends on the drafts; STRATA_IQ_MT_MIN=2 restores the old rule; native_expert_parity checks the width invariance bit for bit
Niko1221fee66e89cc09
diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cppindex b52544563..2beb344cc 100644--- a/src/kernels/cpu/native_expert.cpp+++ b/src/kernels/cpu/native_expert.cpp@@ -84,7 +84,11 @@ void native_gu_rows(const NativeFmt& f, const uint8_t* blob, const void* const*// both set (and on a CPU without AVX-512, STRATA_NO_IQ512 changes nothing).static const bool avx512 = cpu_avx512_ok() && std::getenv("STRATA_NO_IQ512") == nullptr;static const bool avx2 = std::getenv("STRATA_NO_IQ256") == nullptr;- if (nt >= 2 && iq512_supported(f.gu_type)) { // one token: ggml-cpu is as fast or faster+ // #152: the multi-token kernels from ONE token on (they were used from two, ggml's vec_dot for one): a token's+ // expert rows then round the same whatever the verify window grouped with it, so the output no longer depends+ // on how many drafts a window held. STRATA_IQ_MT_MIN=2 restores the old rule (A/B).+ static const int mt_min = [] { const char* e = std::getenv("STRATA_IQ_MT_MIN"); return e ? std::atoi(e) : 1; }();+ if (nt >= mt_min && iq512_supported(f.gu_type)) {if (avx512) {iq512_gu_rows(f.gu_type, blob, f.gu_row, f.up_off, (int) f.n_embd, act, nt, ff, r0, r1);return;@@ -113,7 +117,8 @@ void native_down_rows(const NativeFmt& f, const uint8_t* blob, const void* const// IQ4_NL down rows: the AVX-2 multi-token kernel decodes the nibbles and absolutises the weights once per// block instead of once per token; ggml-cpu's dot is single-token. STRATA_NO_IQ4NL falls back to it.static const bool iq4nl_mt = std::getenv("STRATA_NO_IQ4NL") == nullptr;- if (nt >= 2 && f.d_type == 20 && iq4nl_mt) {+ static const int mt_min = [] { const char* e = std::getenv("STRATA_IQ_MT_MIN"); return e ? std::atoi(e) : 1; }();+ if (nt >= mt_min && f.d_type == 20 && iq4nl_mt) { // #152: from one token on, as the gate/up rowsiq4nl256_down_rows(blob + f.down_off, f.d_row, (int) f.n_ff, hq, nt, out, r0, r1);return;}diff --git a/src/kernels/native_expert_parity.cpp b/src/kernels/native_expert_parity.cppindex 496cf5ea7..15064da8e 100644--- a/src/kernels/native_expert_parity.cpp+++ b/src/kernels/native_expert_parity.cpp@@ -22,6 +22,7 @@#include <cmath>#include <cstdio>#include <cstdlib>+#include <cstring>#include <random>#include <string>#include <vector>@@ -163,6 +164,27 @@ int main(int argc, char** argv) {op[k] = got_c.data() + k * H;}cpu::native_down_rows(f, blob.data(), hp, NT, op, 0, (int) H);+ { // #152: a token's rows must not depend on how many tokens share the call - each token alone (nt = 1)+ // against its row of the NT-token call above, bit for bit, gate/up and down+ size_t gu_diff = 0, dn_diff = 0;+ std::vector<float> one_ff(FF), one_out(H);+ // the NT-token gate/up rows again: the throughput loops above overwrote ff with other kernels' rows+ for (int k = 0; k < NT; ++k) ffp[k] = ff[k].data();+ cpu::native_gu_rows(f, blob.data(), a, NT, ffp, 0, (int) FF);+ for (int k = 0; k < NT; ++k) {+ const void* a1[1] = {a[k]};+ float* f1[1] = {one_ff.data()};+ cpu::native_gu_rows(f, blob.data(), a1, 1, f1, 0, (int) FF);+ for (int64_t r = 0; r < FF; ++r) gu_diff += std::memcmp(&one_ff[r], &ff[k][r], 4) != 0;+ const void* h1[1] = {hp[k]};+ float* o1[1] = {one_out.data()};+ cpu::native_down_rows(f, blob.data(), h1, 1, o1, 0, (int) H);+ for (int64_t r = 0; r < H; ++r) dn_diff += std::memcmp(&one_out[r], &got_c[k * H + r], 4) != 0;+ }+ std::printf(" width invariance (1 vs %d tokens): gate/up %zu, down %zu rows differ\n", NT,+ gu_diff, dn_diff);+ if (gu_diff || dn_diff) ++failures;+ }if (f.d_type == 42) {// (b2) the GGUF-layout Q2_0 kernel the pool uses for Q2_0 down projections - the AVX-512 one// where the CPU has it, the AVX-2 one (q2_avx2.cpp) where it does not. Calling the AVX-512