nx_lowrank_kv_real.nx
buildroot/runtime/nx_lowrank_kv_real.nx
about
nx_lowrank_kv_real.nx -- M4c-1: is REAL Qwen2.5-0.5B KV actually low-rank? (the empirical foundation of the
low-rank-KV competition). Loads the sovereign-downloaded model, runs a real forward, then measures the
SINGULAR SPECTRUM of the real cached K: cumulative energy in the top-r directions vs total. If the top few
directions hold most of the energy, real KV IS low-rank -> our per-token compression (M3) helps real models.
Reuses: the proven real-LM load+forward (nx_f32_llm_forward_v4, identical to nx_f32_llm_live_load_test) +
the M1 reorthogonalization lesson for the eigen-extraction. Arithmetic = nx_f32 (software, matches the LM
stack) + nx_f32_hw f32_of/f32_int for int<->f32. Sovereign: nx_cc->nxasm, no gcc. license_tier: ORIGINAL
dependencies 17 imports · 0 importers
diagram shows first 10 each side; +7 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_itoa_lib.nxnx_tier.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_f32.nxnx_f32_hw.nxnx_f32_kv_cache.nxnx_f32_lazy_weight.nxnx_f32_llama_block.nxnx_f32_llama_block_v4.nxnx_f32_llama_stack_v4.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llm.nxnx_f32_llm_v4.nxnx_f32_llm_read_dims.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
| 27 | func r_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 32 | func r_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 33 | func r_is_zero(x: i64) -> i64 { if (x & 0x7fffffff) == 0 { return 1 } return 0 } |
| 36 | func r_dot(a: *i64, b: *i64, n: i64) -> i64 |
| 42 | func r_normalize(v: *i64, n: i64) -> i64 |
| 52 | func r_gmatvec(G: *i64, v: *i64, d: i64, out: *i64) -> i64 |
| 63 | func r_deflate1(v: *i64, basis: *i64, found: i64, d: i64) -> i64 |
| 75 | func r_reorth(v: *i64, basis: *i64, found: i64, d: i64) -> i64 |
| 79 | func r_power_one(G: *i64, d: i64, basis: *i64, found: i64, v: *i64, w: *i64) -> i64 |
| 104 | func r_gram(K: *i64, seq: i64, d: i64, G: *i64) -> i64 |
| 119 | func r_trace(G: *i64, d: i64) -> i64 |
| 127 | func r_spectrum(K: *i64, seq: i64, d: i64, label: *u8) -> i64 |
| 153 | func r_rank_for_threshold(K: *i64, seq: i64, d: i64, thresh: i64) -> i64 |
| 173 | func r_argmax(a: *i64, n: i64) -> i64 calls 1: nx_f32_gt |
| 185 | func r_compress_layer(K: *i64, seq: i64, d: i64, rank: i64) -> i64 |
| 217 | func r_copy(dst: *i64, src: *i64, n: i64) -> i64 { var i: i64 = 0; while i < n { dst[i] = src[i]; i = i + 1 } return 0 } called by 1: main |
| 220 | func r_logit_rel(la: *i64, lb: *i64, n: i64) -> i64 |
| 234 | func main() -> i64 |