code wiki / _hdl_build / nx_kquant_test.nx

nx_kquant_test.nx

buildroot/runtime/_hdl_build/nx_kquant_test.nx

4180 B70 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_kquant_test.nx -- prove the QUALITY lever: finer-grained scales (the K-quant idea) cut the quantization error on REALISTIC weights -- concentrated near zero with occasional OUTLIERS, the real NN case. A naive block of 32 shares one scale, so one outlier inflates the step and blurs the other 31 weights; sub-blocks of 8 isolate the outlier. Exit 0 only if: (1) Q4 @ blk=8 has materially LOWER L2 error than Q4 @ blk=32 (the quality win is real); (2) the cost is honest: blk=8 moves MORE bytes than blk=32 but still far less than fp16; (3) so this is a real point on the quality/data frontier the Council balances. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_kquant.nx nx_syscalls.nx nx_kquant_test.nx

imports: nx_kquant.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main kt_puts sys_write sys_mmap qlayer_matvec_exact kq_layer_quantize kq_blocks_per_row qmv_block_scale qmv_abs qmv_code kq_layer_matvec kq_blocks_per_row ↻ qlayer_l2_relerr_permil qlayer_isqrt kq_bytes kq_blocks_per_row ↻ kt_num sys_mmap ↻ sys_write ↻ kq_bits_x100 sys_exit

structs

none

consts

none

functions

13func kt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
14func kt_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
16func main() -> i64