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

CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on

Niko1221f8525fa0b052
diff --git a/src/core/expert_source.cpp b/src/core/expert_source.cpp
index e4fccea88..295d0de03 100644
--- a/src/core/expert_source.cpp
+++ b/src/core/expert_source.cpp
@@ -996,9 +996,15 @@ bool FileExpertSource::pin_cache_complement(
const char* v = std::getenv("STRATA_PARTIAL_PIN"); // 0: the A/B arm without it
return v == nullptr || std::atoi(v) != 0;
}();
+ // at most STRATA_PARTIAL_PIN_GIB (default 24): registering 30 GiB of a 40 GiB arena left the driver
+ // unable to page-lock the prompt path's small buffers afterwards (RTX 5070, WDDM)
+ static const uint64_t pin_cap = [] {
+ const char* v = std::getenv("STRATA_PARTIAL_PIN_GIB");
+ return (uint64_t) ((v != nullptr && std::atof(v) > 0 ? std::atof(v) : 24.0) * 1073741824.0);
+ }();
if (budget_bytes > 0 && partial_on) {
const uint64_t step = 2ull << 30;
- for (uint64_t want = bytes; want >= step; want = want > step ? want - step : 0) {
+ for (uint64_t want = std::min(bytes, pin_cap); want >= step; want = want > step ? want - step : 0) {
const uint64_t w = want - want % (64ull << 10);
if (cudaHostRegister(arena, (size_t) w, cudaHostRegisterMapped | cudaHostRegisterPortable) ==
cudaSuccess) {
diff --git a/src/kernels/cpu/native_expert.cpp b/src/kernels/cpu/native_expert.cpp
index 673d4ec96..2ae3947bc 100644
--- a/src/kernels/cpu/native_expert.cpp
+++ b/src/kernels/cpu/native_expert.cpp
@@ -93,7 +93,7 @@ void native_gu_rows(const NativeFmt& f, const uint8_t* blob, const void* const*
// Unsloth UD-Q4_K_XL's Q4_K gate/up: the multi-token kernel is bit-exact against ggml's per-token dot, so it
// runs for every group size (no #152 rule). STRATA_NO_KQ256 falls back to ggml's vec_dot.
static const bool kq = std::getenv("STRATA_NO_KQ256") == nullptr;
- if (kq && f.gu_type == 12) {
+ if (kq && f.gu_type == 12 && nt >= 2) { // one token: ggml's own dot below (the same bits, less overhead)
kq256_gu_rows(f.gu_type, blob, f.gu_row, f.up_off, (int) f.n_embd, act, nt, ff, r0, r1);
return;
}
@@ -128,7 +128,7 @@ void native_down_rows(const NativeFmt& f, const uint8_t* blob, const void* const
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) : 2; }();
static const bool kq = std::getenv("STRATA_NO_KQ256") == nullptr;
- if (kq && (f.d_type == 7 || f.d_type == 8)) { // Q5_1 / Q8_0 down: bit-exact, every group size
+ if (kq && nt >= 2 && (f.d_type == 7 || f.d_type == 8)) { // Q5_1 / Q8_0 down: bit-exact, any group size
kq256_rows(f.d_type, blob + f.down_off, f.d_row, (int) f.n_ff, hq, nt, out, r0, r1);
return;
}