STRATA_ROUTE_TAIL_SKIP=7 on by default on CUDA serve (=0 off): single GPU and layer splits; not with every expert in VRAM, --batch slots, a peer or helper GPU, HIP; one start-up line names the opt-out

This commit is contained in:
Niko1221 committed 2026-10-09 22:52:22 +02:00
1 parent 8b0c241ca0
commit b4e3407bd2
3 files changed
+42 -6

No files matched your search

+19 -6
View File
@@ -3370,6 +3370,23 @@ constexpr int64_t kMaxWindowEntries = 128;
static_assert(strata::kernels::cpu::MAXT * 10 <= kMaxWindowEntries, "a verify window's entries overflow the tables");
} // namespace
namespace {
// STRATA_ROUTE_TAIL_SKIP: the rank from which a missed expert that every token of the window routes that low is skipped. An
// explicit environment value is read once; the serve start-up (generate.cpp) sets the CUDA default where it applies.
std::atomic<int> g_tail_skip_rank{-1}; // -1: not resolved yet
} // namespace
int tail_skip_rank() {
int r = g_tail_skip_rank.load(std::memory_order_relaxed);
if (r < 0) {
const char* v = std::getenv("STRATA_ROUTE_TAIL_SKIP");
r = v != nullptr ? std::atoi(v) : 0;
r = r > 0 && r < 10 ? r : 0;
g_tail_skip_rank.store(r, std::memory_order_relaxed);
}
return r;
}
void set_tail_skip_rank(int r) { g_tail_skip_rank.store(r > 0 && r < 10 ? r : 0, std::memory_order_relaxed); }
void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32_t* ids, int64_t n_tok, int64_t k,
float* out) {
using namespace strata::kernels::cpu;
@@ -3431,14 +3448,10 @@ 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
// STRATA_ROUTE_TAIL_SKIP=R (default 7 on CUDA serve, =0 off; 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;
}();
const int tail_rank = tail_skip_rank();
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) {