ling32: Windows planner headroom (STRATA_L32_WDDM_HEADROOM_MB, default 1536) and the first make_room checks are printed

- Windows (WDDM), discrete card, any tier except --tier vram: the planner plans against the card's free memory minus 1.5 GiB.  A 12 GB RTX 5070 was planned to 10.52 of 10.53 GiB and showed "GPU memory 11.54 / 11.91 GiB used" at ready; WDDM pages allocations beyond the dedicated memory into shared system memory instead of failing them, so the prefill scratch, the graphs and the desktop's own use lived in shared memory and a 33,784-token prompt took 620 s instead of 100 s (regrow off or a 9.6 GiB budget: 100 s / 116 s).  0 switches the headroom off.  A card that only just fits tier A may now plan tier B; HIP and the integrated GPUs are not touched.
- make_room prints its first four checks (allocations of 8 MiB and more: size, card free / total as cudaMemGetInfo gives them, margin, whether it released) and every check with STRATA_L32_REGROW_TRACE=1, so a log shows what the driver reports.
This commit is contained in:
Niko1221 committed 2026-12-03 07:09:04 +01:00
1 parent cd3fbe4c60
commit defc0ba4c8
2 files changed
+18 -2

No files matched your search

+6 -2
View File
@@ -489,11 +489,15 @@ struct Ling32Engine::StageCtx {
void make_room(size_t bytes) {
if (!E.provider_ || E.opt.kv_init_ctx <= 0) return;
static const size_t margin = [] { const char* e = std::getenv("STRATA_L32_ALLOC_MARGIN_MB"); return static_cast<size_t>(e && e[0] ? std::max(0, std::atoi(e)) : 256) * 1048576ull; }();
static const bool trace = [] { const char* f = std::getenv("STRATA_L32_REGROW_TRACE"); return f && f[0] == '1'; }();
static int n_print = 0; // the first checks of a process are always printed (one short line each, at most 4): the numbers cudaMemGetInfo gives are what decides whether the pool makes room
for (int t = 0; t < 64; ++t) {
size_t fr = 0, tot = 0;
if (cudaMemGetInfo(&fr, &tot) != cudaSuccess) { (void)cudaGetLastError(); return; }
if (fr >= bytes + margin) return;
if (E.provider_->release_bytes(bytes + margin - fr) == 0) return;
const bool low = fr < bytes + margin;
if ((trace && bytes >= (8u << 20)) || (n_print < 4 && bytes >= (8u << 20))) { ++n_print; std::printf("[make_room] alloc %.1f MiB, card free %.0f of %.0f MiB, margin %.0f MiB: %s\n", bytes / 1048576.0, fr / 1048576.0, tot / 1048576.0, margin / 1048576.0, low ? "releasing pool chunks" : "room"); }
if (!low) return;
if (E.provider_->release_bytes(bytes + margin - fr) == 0) { if (trace) std::printf("[make_room] the pool has nothing more to give\n"); return; }
}
}
+12
View File
@@ -753,6 +753,18 @@ int cmd_run(const RunOpts& o_in) {
#endif
igpu_zero_copy = win_igpu && o.tier != "vram";
uint64_t plan_vram = fr, plan_ram = host_ram_available(), win_ram_budget = 0;
#if defined(_WIN32) && !defined(STRATA_USE_HIP)
if (!integrated && o.tier != "vram") {
// Windows (WDDM) with a discrete card: the planner filled the card to the last 0.4 GiB (a 12 GB RTX 5070: "GPU memory 11.54 / 11.91 GiB used" at ready), and WDDM does not fail an allocation
// beyond the dedicated memory, it pages it into shared system memory: the prefill scratch, the graphs and the desktop's own use ended up there and a 33,784-token prompt took 620 s instead of 100 s.
// Plan against the free memory minus a headroom (STRATA_L32_WDDM_HEADROOM_MB, default 1536; 0 switches it off).
static const uint64_t headroom = [] { const char* e = std::getenv("STRATA_L32_WDDM_HEADROOM_MB"); return static_cast<uint64_t>(e && e[0] ? std::max(0, std::atoi(e)) : 1536) << 20; }();
if (headroom > 0) {
plan_vram = fr > headroom ? fr - headroom : 0;
std::printf("Windows: the card is planned within %.2f of its %.2f GiB free (%.2f GiB headroom against WDDM paging)\n", plan_vram / 1073741824.0, fr / 1073741824.0, headroom / 1073741824.0);
}
}
#endif
if (win_igpu && o.tier != "vram") {
constexpr uint64_t kGiBu = 1ull << 30;
l32::trace("main: probing the GPU allocation cap");