Merge f-ling32-replan-cap (f4eb3bada1): the Windows Ling replan keeps the RAM pin cap

Post-freeze fix #6. On Windows, when --mtp-auto decides not to load the sidecar, the engine replanned from the plain options and lost the RAM pin cap of the first
plan, so it pinned 16.9 GiB on a 32 GB PC and every device allocation after the tier store failed (B70 Load: "cudaMemset: SYCL runtime error"; the same code path
serves Windows NVIDIA). The replan now starts from the capped plan options with the sidecar cleared. engine/src/ling32/ling32_main.cpp only, behaviour inside
_WIN32; Linux, macOS and aarch64 compile the same code as before.
This commit is contained in:
Niko1221 committed 2026-12-03 12:21:44 +01:00
commit 8580da079d
1 file changed
+12
+12
View File
@@ -800,6 +800,7 @@ int cmd_run(const RunOpts& o_in) {
}
uint64_t win_pin_cap = 0; // Windows with a discrete card: how much RAM the planner may give the pinned RAM tier
#if defined(_WIN32)
RunOpts plan_opts = o; // the options of the first plan (the RAM budget cut to the pin cap below): the replan after --mtp-auto dropped the sidecar starts from this copy, not from the plain options
if (!win_igpu && o.tier != "vram") {
// The driver page-locks only part of the system RAM for the GPU (it stops at about half of it, and the commit limit is RAM + page file): a 34 GiB cudaHostAlloc failed with "out of memory" on a
// 63 GB PC with 43 GB free (the planner had offered all free RAM minus 6 GiB). Plan the RAM tier within the free RAM minus 8 GiB for Windows and at most half of the system RAM minus 0.5 GiB
@@ -817,7 +818,9 @@ int cmd_run(const RunOpts& o_in) {
#endif
if (!o.map_experts && (!integrated || asked || (win_igpu && o.tier != "vram"))) {
std::string perr;
#if !defined(_WIN32)
RunOpts plan_opts = o;
#endif
if (win_igpu && o.tier != "vram" && o.ram_budget_gib <= 0 && win_ram_budget > 0) plan_opts.ram_budget_gib = win_ram_budget / double(1ull << 30);
if (win_pin_cap > 0) {
const double cap_gib = win_pin_cap / double(1ull << 30);
@@ -845,7 +848,16 @@ int cmd_run(const RunOpts& o_in) {
o.spec_mtp = false;
o.spec = false; // the speculative loop is the drafter's: a plain run follows
if (tiered) { // the plan counted the sidecar's bytes: plan again without it
#if defined(_WIN32)
// the first plan cut the RAM tier to the Windows pin cap (the GPU driver pins no more than about half of the system RAM); planning again from the plain options dropped the cap: a B70 PC pinned 16.9 GiB
// of 32 GB RAM and every device allocation after the tier store failed with UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY (Load: "cudaMemset: SYCL runtime error"). Replan from the capped copy, the sidecar removed
RunOpts po = plan_opts;
po.mtp_file.clear();
po.spec_mtp = false;
po.spec = false;
#else
RunOpts po = o;
#endif
std::string perr2;
if (make_plan(f, po, plan_vram, plan_ram, plan, rt, perr2)) { std::printf("%s\n", plan.describe().c_str()); tiered = plan.mode != TierMode::A; }
}