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++
STRATA_ROUTE_TAIL_SKIP=R: missed experts routed only at rank >= R are neither copied nor computed
LeGeRyChEeSe65268d996121
diff --git a/include/strata/core/expert_source.hpp b/include/strata/core/expert_source.hppindex 336cee6a4..861d9e826 100644--- a/include/strata/core/expert_source.hpp+++ b/include/strata/core/expert_source.hpp@@ -429,6 +429,10 @@ struct ExpertDispatch {/// #588: routed (token, expert) entries the GPU computed from outside its cache in verify windows: read over PCIe/// (--pcie-frac, kind 1) or on another GPU (kind 2). In neither cache_hits nor cache_refused.int64_t offload_entries = 0;+ /// STRATA_ROUTE_TAIL_SKIP=R: entries skipped (a missed expert every token of the window routes only at rank >= R)+ /// and the distinct experts behind them (neither copied nor computed)+ int64_t tail_skipped = 0;+ int64_t tail_experts = 0;double ms_plan = 0, ms_actq = 0, ms_jobs = 0, ms_run = 0; ///< verify-window dispatch sections/// Plan v0.3 P6: decayed routing counts per (layer, expert) during decode (sized by the caller; empty = off),/// which the driver uses to swap the most-routed missing experts into the VRAM tier between rounds.diff --git a/src/core/expert_source.cpp b/src/core/expert_source.cppindex 11dd8c0df..add047d0d 100644--- a/src/core/expert_source.cpp+++ b/src/core/expert_source.cpp@@ -3431,6 +3431,33 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32!(d.peer != nullptr && d.peer->has(d.layers, e)) && !helper_holds(e)) ++nmiss;}}+ // STRATA_ROUTE_TAIL_SKIP=R (opt-in, changes the output): a missed expert that EVERY token of the window routes+ // only at rank >= R (the smallest weights of the top-10) is neither copied nor computed; its contribution is+ // zero, without renormalisation (the others keep the weight the router gave them). Less PCIe and CPU work.+ static const int tail_rank = [] {+ const char* v = std::getenv("STRATA_ROUTE_TAIL_SKIP");+ const int r = v != nullptr ? std::atoi(v) : 0;+ return r > 0 && r < 10 ? r : 0;+ }();+ bool skip_d[kMaxWindowEntries];+ for (int q = 0; q < nd; ++q) skip_d[q] = false;+ if (tail_rank > 0 && d.peer == nullptr && d.remote_count == 0) {+ int minr[kMaxWindowEntries];+ for (int q = 0; q < nd; ++q) minr[q] = 99;+ for (int64_t i = 0; i < n; ++i) {+ int q = 0;+ while (q < nd && distinct[q] != first_of[i]) ++q;+ if (q < nd) minr[q] = std::min(minr[q], (int) (i % k));+ }+ for (int q = 0; q < nd; ++q) {+ const int32_t e = ids[distinct[q]];+ if (e < 0 || e >= d.n_expert || minr[q] < tail_rank) continue;+ if (d.host_res[(size_t) d.layers * (size_t) d.n_expert + (size_t) e] >= 0) continue; // resident+ skip_d[q] = true;+ --nmiss;+ ++d.tail_experts;+ }+ }const bool pcie_ok = d.pcie_num > 0 && d.src->pcie_layer(d.layers);const int m = pcie_ok ? (nmiss * d.pcie_num) >> 8 : 0;int miss_rank = 0, groups = 0, entries = 0, fetches = 0;@@ -3442,6 +3469,11 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32const int32_t e = ids[i0];int kd = -1;unsigned long long ptr = 0;+ if (skip_d[q]) { // STRATA_ROUTE_TAIL_SKIP: neither copied nor computed+ for (int64_t i = i0; i < n; ++i)+ if (first_of[i] == i0) kind[i] = -2;+ continue;+ }if (e >= 0 && e < d.n_expert) {const int32_t slot = d.host_res[(size_t) d.layers * (size_t) d.n_expert + (size_t) e];if (slot >= 0) {@@ -3539,7 +3571,7 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32const bool gpu_zeroes_hits = (d.plan != nullptr && n <= kMaxWindowEntries && n <= d.plan->cap && dec_batch && !device_plan);bool any_cpu = false;for (int64_t i = 0; i < n; ++i)- if (kind[i] < 0) { any_cpu = true; break; }+ if (kind[i] == -1) { any_cpu = true; break; } // -2: skipped (STRATA_ROUTE_TAIL_SKIP), no workconst auto c1 = std::chrono::steady_clock::now();if (any_cpu) {// #578 --remote-expert-opt: a token whose experts all run on a GPU (CUDA0 or a helper) needs no CPU activation@@ -3559,7 +3591,7 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32static thread_local std::vector<int64_t> miss;miss.clear();for (int64_t i = 0; i < n_tok * k; ++i)- if (kind[i] < 0 && ids[i] >= 0 && ids[i] < d.n_expert &&+ if (kind[i] == -1 && ids[i] >= 0 && ids[i] < d.n_expert &&std::find(miss.begin(), miss.end(), (int64_t) ids[i]) == miss.end())miss.push_back(ids[i]);d.src->prefetch(d.layers, miss.data(), (int64_t) miss.size());@@ -3577,6 +3609,11 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32d.fail_expert = e;return;}+ if (kind[i] == -2) { // STRATA_ROUTE_TAIL_SKIP: a skipped tail expert contributes zero+ std::memset(row, 0, (size_t) H * sizeof(float));+ ++d.tail_skipped;+ continue;+ }if (kind[i] >= 0) { // CUDA0, PCIe, or a remote/peer result staged into this row belowif (kind[i] == 0) ++d.cache_hits;else ++d.offload_entries; // #588: PCIe or another GPUdiff --git a/src/program/generate.cpp b/src/program/generate.cppindex d1108091d..591edd862 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -11579,6 +11579,9 @@ int main(int argc, char** argv) {100.0 * (double) req_hits / (double) req_look,(long long) req_hits, (long long) req_look, off);}+ if (drive.d.tail_experts > 0) // STRATA_ROUTE_TAIL_SKIP, cumulative+ std::fprintf(stderr, "strata serve: route tail skip: %lld missed experts skipped (%lld entries) since the "+ "start\n", (long long) drive.d.tail_experts, (long long) drive.d.tail_skipped);// the resident RAM mode, cumulative: experts read from experts.bin since the copy was made (what the plain// mmap mode reads through the OS file cache, from the SSD when the RAM could not keep it)if (src.complement_ready())