Skip to content

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++

#152 as an opt-in (the owner's choice): STRATA_IQ_MT_MIN=1 makes CPU expert rounding independent of the drafting; the default stays 0.1.29's rule (IQ3_S decoded 1-3% slower with it on); docs; the width test runs the opt-in

Niko122131ad9627279c
diff --git a/docs/DETAILS.md b/docs/DETAILS.md
index e91c9e3c0..002a4a006 100644
--- a/docs/DETAILS.md
+++ b/docs/DETAILS.md
@@ -70,6 +70,14 @@ VRAM. RTX 3090, the Coder at 198K context: 99 instead of 85 tokens/s output, the
slower. It does not stream its KV cache (KV streaming is on by default from 64K), so it pays off mostly on large
cards at long contexts.
+**Reproducible greedy output (0.1.30, opt-in, `STRATA_IQ_MT_MIN=1`):** with the IQ models, the CPU computes an
+expert for one token with ggml's dot product and for several tokens with Strata's multi-token kernels, which round
+slightly differently. How many tokens share an expert depends on the drafts in a verify window, so the same prompt
+at temperature 0 can end in a different (equally good) answer when the drafting, the cache state or a resumed
+conversation differ (issue #152). `STRATA_IQ_MT_MIN=1` (in the config's `env`) uses the multi-token kernels for
+every group: the answer then no longer depends on the drafting. Measured on a Ryzen 7600 (AVX-512): IQ3_S decode
+-1..-3%, the other models the same; the default stays the fastest rule.
+
**The draft layer's tokens (0.1.27, `--draft-vocab`):** the MTP draft layer can only propose tokens from a subset
of the vocabulary (`mtp/rt/draft_vocab.bin`). Since 0.1.27 the subset includes every Chinese, Japanese and Korean
token (106,299 ids), so answers in those languages are 15-38% faster (Q2_0, RTX 5070). Its head takes ~180 MiB of
diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cpp
index 2beb344cc..d326b410b 100644
--- a/src/kernels/cpu/native_expert.cpp
+++ b/src/kernels/cpu/native_expert.cpp
@@ -84,10 +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;
- // #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; }();
+ // #152: from how many tokens the multi-token kernels run (ggml's vec_dot below that). The default 2 is the
+ // measured-fastest rule, but a token's expert rows then round differently alone than in a group, so greedy output
+ // can depend on how many drafts a verify window held. STRATA_IQ_MT_MIN=1 (opt-in, 0.1.30) uses the multi-token
+ // kernels for every group: output independent of the drafting, at a measured -1..-3% decode on IQ3_S (AVX-512).
+ static const int mt_min = [] { const char* e = std::getenv("STRATA_IQ_MT_MIN"); return e ? std::atoi(e) : 2; }();
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);
@@ -117,8 +118,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;
- 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 rows
+ static const int mt_min = [] { const char* e = std::getenv("STRATA_IQ_MT_MIN"); return e ? std::atoi(e) : 2; }();
+ if (nt >= mt_min && f.d_type == 20 && iq4nl_mt) { // #152: the same rule as the gate/up rows
iq4nl256_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.cpp
index 15064da8e..98c533f60 100644
--- a/src/kernels/native_expert_parity.cpp
+++ b/src/kernels/native_expert_parity.cpp
@@ -38,6 +38,14 @@ static double rel(const std::vector<float>& a, const std::vector<float>& b) {
int main(int argc, char** argv) {
setvbuf(stdout, nullptr, _IONBF, 0); // keep the trail on a crash
if (argc < 2) { std::fprintf(stderr, "usage: native_expert_parity <shard1.gguf> [layer ...]\n"); return 2; }
+ // #152's width check tests the opt-in rule (the multi-token kernels from one token on)
+ if (std::getenv("STRATA_IQ_MT_MIN") == nullptr) {
+#ifdef _WIN32
+ _putenv_s("STRATA_IQ_MT_MIN", "1");
+#else
+ setenv("STRATA_IQ_MT_MIN", "1", 1);
+#endif
+ }
strata::GgufFile gguf(argv[1]);
std::vector<int> layers;
for (int i = 2; i < argc; ++i) layers.push_back(std::atoi(argv[i]));