code wiki / _hdl_build / nx_vram_frontier.nx
nx_vram_frontier.nx source
↩ module page · 28 lines · 1492 B
1// nx_vram_frontier.nx -- MAP THE FRONTIER: the achievable set on a fixed consumer GPU is not set
2// by the hardware, it is PUSHED OUTWARD by smarter math. For a budget, this walks a ladder of
3// stacked techniques (fp16 -> Q4 weights -> +Q8 KV -> +GQA -> +Q4 K-cache) and shows, at each
4// rung, (a) the LARGEST model that fits at a fixed context and (b) the LONGEST context that fits
5// for a fixed model. Each rung should dominate the one below: same silicon, more capability.
6// The deep-research adds further rungs (2-bit/BitNet weights, MLA, KV eviction, weight streaming).
7// license_tier: ORIGINAL
8
9import "nx_vram_budget.nx"
10
11// usable MB for weights+KV after activations + overhead are carved out of the budget.
12func vfr_usable_mb(budget_gb: i64, act_mb: i64, overhead: i64) -> i64 {
13 return (budget_gb * 1000 * 100) / (100 + overhead) - act_mb
14}
15
16// largest model (millions of params) that fits at a fixed context, given the KV footprint there.
17func vfr_max_model_m(usable_mb: i64, kv_mb: i64, w_bits: i64) -> i64 {
18 if usable_mb <= kv_mb { return 0 }
19 if w_bits <= 0 { return 0 }
20 return ((usable_mb - kv_mb) * 8) / w_bits
21}
22
23// longest context (tokens) that fits for a fixed model, scaling linearly from the KV cost at ref_ctx.
24func vfr_max_ctx(usable_mb: i64, weights_mb: i64, kv_at_ref_mb: i64, ref_ctx: i64) -> i64 {
25 if usable_mb <= weights_mb { return 0 }
26 if kv_at_ref_mb <= 0 { return 0 }
27 return (ref_ctx * (usable_mb - weights_mb)) / kv_at_ref_mb
28}