ling32: on Windows the replan after --mtp-auto dropped the sidecar starts from the capped options of the first plan

On Windows the first plan cuts the RAM tier to what the GPU driver can pin (about half of the system RAM, "the RAM tier is planned within 15.3 GiB"), in a copy of the options (plan_opts). When --mtp-auto then decides that the sidecar does not pay, the plan was made again from the plain options and the cap was lost: a 32 GB RAM B70 PC pinned 16.9 GiB and every device allocation after the tier store failed with UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, then DEVICE_LOST ("strata-ling32: cudaMemset: SYCL runtime error" at Load). Without the MTP flags there is no second plan and the cap held (12.4 to 13.4 GiB pinned: Load fine).

The replan now starts from plan_opts (hoisted next to win_pin_cap) with only the sidecar removed (mtp_file cleared, spec off), so it keeps the RAM budget of the first plan. The change is inside _WIN32: Linux, macOS and aarch64 compile the same code as before.
This commit is contained in:
Niko1221 committed 2026-12-03 11:22:30 +01:00
1 parent 3070d6d4a0
commit f4eb3bada1
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; }
}