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

native experts: IQ3_S one-token AVX-2 kernel is opt-in (STRATA_IQ3S_MT1=1); the default keeps 0.1.39's rounding

Niko1221aaf99d30747b
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a770e656..26e42590d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1139,6 +1139,7 @@ if(STRATA_NATIVE_EXPERTS)
target_link_libraries(iq_avx2_parity PRIVATE strata_kernels_cpu)
if(STRATA_BUILD_TESTS)
add_test(NAME iq_avx2_parity COMMAND iq_avx2_parity)
+ add_test(NAME iq_avx2_parity_iq3s_mt1 COMMAND ${CMAKE_COMMAND} -E env STRATA_IQ3S_MT1=1 $<TARGET_FILE:iq_avx2_parity>)
endif()
set(_strata_mmq_types q2_0 iq2_xxs iq2_xs iq2_s iq3_xxs iq3_s iq4_nl iq4_xs q8_0)
# #296: OrcaRouter Q4_K_S's Q5_0 experts (Q4_K and Q5_1 come with STRATA_MMQ_KQUANTS on CUDA, S5's branch)
diff --git a/docs/DETAILS.md b/docs/DETAILS.md
index a04717566..f53b19ad6 100644
--- a/docs/DETAILS.md
+++ b/docs/DETAILS.md
@@ -91,8 +91,8 @@ at temperature 0 can end in a different (equally good) answer when the drafting,
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. On an Intel CPU of Alder Lake or later
-without AVX-512, where the AVX-2 kernel gathers the IQ3_S grid, IQ3_S takes the multi-token kernel for one token by
-default, because there it is the faster one (`STRATA_IQ_MT_MIN=2` restores ggml's dot). Through the server, two more things carry
+without AVX-512, where the AVX-2 kernel gathers the IQ3_S grid, `STRATA_IQ3S_MT1=1` (opt-in) gives IQ3_S the multi-token
+kernel for one token, which is the faster one there; it changes a lone token's rounding, so it is off by default. Through the server, two more things carry
over from one request to the next (#410): the adaptive tier moves experts between RAM and VRAM (the GPU and the CPU
round an expert differently), and the prompt cache resumes a repeated prompt and reads only its tail through the
decode path. For byte-identical repeats add `--prompt-cache 0 --adapt-swaps 0 --pcie-frac 0` to the engine's args
diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cpp
index 22759ce69..c381ddc5e 100644
--- a/src/kernels/cpu/native_expert.cpp
+++ b/src/kernels/cpu/native_expert.cpp
@@ -89,7 +89,8 @@ int native_gu_mt_min(int gu_type) {
// of the window. So IQ3_S takes it for every group, and those rows no longer depend on the drafting. A machine-
// wide rule, not a per-core one: every core rounds an expert the same. Every probe here is in expert_layout.cpp
// and cpu_avx2_ok() comes first, so no AVX2 code runs before the check. STRATA_IQ_MT_MIN set keeps its rule.
- static const bool iq3s_one = env == nullptr && cpu_avx2_ok() && std::getenv("STRATA_NO_IQ256") == nullptr &&
+ // Opt-in (STRATA_IQ3S_MT1=1): it changes a lone token's IQ3_S rounding on those CPUs, so the default stays 0.1.39's.
+ static const bool iq3s_one = env == nullptr && std::getenv("STRATA_IQ3S_MT1") != nullptr && cpu_avx2_ok() && std::getenv("STRATA_NO_IQ256") == nullptr &&
!cpu_avx512_ok() && iq256_gather_setting() != 0 && cpu_gather_fast();
return iq3s_one && gu_type == 21 ? 1 : mt_min;
}