nx_lowrank_weight_spectrum.nx
buildroot/runtime/nx_lowrank_weight_spectrum.nx
about
nx_lowrank_weight_spectrum.nx -- the FORWARD-FREE VRAM lever: are the real model's WEIGHT matrices low-rank?
(FlashSVD / over-parameterization: arXiv 2508.01506). Unlike the KV-cache lever, this needs NO forward --
just load a weight tensor + measure its singular spectrum -- so it iterates without the slow software-f32
forward. Measures attn_q (square 896x896) AND ffn_gate (4864x896, the big MLP weight where most params live)
for Qwen2.5-0.5B: cumulative covariance energy in the top-r of the smaller (cols) dimension. High energy at
small r => low-rank => SVD-compressible. Sovereign (nx_cc->nxasm, no gcc). NOTE: SVD funcs copied from
nx_lowrank_kv_real (proven f32+reorth) -- TODO extract both to nx_lowrank_svd.nx (DRY #15). license_tier: ORIGINAL
dependencies 8 imports · 0 importers
imports: nx_syscalls.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_gguf_load_f32.nxnx_f32.nxnx_f32_div.nxnx_f32_hw.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
| none |
functions
| 17 | func w_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 18 | func w_putn(v: i64) -> i64 |
| 30 | func r_is_zero(x: i64) -> i64 { if (x & 0x7fffffff) == 0 { return 1 } return 0 } |
| 31 | func r_dot(a: *i64, b: *i64, n: i64) -> i64 |
| 37 | func r_normalize(v: *i64, n: i64) -> i64 |
| 47 | func r_gmatvec(G: *i64, v: *i64, d: i64, out: *i64) -> i64 |
| 58 | func r_deflate1(v: *i64, basis: *i64, found: i64, d: i64) -> i64 |
| 70 | func r_reorth(v: *i64, basis: *i64, found: i64, d: i64) -> i64 |
| 73 | func r_power_one(G: *i64, d: i64, basis: *i64, found: i64, v: *i64, w: *i64) -> i64 |
| 98 | func r_gram(W: *i64, rows: i64, cols: i64, G: *i64) -> i64 |
| 113 | func r_trace(G: *i64, d: i64) -> i64 |
| 121 | func w_spectrum(W: *i64, rows: i64, cols: i64, label: *u8) -> i64 |
| 147 | func w_measure(buf: *u8, hdr: *NxGgufHeader, name: *u8, name_len: nx_int, label: *u8) -> i64 called by 1: main calls 7: nx_gguf_find_tensorw_putsnx_gguf_tensor_atsys_mmapnx_gguf_load_tensor_to_f32w_putn+1 |
| 166 | func main() -> i64 |