Files
strata/tests/prefill/share_rules_test.cpp
T
Niko1221 eaaa237e85 CPU prefill share: not armed by default when the cache holds every expert (#1595)
With every expert resident nothing streams, so the share has nothing to take and
only moves the staged-chunk limit (+4.8% at 1,000 tokens on a V100). An explicit
STRATA_PREFILL_CPU_SHARE is honoured as before; the default is unchanged where
experts are not all resident.
2026-10-09 03:31:47 +02:00

23 lines
1.1 KiB
C++

// The default CPU share is not armed when every expert is resident (#1595): no GPU, no model.
#include <cstdio>
#include "strata/prefill/share_rules.hpp"
using strata::prefill::share_rules::default_share_has_work;
static int failed = 0;
#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)
int main() {
const long long pairs = 48 * 512;
CHECK(default_share_has_work(pairs - 1, pairs)); // one expert streams: the share has something to take
CHECK(default_share_has_work(1500, pairs)); // a 12 GB card: most of them stream
CHECK(!default_share_has_work(pairs, pairs)); // every expert resident: nothing to take
CHECK(!default_share_has_work(pairs + 100, pairs)); // a cache with spare slots
CHECK(default_share_has_work(0, pairs)); // empty cache
CHECK(default_share_has_work(100000, 0)); // total unknown: keep today's behaviour
static_assert(!default_share_has_work(10, 10), "constexpr");
if (failed == 0) std::printf("share_rules_test: ok\n");
return failed ? 1 : 0;
}