From 4a998adf2c4d3d8affe1897d79b8ea7fda10ea46 Mon Sep 17 00:00:00 2001 From: Robert Karl Date: Sun, 11 Oct 2026 11:20:16 -0700 Subject: [PATCH] The VRAM plan: no CUDA-context term in the engine, where the budget is already net of it in.budget_bytes is cudaMemGetInfo's free figure, read after this process's context exists, and the engine subtracted a 300 MiB context on top of it: ~290 (IQ3) / ~160 (Q4) expert slots under table 4.3 (review finding 2). The engine passes 0; vram_plan_test keeps the study's 300 MiB because its budgets are the cards' sizes. Said in vram_plan.hpp's field comment. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr --- include/strata/plan/vram_plan.hpp | 4 +++- src/program/generate.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/strata/plan/vram_plan.hpp b/include/strata/plan/vram_plan.hpp index a229984..3a07efb 100644 --- a/include/strata/plan/vram_plan.hpp +++ b/include/strata/plan/vram_plan.hpp @@ -27,7 +27,9 @@ struct VramPlanInput { uint64_t drafter_bytes = 0; ///< the MTP draft block: dense + experts in VRAM + ring KV + logits uint64_t kv_bytes_per_token = 0; ///< the KV format's bytes per token over every attention layer uint64_t session_bytes = 0; ///< rope table, GDN state, scratch - uint64_t cuda_context_bytes = 0; ///< the driver's own share, ~230 to 300 MiB + uint64_t cuda_context_bytes = 0; ///< the driver's own share, ~230 to 300 MiB, when `budget_bytes` is a card's + ///< size (the study's table); 0 when it is cudaMemGetInfo's free figure, which + ///< is read after the context exists and so is already net of it uint64_t reserve_bytes = 0; ///< --vram-reserve-mib (700 default, 300 on a small card) uint64_t prompt_bytes = 0; ///< the prompt path's chunk buffers; 0 when prefill borrows cache slots int64_t context = 262144; ///< requested diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 391583e..87581e5 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -2203,7 +2203,10 @@ int main(int argc, char** argv) { (uint64_t) g.n_gdn_layers() * ((uint64_t) g.ssm_state_size * g.ssm_v_heads * g.ssm_state_size + (uint64_t) g.ssm_conv_channels * (g.ssm_d_conv - 1)) * 4 + (36ull << 20); - in.cuda_context_bytes = 300ull << 20; + // cudaMemGetInfo's free figure is read after this process's context exists, so the driver's share is + // already out of it: 0 here. The planner's unit test puts the study's 300 MiB in, because its budgets are + // the cards' sizes (table 4.1), not a free figure. + in.cuda_context_bytes = 0; in.reserve_bytes = (uint64_t) (o.vram_reserve_given ? o.vram_reserve_mib : 300) << 20; // kSmallReserveMib const bool borrow = !o.no_prefill_borrow && !o.expert_profile.empty(); in.prompt_bytes = (o.prefill_chunk > 0 && !borrow) ? ((uint64_t) (160 + (o.prefill_chunk * 680) / 1024) << 20) : 0;