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.
This commit is contained in:
Niko1221 committed 2026-12-03 03:33:44 +01:00
1 parent de6f7bb0d4
commit 03006f62ed
1 file changed
+4 -1
+4 -1
View File
@@ -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<uint64_t>(o.ctx) * 576 * 2 * 7 + static_cast<uint64_t>(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<uint64_t>(o.ctx) * 576 * 2 * 7 + static_cast<uint64_t>(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();