code wiki / (root) / nx_reader_mlp_gate.nx

nx_reader_mlp_gate.nx

buildroot/runtime/nx_reader_mlp_gate.nx

10776 B230 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic reader
docsdependenciesstructsconstsfunctions

about

nx_reader_mlp_gate.nx -- NEURAL-READER RUNG 1: prove the sovereign autograd (nx_autograd) can TRAIN a nonlinear model, on the exact capability the deep-research reader's linear plateau lacks. The oracle diagnostic proved SCORING is the deep-research wall and that a LINEAR perceptron over hand-features plateaus (~250 vs oracle 727; two features net-negative/inert). The fix is LEARNED NONLINEAR representations. This gate is the minimal liar-killed proof of that mechanism: a 2-layer MLP (2->4->1, ReLU) trained by SGD on the autograd tape LEARNS XOR (100%), which a LINEAR model provably CANNOT (<=75%). Same loop scales to the reader (features->hidden->score) and to any trained model; train in f32, quantize to integer for the no-float inference path. TEETH: T1 MLP fits XOR 4/4 T2 MLP loss collapses T3 LINEAR baseline FAILS (<4/4, the liar-kill: if a linear model 'passed' XOR the test would be meaningless) T4 gradcheck (autograd d/dx x^2=2x). expect_exit: 0 license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_autograd.nx nx_reader_mlp_gate.nx

imports: nx_autograd.nx

imported by: nobody (leaf or entry point)

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

main gw ag_constf nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 init_mlp ag_constf ↻ mlp_step ag_leaf ag_mul ag_mk nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ ag_add ag_mk ↻ nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ ag_relu nx_f32_gt nx_f32_lt nx_f32_is_nan nx_f32_classify ↻ nx_f32_is_zero nx_f32_classify ↻ ag_mk ↻ ag_sub ag_mk ↻ nx_f32_sub

structs

none

consts

39const NIN: i64 = 2
40const NHID: i64 = 8
41const B1_OFF: i64 = 16 // NHID*NIN
42const W2_OFF: i64 = 24 // B1_OFF + NHID
43const B2_OFF: i64 = 32 // W2_OFF + NHID
44const NP_MLP: i64 = 33 // W1[8x2]=16 + b1[8]=8 + W2[8]=8 + b2=1
45const NP_LIN: i64 = 3 // w0,w1,b

functions

13func gw(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
14func gn(v: i64) -> i64
called by 1: main
23func nx_f32_trunc(raw: i64) -> i64
called by 1: f32_milli
37func f32_milli(v: i64) -> i64 { return nx_f32_trunc(nx_f32_mul(v, nx_i32_to_f32(1000))) }
48func init_weights(W: *i64, n: i64) -> i64
called by 1: main calls 1: ag_constf
57func init_mlp(W: *i64) -> i64
called by 1: main calls 1: ag_constf
68func mlp_step(tape: *i64, np: *i64, W: *i64, x0: i64, x1: i64, tgt: i64, ob: *i64) -> i64
94func lin_step(tape: *i64, np: *i64, W: *i64, x0: i64, x1: i64, tgt: i64, ob: *i64) -> i64
called by 1: main calls 4: ag_leafag_mulag_addag_sub
110func main() -> i64