Files
strata/src/core/window_evict_test.cpp
T
Niko1221 a8c1d4b7f8 verify: a window graph that does not fit frees the graphs of other window sizes instead of ending the engine (#3702)
On a layer split the later card is left with a few dozen MiB after loading, and each single-request window size is
captured the first time it is used (68, 64, 58, 52 and then 10 MiB free in the report); when one capture's
cudaGraphInstantiate ran out of memory, instantiate_evicting could only free graphs of batch slot layouts, a
single-request run has none, and "verify: instantiate: out of memory" ended the engine.

Now, after the batch layouts, a single-request window's capture frees the graph of the largest other window size (never the
one being captured or a prelaunched one; pick_window_victim) and instantiates again, and says so once: the freed size is
captured again when it is next used. capture_all keeps every size at once and is excluded. Only a failed instantiate does
anything new; with enough VRAM nothing changes.

window_evict_test (CPU, header-only) covers the choice. The real gate needs a model on a 2-GPU split with a thin later card
(listed in the triage file); not changed here: the later-stage reserve of the split search (kWindowMib), which is a default
placement change.
2026-10-26 18:51:29 +01:00

34 lines
1.3 KiB
C++

// pick_window_victim (include/strata/core/window_evict.hpp): CPU only (#3702).
#include "strata/core/window_evict.hpp"
#include <cstdio>
#include <cstdlib>
using strata::core::pick_window_victim;
namespace {
int checks = 0;
void check(bool ok, const char* label) {
++checks;
if (!ok) { std::fprintf(stderr, "FAIL: %s\n", label); std::exit(1); }
}
} // namespace
int main() {
bool have[9] = {};
check(pick_window_victim(have, 8, 5, 0) == 0, "nothing captured: nothing to free");
have[2] = have[3] = have[5] = true;
check(pick_window_victim(have, 8, 6, 0) == 5, "the largest captured size goes first");
check(pick_window_victim(have, 8, 5, 0) == 3, "never the size being captured");
check(pick_window_victim(have, 8, 5, 3) == 2, "never the prelaunched size");
check(pick_window_victim(have, 4, 1, 0) == 3, "sizes above max_t are not considered");
have[5] = false;
check(pick_window_victim(have, 8, 3, 2) == 0, "only the kept and the pinned sizes are left: nothing");
have[2] = have[3] = false;
have[1] = true;
check(pick_window_victim(have, 8, 7, 0) == 1, "size 1 can be freed");
check(pick_window_victim(have, 8, 1, 0) == 0, "size 1 kept");
std::printf("window_evict_test: %d checks passed\n", checks);
return 0;
}