code wiki / _hdl_build / nx_nofloat_autograd_gate.nx
nx_nofloat_autograd_gate.nx
buildroot/runtime/_hdl_build/nx_nofloat_autograd_gate.nx
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
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
structs
| none |
consts
| 28 | const NLOG: *u8 = "knowledge/status/nofloat_autograd.log" |
| 29 | const Q16: i64 = 65536 |
functions
| 31 | func g_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: main |
| 32 | func 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 |
| 35 | func 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 } |
| 36 | func nl_wn(fd: i64, v: i64) -> i64 |
| 42 | func nl_emit(fd: i64, r: *i64) -> i64 |
| 56 | func gA_loss(tape: *i64, vals: *i64, st: *i64, p: *i64, leaves: *i64) -> i64 |
| 73 | func gA_lossval(tape: *i64, vals: *i64, st: *i64, p: *i64) -> i64 |
| 78 | func gA_analytic(tape: *i64, vals: *i64, grads: *i64, st: *i64, p: *i64, gout: *i64) -> i64 |
| 87 | func gA_fd(tape: *i64, vals: *i64, st: *i64, p: *i64, pi: i64, h: i64) -> i64 |
| 99 | func gB_build(tape: *i64, vals: *i64, st: *i64, Wp: *i64, X: *i64, Y: *i64, T: i64, outW: *i64) -> i64 |
| 115 | func gB_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, epochs: i64, lr_q: i64, Wout: *i64, lf: *i64, ll: *i64) -> i64 |
| 141 | func main() -> i64 |