nx_reader_mlp_gate.nx
buildroot/runtime/nx_reader_mlp_gate.nx
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
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
structs
| none |
consts
| 39 | const NIN: i64 = 2 |
| 40 | const NHID: i64 = 8 |
| 41 | const B1_OFF: i64 = 16 // NHID*NIN |
| 42 | const W2_OFF: i64 = 24 // B1_OFF + NHID |
| 43 | const B2_OFF: i64 = 32 // W2_OFF + NHID |
| 44 | const NP_MLP: i64 = 33 // W1[8x2]=16 + b1[8]=8 + W2[8]=8 + b2=1 |
| 45 | const NP_LIN: i64 = 3 // w0,w1,b |
functions
| 13 | func 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 |
| 14 | func gn(v: i64) -> i64 called by 1: main |
| 23 | func nx_f32_trunc(raw: i64) -> i64 called by 1: f32_milli |
| 37 | func f32_milli(v: i64) -> i64 { return nx_f32_trunc(nx_f32_mul(v, nx_i32_to_f32(1000))) } |
| 48 | func init_weights(W: *i64, n: i64) -> i64 |
| 57 | func init_mlp(W: *i64) -> i64 |
| 68 | func mlp_step(tape: *i64, np: *i64, W: *i64, x0: i64, x1: i64, tgt: i64, ob: *i64) -> i64 |
| 94 | func lin_step(tape: *i64, np: *i64, W: *i64, x0: i64, x1: i64, tgt: i64, ob: *i64) -> i64 |
| 110 | func main() -> i64 |