nx_mesh_mux.nx
buildroot/runtime/nx_mesh_mux.nx
about
nx_mesh_mux.nx -- WORKER MESH: MULTI-MODEL multiplexing on one GPU (the Triton model-management analog). A single
GPU worker can host MANY models (Z-Image, an LLM, SDXL, ...) but not all fit in VRAM at once. This is the RESIDENCY
policy: route a request by model-id, and keep the hot models loaded within a VRAM budget, evicting the LEAST-
RECENTLY-USED model when a new one must be loaded and there is no room -- exactly a VRAM-sized LRU cache of models
(Triton's dynamic model load/unload + instance management). Composes with autoscale (load/unload) + the container
registry (model artifacts) + spec-emit (a per-model worker).
CLI: (no args) -> self-test GATE (routing + fit/evict/refuse + LRU correctness + never-over-budget)
run <budget_mb> <id...> -> simulate a request sequence, print hits/loads/evicts/refused/peak-VRAM
NO fake greens: the gate proves resident VRAM NEVER exceeds the budget, an oversized model is refused (not force-
loaded), and eviction picks the LRU model (a later hit on a kept model proves it was not wrongly evicted). ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_runtime.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 14 | const MUX_MAGIC_10900: i64 = 10900 |
| 15 | const MUX_MAGIC_3000: i64 = 3000 |
| 16 | const MUX_MAGIC_6000: i64 = 6000 |
| 17 | const MUX_MAGIC_20000: i64 = 20000 |
| 18 | const MUX_MAGIC_4000: i64 = 4000 |
| 19 | const MUX_MAGIC_14000: i64 = 14000 |
| 20 | const MUX_MAGIC_11000: i64 = 11000 |
| 21 | const MUX_MAGIC_16000: i64 = 16000 |
| 22 | const MUX_MAGIC_9000: i64 = 9000 |
| 24 | const MUX_MAXRES: i64 = 16 |
functions
| 26 | func mx_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 27 | func mx_wn(fd: i64, v: i64) -> i64 |
| 40 | func mx_p(s: *u8) -> i64 { return mx_w(1, s) } |
| 41 | func mx_pn(v: i64) -> i64 { return mx_wn(1, v) } |
| 42 | func mx_b(v: i64) -> i64 { if v == 1 { mx_p("1" as *u8) } else { mx_p("0" as *u8) } return 0 } |
| 43 | func mx_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } called by 1: main |
| 46 | func mx_size(id: i64) -> i64 |
| 56 | func mx_name(id: i64) -> *u8 |
| 66 | func mx_run(reqs: *i64, nreq: i64, budget: i64, outbox: *i64) -> i64 |
| 121 | func mx_seq(arr: *i64, a: i64, b: i64, c: i64, d: i64, e: i64) -> i64 { arr[0]=a; arr[1]=b; arr[2]=c; arr[3]=d; arr[4]=e; return 5 } called by 1: mx_gate |
| 123 | func mx_gate() -> i64 |
| 171 | func main(argc: i64, argv: *i64) -> i64 |