code wiki / _hdl_build / nx_nofloat_mlp.nx

nx_nofloat_mlp.nx

buildroot/runtime/_hdl_build/nx_nofloat_mlp.nx

8239 B112 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_mlp.nx -- SOVEREIGN NO-FLOAT MLP + INTEGER BACKPROP (scale the trainer linear->multi-layer, toward an LLM). A 2-2-1 ReLU network in integer Q16 with full backprop (output layer + ReLU gradient + hidden layer), trained on XOR -- the canonical task a LINEAR model provably CANNOT solve, so success proves multi-layer integer backprop genuinely works. All integer => bit-exact deterministic training (the moat vs float/CUDA). T1 forward with the analytic ReLU-XOR weights outputs EXACT XOR [0,1,1,0] -- architecture + nonlinearity proven. T2 integer backprop from a distinct init REDUCES loss (the gradient mechanism works in fixed-point). T3 (EXCEED) DETERMINISM: two training runs -> BIT-IDENTICAL params. T4 substantial learning (final << initial). expect_exit: 0 Sovereign: nx_syscalls.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_nofloat_mlp.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 g_puts sys_write sys_mmap forward fxmul relu g_pn sys_mmap ↻ sys_write ↻ ck g_puts ↻ train init_params epoch sys_mmap ↻ forward ↻ fxmul ↻ sys_openat_append sys_write ↻ sys_close sys_exit

structs

none

consts

10const K_MAGIC_3000: i64 = 3000
16const Q: i64 = 16
17const ONE: i64 = 65536

functions

12func g_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 2: ckmain calls 1: sys_write
13func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
called by 1: main calls 2: sys_mmapsys_write
14func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
called by 1: main calls 1: g_puts
18func fxmul(a: i64, b: i64) -> i64 { return (a*b)>>Q }
called by 2: forwardepoch
19func relu(x: i64) -> i64 { if x>0 { return x } return 0 }
called by 1: forward
20func iabs(v: i64) -> i64 { if v<0 { return 0-v } return v }
24func forward(P: *i64, x1: i64, x2: i64, s: *i64) -> i64
called by 2: epochmain calls 2: fxmulrelu
31func epoch(P: *i64, lr: i64) -> i64
called by 1: train calls 3: sys_mmapforwardfxmul
53func init_params(P: *i64) -> i64 { // distinct small inits = symmetry broken; deterministic (no RNG)
called by 1: train
56func train(P: *i64, epochs: i64, lr: i64, lossout: *i64) -> i64
called by 1: main calls 2: init_paramsepoch
63func main() -> i64