code wiki / (root) / nx_nofloat_w4_gemm_gate.nx

nx_nofloat_w4_gemm_gate.nx

buildroot/runtime/nx_nofloat_w4_gemm_gate.nx

8323 B161 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_w4_gemm_gate.nx -- THE DECISIVE W4A16 EXPERIMENT (de-risks the inference-speed arc before any core-engine change). Decode is memory-bound (baseline: i8 3x faster than i32 = 4x fewer weight bytes). W4A16 stores weights as 4-bit (0.5 B/weight = HALF of i8) -> less memory read, but needs extra 4-bit unpack. Q: does the halved weight-read beat the unpack cost on the REAL decode shape (matvec: 1 x K activation * N x K weights)? This gate builds both paths (i8-weight and 4-bit-weight, SAME __i16x16_madd inner product), checks correctness (both approximate the int16 reference within quant error), and TIMES them. Verdict decides whether to build the full W4 kernel (and whether it needs SIMD-unpack primitives). Isolated -- touches NO serve code. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_nofloat_w4_gemm_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap gp_puts sys_write lcg gp_iabs now_ms sys_mmap ↻ sys_clock_gettime_mono i32x8_hsum gp_n sys_write ↻ sys_mmap ↻

structs

none

consts

none

functions

10func gp_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
11func gp_n(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
21func gp_iabs(x: i64) -> i64 { if x<0 { return 0-x } return x }
called by 1: main
22func i32x8_hsum(acc: *u8) -> i64 { let p: *i32=acc as *i32; var s: i64=0; var i: i64=0; while i<8 { s=s+(p[i] as i64); i=i+1 } return s }
called by 1: main
23func now_ms() -> i64 { let ts: *i64=sys_mmap(16) as *i64; sys_clock_gettime_mono(ts); return ts[0]*1000 + ts[1]/1000000 }
called by 1: main calls 2: sys_mmapsys_clock_gettime_mono
26func lcg(st: *i64) -> i64 { st[0] = (st[0]*6364136223846793005 + 1442695040888963407) & 0x7FFFFFFFFFFFFFFF; return st[0] }
called by 1: main
28func main() -> i64