From 5c4105c0736471f9ddd5d406e29abd2d74d3a9bd Mon Sep 17 00:00:00 2001 From: Francesco Albano <119073350+Hardin22@users.noreply.github.com> Date: Mon, 5 Oct 2026 00:19:22 +0200 Subject: [PATCH] Layer split: --vram-reserve-later-mib, a separate reserve for the later cards --vram-reserve-mib is every card's reserve, but the card that drives the monitors needs more headroom than one that drives none: one value has to fit the display card, and the other cards then keep that headroom for nothing. --vram-reserve-later-mib N is the reserve of every card after the first (default: --vram-reserve-mib's value), in the split search and in each later card's cache sizing. RTX 4060 Ti (no display, layers 0-19) + RTX 5080 (display, 20-47), Swift 1.5 IQ3_XXS at 160K: --vram-reserve-mib 1000 gives the 4060 Ti's cache 4551 slots; --vram-reserve-mib 300 --vram-reserve-later-mib 1800 gives it 4867, and the 5080 keeps 1.3 GB free with everything loaded. --- docs/MULTI_GPU.md | 4 ++++ src/program/generate.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/MULTI_GPU.md b/docs/MULTI_GPU.md index 1270125b..abf2f5a0 100644 --- a/docs/MULTI_GPU.md +++ b/docs/MULTI_GPU.md @@ -102,6 +102,10 @@ it goes). A card holding more experts can change which experts run on the GPU, so the output can differ slightly from a run without it. +**A separate VRAM reserve for the later cards:** `--vram-reserve-later-mib N` (default: `--vram-reserve-mib`'s value). +The card that drives the monitors needs more headroom than one that drives none; with the display on the last card, +`--vram-reserve-mib 300 --vram-reserve-later-mib 1800` gives the first card's cache that VRAM. + **auto** tries every placement (all of them for two or three cards; proportional to the free VRAM beyond that) and keeps the one whose caches would hold the most of the expert profile, hottest pairs weighted most; ties go to the placement that leaves the fullest card the most room. The startup log prints the choice: diff --git a/src/program/generate.cpp b/src/program/generate.cpp index c676719a..ce5d1b0b 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -427,6 +427,9 @@ struct Options { /// `VRAM ` command can give part of it back to other programs and take it again. Off: one cudaMalloc. bool vram_elastic = false; int64_t vram_segment_mib = 512; + /// `--vram-reserve-later-mib N`: the reserve on a layer split's later cards (default: the same as the first). + /// A card that drives no display needs less than the one the monitors are on. + int vram_reserve_later_mib = -1; /// Plan v0.3 P5: batched prompt processing in chunks of this many tokens (0 = the token path). int64_t prefill_chunk = 0; /// `--prefill auto`: the largest chunk (up to 8192) whose buffers the expert cache can lend. Every expert a chunk @@ -1376,6 +1379,8 @@ int main(int argc, char** argv) { else if (a == "--expert-cache-remote-placement") o.expert_cache_remote_placement = next("--expert-cache-remote-placement"); else if (a == "--vram-reserve-mib") { o.vram_reserve_mib = std::atoi(next("--vram-reserve-mib")); o.vram_reserve_given = true; } + else if (a == "--vram-reserve-later-mib") + o.vram_reserve_later_mib = std::atoi(next("--vram-reserve-later-mib")); else if (a == "--prefill") { const std::string v = next("--prefill"); o.prefill_auto = v == "auto" || v.rfind("auto:", 0) == 0; @@ -2743,7 +2748,9 @@ int main(int argc, char** argv) { std::fprintf(stderr, "strata generate: layer split: CUDA%d free memory: %s\n", dev < 0 ? 0 : dev, cudaGetErrorString(e)); const int64_t pf = search && split_own_auto && !place_with_reserve ? 0 : split_pf_mib; - const int64_t reserve = ((int64_t) o.vram_reserve_mib + pf + (later ? kWindowMib : 0) + + const int64_t base_reserve = + later && o.vram_reserve_later_mib >= 0 ? o.vram_reserve_later_mib : o.vram_reserve_mib; + const int64_t reserve = (base_reserve + pf + (later ? kWindowMib : 0) + (drafter ? kDrafterMib : 0)) << 20; return std::max((int64_t) fb - reserve, 0); };