From 5fc49bdcacb345fd7cf5c8b391fb53273514ef7e Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 3 Oct 2026 20:05:31 +0200 Subject: [PATCH] layer split trim: opt-in on HIP too (STRATA_STAGE_TRIM=1, PR #639) The trim was on by default in the HIP builds. It now waits, as on CUDA, for the PR author's re-run of the release branch on his cards; the default flips after that. --layer-split auto and one GPU were never affected. --- docs/MULTI_GPU.md | 4 ++-- src/program/generate.cpp | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/docs/MULTI_GPU.md b/docs/MULTI_GPU.md index 5925214e..d98f8e19 100644 --- a/docs/MULTI_GPU.md +++ b/docs/MULTI_GPU.md @@ -83,8 +83,8 @@ everything - the bit-exact check of the hand-off, not a speed mode. **Each card loads only its own layers' dense weights** (0.1.39, PR #639) with explicit split points (`--layer-split 27`, not `auto`): every card used to keep a full copy (~3.4 GB for the Coder) though its stage reads only its own layers, and the VRAM it frees goes to that card's expert cache (2x MI50 16 GB, Coder: 8,819 -> 10,626 experts in -VRAM, decode 39.2 -> 41.7 tok/s). On by default in the AMD (HIP) builds, `STRATA_STAGE_TRIM=0` keeps the full copies; -on NVIDIA it is opt-in with `STRATA_STAGE_TRIM=1` until it has been run on NVIDIA cards (please report how it goes). +VRAM, decode 39.2 -> 41.7 tok/s). Opt-in for now, on AMD and NVIDIA alike: `STRATA_STAGE_TRIM=1` (please report how +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. diff --git a/src/program/generate.cpp b/src/program/generate.cpp index f6d98b96..b9a4440c 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -2146,18 +2146,12 @@ int main(int argc, char** argv) { } // Layer split with explicit split points: every GPU holds only the dense weights of ITS layers (the PLE tensors // stay everywhere). Without this each card keeps a full copy (~3.4 GB for the Coder) that its stage never - // reads - VRAM the expert cache wants. On by default in the AMD (HIP) builds, where it was measured (PR #639, - // 2x MI50); STRATA_STAGE_TRIM=0 keeps the full copies there. The CUDA build keeps the full copies unless - // STRATA_STAGE_TRIM=1, until it has run on NVIDIA cards. + // reads - VRAM the expert cache wants. Opt-in, STRATA_STAGE_TRIM=1, on HIP and CUDA alike: measured on 2x MI50 + // (PR #639), and the default waits for its author's re-run of the release branch on his cards. const std::set skip_base = skip; const bool stage_trim = multi_gpu && !split_auto && !split_at.empty() && [] { const char* v = std::getenv("STRATA_STAGE_TRIM"); - if (v != nullptr && v[0] != 0) return std::string(v) != "0"; -#if defined(STRATA_USE_HIP) || defined(STRATA_HIP_GFX906) - return true; -#else - return false; -#endif + return v != nullptr && v[0] != 0 && std::string(v) != "0"; }(); // keep_routers: CUDA0 with --mmap-experts keeps every layer's router (ffn_gate_inp, ~2.5 MiB a layer) - the file // tier's routing-aware prefetch (RouterLookahead, below) copies all of them from CUDA0's arena, and would