code wiki / (root) / nx_mesh_mux.nx

nx_mesh_mux.nx

buildroot/runtime/nx_mesh_mux.nx

9350 B191 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic mesh
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_runtime.nx nx_mesh_mux.nx

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

main mx_atoi sys_mmap mx_run sys_mmap ↻ mx_size mx_p mx_w sys_write mx_pn mx_wn sys_mmap ↻ sys_write ↻ mx_w ↻ mx_gate mx_p ↻ sys_mmap ↻ mx_size ↻ mx_seq mx_run ↻ mx_b mx_p ↻ sys_openat_wr mx_w ↻ sys_close

structs

none

consts

14const MUX_MAGIC_10900: i64 = 10900
15const MUX_MAGIC_3000: i64 = 3000
16const MUX_MAGIC_6000: i64 = 6000
17const MUX_MAGIC_20000: i64 = 20000
18const MUX_MAGIC_4000: i64 = 4000
19const MUX_MAGIC_14000: i64 = 14000
20const MUX_MAGIC_11000: i64 = 11000
21const MUX_MAGIC_16000: i64 = 16000
22const MUX_MAGIC_9000: i64 = 9000
24const MUX_MAXRES: i64 = 16

functions

26func 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 }
called by 3: mx_pmx_gatemain calls 1: sys_write
27func mx_wn(fd: i64, v: i64) -> i64
called by 1: mx_pn calls 2: sys_mmapsys_write
40func mx_p(s: *u8) -> i64 { return mx_w(1, s) }
called by 3: mx_bmx_gatemain calls 1: mx_w
41func mx_pn(v: i64) -> i64 { return mx_wn(1, v) }
called by 1: main calls 1: mx_wn
42func mx_b(v: i64) -> i64 { if v == 1 { mx_p("1" as *u8) } else { mx_p("0" as *u8) } return 0 }
called by 1: mx_gate calls 1: mx_p
43func 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
46func mx_size(id: i64) -> i64
called by 2: mx_runmx_gate
56func mx_name(id: i64) -> *u8
66func mx_run(reqs: *i64, nreq: i64, budget: i64, outbox: *i64) -> i64
called by 2: mx_gatemain calls 2: sys_mmapmx_size
121func 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
123func mx_gate() -> i64
171func main(argc: i64, argv: *i64) -> i64