From 03006f62edabb8a368df8ad8247d8e506c8a7e57 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Thu, 3 Dec 2026 03:08:42 +0100 Subject: [PATCH] ling32: the loader reserve counts decode_rows of scratch when a tiered run has scratch regrow on (an 8 GB card could not start at chunk 2048) The loader refuses to start when the free card memory is below trunk + reserve_bytes, and the reserve counted the chunk's logits buffer (chunk x 157,184 x 4 B = 1.3 GiB at 2048) plus its share of the latent cache. With scratch regrow in a tiered run only decode_rows rows of scratch stay resident (the chunk-sized set is allocated by the first prefill, the store gives pool chunks for it), so the reserve counts min(chunk, decode_rows) rows there. Every other run (tier A, regrow off, no lazy KV) computes the same expression as before: reserve_rows = o.chunk. --- engine/src/ling32/ling32_main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/src/ling32/ling32_main.cpp b/engine/src/ling32/ling32_main.cpp index 2ae04428cc..074813c18e 100644 --- a/engine/src/ling32/ling32_main.cpp +++ b/engine/src/ling32/ling32_main.cpp @@ -848,7 +848,10 @@ int cmd_run(const RunOpts& o_in) { lo.map_experts = o.map_experts; lo.lock_mapped = o.lock_mapped; lo.device = o.device; - lo.reserve_bytes = (1ull << 30) + static_cast(o.ctx) * 576 * 2 * 7 + static_cast(o.chunk) * 157184 * 4 + (700ull << 20); + // the card must hold the trunk and this reserve; with scratch regrow in a tiered run the always-resident scratch is decode_rows rows, a prompt takes pool slots for the big chunk scratch only while it is prefilled + // (a card of 8 GB could not start at chunk 2048: the logits buffer of the chunk alone is 1.3 GiB) + const int reserve_rows = (tiered && plan.kv_rows > 0 && o.regrow()) ? std::min(o.chunk, o.decode_rows_opt) : o.chunk; + lo.reserve_bytes = (1ull << 30) + static_cast(o.ctx) * 576 * 2 * 7 + static_cast(reserve_rows) * 157184 * 4 + (700ull << 20); if (!o.vis.file.empty() && (o.vis.backend == "gpu" || (o.vis.backend == "auto" && vision_default_backend(vision_gpu_total_bytes(o.device))[0] == 'g'))) lo.reserve_bytes += 1600ull << 20; // the GPU picture encoder: ~830 MiB of weights plus the activations of one picture const double t0 = now_s();