code wiki / _hdl_build / nx_nofloat_mlp.nx
nx_nofloat_mlp.nx
buildroot/runtime/_hdl_build/nx_nofloat_mlp.nx
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
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
structs
| none |
consts
| 10 | const K_MAGIC_3000: i64 = 3000 |
| 16 | const Q: i64 = 16 |
| 17 | const ONE: i64 = 65536 |
functions
| 12 | func 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 } |
| 13 | func 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 } |
| 14 | func 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 } |
| 18 | func fxmul(a: i64, b: i64) -> i64 { return (a*b)>>Q } |
| 19 | func relu(x: i64) -> i64 { if x>0 { return x } return 0 } called by 1: forward |
| 20 | func iabs(v: i64) -> i64 { if v<0 { return 0-v } return v } |
| 24 | func forward(P: *i64, x1: i64, x2: i64, s: *i64) -> i64 |
| 31 | func epoch(P: *i64, lr: i64) -> i64 |
| 53 | func init_params(P: *i64) -> i64 { // distinct small inits = symmetry broken; deterministic (no RNG) called by 1: train |
| 56 | func train(P: *i64, epochs: i64, lr: i64, lossout: *i64) -> i64 |
| 63 | func main() -> i64 |