code wiki / _hdl_build / nx_nofloat_autograd_gate.nx

nx_nofloat_autograd_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_autograd_gate.nx

12750 B221 linesdepth 4pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_autograd_gate.nx -- HARD-EVIDENCE gate for the NO-FLOAT (integer Q16) general autograd (nx_nofloat_autograd). Proves, by RUNNING in pure integer arithmetic, that the team can do general reverse-mode backprop + train a model WITHOUT any float -- the genuine missing generation on the no-float DeepMind ladder. Mirrors the proven nx_train_r1_gate evidence shape, but Q16-integer: A GRADCHECK (oracle = mathematics): loss = ( relu(w1*x+b1)*w2 + b2 )^2 at params OFF the relu kink (w1=2/3, b1=1/4, w2=3/2, b2=1/4, x=3/4, all Q16). For each param: analytic grad (the tape's reverse sweep) vs CENTRAL finite difference (L(p+h)-L(p-h))/2h, h=1/128, all in Q16. Relative error < 1/32 (floor 1/16). This exercises matvec + vadd + RELU + mse backward -> a GENERAL graph, not one layer. D THE GRADCHECK HAS TEETH (neg-control): negate one analytic grad and assert the SAME check now FAILS -- a wrong gradient is provably caught (so gate A is not vacuously passing). B A MODEL PROVABLY LEARNS: the EXACT task nx_nn_train solves (linear layer W[1x2], target W*=[1.0,-0.5] Q16, 4 samples), but trained by the GENERAL TAPE (matvec->mse summed, one reverse sweep, nfa_sgd) instead of a hand-coded analytic gradient. Assert SSE loss collapses >=95% AND both weights converge >=60% of the way to target with correct sign. The general autograd REPRODUCES the special trainer. C BIT-EXACT REPRODUCIBLE: train twice from zero; assert the final integer weights are IDENTICAL. Integer add is EXACTLY associative -> determinism is STRUCTURAL here (a stronger exceed-axis than the f32 tower, which is only reproducible because it pins one summation order). Evidence -> knowledge/status/nofloat_autograd.log. Sovereign: imports nx_nofloat_autograd (pure integer; NO nx_f32 anywhere in this organ's import graph) + nx_syscalls. license_tier: ORIGINAL expect_exit: 0

dependencies 5 imports · 0 importers

nx_nofloat_autograd.nx nx_g_check_lib.nx nx_g_pn_lib.nx nx_g_puts_lib.nx nx_syscalls.nx nx_nofloat_autograd_gate.nx

imports: nx_nofloat_autograd.nxnx_g_check_lib.nxnx_g_pn_lib.nxnx_g_puts_lib.nxnx_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 gA_analytic sys_mmap ↻ gA_loss nfa_leaf nfa_new nfa_matvec nfa_new ↻ nfa_vadd nfa_new ↻ nfa_relu nfa_new ↻ nfa_mse nfa_new ↻ nfa_backward nfa_qmul nfa_silud nfa_sigmoid nfa_fxexp nfa_qmul ↻ nfa_isqrt nfa_fxexp ↻ nfa_cosf nfa_reduce2pi nfa_cosq nfa_qmul ↻ nfa_sinf nfa_reduce2pi ↻ nfa_sinq nfa_qmul ↻ nfa_grad gA_fd sys_mmap ↻ gA_lossval sys_mmap ↻ gA_loss ↻ nfa_val

structs

none

consts

28const NLOG: *u8 = "knowledge/status/nofloat_autograd.log"
29const Q16: i64 = 65536

functions

31func g_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
32func q_milli(q: i64) -> i64 { var neg: i64=0; var a: i64=q; if a<0 { neg=1; a=0-a } let m: i64=(a*1000)/Q16; if neg==1 { return 0-m } return m }
called by 1: main
35func nl_ws(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: nl_emit calls 1: sys_write
36func nl_wn(fd: i64, v: i64) -> i64
called by 1: nl_emit calls 2: sys_mmapsys_write
42func nl_emit(fd: i64, r: *i64) -> i64
called by 1: main calls 2: nl_wsnl_wn
56func gA_loss(tape: *i64, vals: *i64, st: *i64, p: *i64, leaves: *i64) -> i64
73func gA_lossval(tape: *i64, vals: *i64, st: *i64, p: *i64) -> i64
called by 1: gA_fd calls 3: sys_mmapgA_lossnfa_val
78func gA_analytic(tape: *i64, vals: *i64, grads: *i64, st: *i64, p: *i64, gout: *i64) -> i64
87func gA_fd(tape: *i64, vals: *i64, st: *i64, p: *i64, pi: i64, h: i64) -> i64
called by 1: main calls 2: sys_mmapgA_lossval
99func gB_build(tape: *i64, vals: *i64, st: *i64, Wp: *i64, X: *i64, Y: *i64, T: i64, outW: *i64) -> i64
115func gB_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, epochs: i64, lr_q: i64, Wout: *i64, lf: *i64, ll: *i64) -> i64
141func main() -> i64