okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
01529aaa8
main
1// src/plan/plan_main.cpp - the `strata-plan` CLI: print the memory plan, or say why it does not close. 2// 3// The engine must adapt to the GPU it is running on, so the plan is computed from measured free VRAM and the 4// requested context rather than configured by hand. This tool is that computation on its own, which is what 5// makes it testable without a GPU. 6#include "strata/plan/plan.hpp" 7 8#include <cstdio> 9#include <cstdlib> 10#include <cstring> 11#include <string> 12 13int main (int argc ,char ** argv ) { 14uint64_t ctx = 20480 ; 15uint64_t free_vram = 12ull * 1000 * 1000 * 1000 ;// RTX 5070 nominal; overridden by --vram 16 strata::plan::Costs costs ; 17bool state_given = false; 18for (int i = 1 ;i < argc ;++ i ) { 19const std::string a = argv [i ]; 20auto next = [& ](uint64_t & out ) { 21if (i + 1 >=argc ) { 22 std::fprintf (stderr ,"%s needs a value\n" ,a .c_str ()); 23 std::exit (2 ); 24 } 25out = std::strtoull (argv [++ i ],nullptr ,10 ); 26 }; 27if (a == "--max-context" ) 28next (ctx ); 29else if (a == "--vram" ) 30next (free_vram ); 31else if (a == "--dense" ) 32next (costs .dense_bytes ); 33else if (a == "--embd" ) 34next (costs .embd_bytes ); 35else if (a == "--workspace" ) 36next (costs .workspace_bytes ); 37else if (a == "--state" ) { 38next (costs .state_bytes ); 39state_given = true; 40 }else if (a == "--pool" ) { 41uint64_t v = 0 ; 42next (v ); 43free_vram = v ; 44 }else if (a == "--help" || a == "-h" ) { 45 std::printf ("usage: strata-plan [--max-context N] [--vram BYTES] [--dense B] [--embd B]\n" 46" [--workspace B] [--state B] [--pool B]\n" 47" --state defaults to the geometry's own GDN recurrence + conv history, NOT to 0:\n" 48" the flag used to default to zero and nothing passed it, so the planner silently\n" 49" planned without 117.7 MB (85 expert slots) of non-evictable state.\n" ); 50return 0 ; 51 }else { 52 std::fprintf (stderr ,"unknown argument: %s\n" ,a .c_str ()); 53return 2 ; 54 } 55 } 56// DEFAULT THE STATE FROM THE GEOMETRY. A `--state` that defaults to 0 and is never passed is not a 57// default, it is an omission - and this one was worth 85 cache slots of overcommit. 58if (!state_given )costs .state_bytes = strata::plan::state_bytes (strata::plan::Geometry {}); 59// The pool is what the KV cache and the expert cache share. Derived from the card's free VRAM less the 60// resident dense weights; `--pool` overrides it for reproducing the standard-tier numbers exactly. 61const uint64_t pool = free_vram > costs .dense_bytes + costs .embd_bytes 62 ?free_vram - costs .dense_bytes - costs .embd_bytes 63 :0 ; 64try { 65const strata::plan::Plan p = strata::plan::make_plan (ctx , strata::plan::Geometry {},costs , 66pool ?pool : strata::plan::vram_pool_bytes ()); 67 std::printf ("%s" , strata::plan::to_string (p ).c_str ()); 68return 0 ; 69 }catch (const strata::plan::DoesNotClose & e ) { 70 std::fprintf (stderr ,"strata-plan: %s\n" ,e .what ()); 71return 1 ; 72 } 73}