code wiki / _hdl_build / nx_nofloat_train_exceed.nx

nx_nofloat_train_exceed.nx

buildroot/runtime/_hdl_build/nx_nofloat_train_exceed.nx

7940 B123 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_train_exceed.nx -- the MEASURED S-class exceed for no-float TRAINING. Extends the established no-float exceed axis (nx_nofloat_exceed_gate proved it for an INFERENCE dot product) to the GRADIENT, which is what every training step computes. The capability that DETECTS/GUARANTEES what mainstream float training CANNOT: a training gradient is a SUM of many per-sample / per-reduction contributions; integer addition is associative + exact, so the no-float gradient is BIT-IDENTICAL regardless of accumulation order, batch order, thread count, or machine -- i.e. REPRODUCIBLE + AUDITABLE training. IEEE-754 float add is non-associative, so the SAME gradient gives DIFFERENT bits by order (PyTorch/JAX/llama.cpp are non-deterministic by construction). This is a CAPABILITY exceed (best-at-job: verifiable reproducibility), NOT merely "we are sovereign": PART 1 (the principle, refereed head-to-head, float = the competitor = teeth): representative wide-dynamic- range per-sample gradient contributions [2^24,1,1,1,1] (true sum 2^24+4). Integer fwd==rev==exact; float fwd!=rev AND float!=exact (it silently drops the small-gradient terms -> the vanishing-update bug). PART 2 (tie to the REAL engine): run nx_nofloat_autograd's actual backward on a batch in two different SAMPLE ORDERS -> the resulting integer gradient is BYTE-IDENTICAL. The real training engine is order-invariant. HONEST scope: this is the reproducibility/exactness/auditability axis. It is NOT a claim to beat PyTorch on model scale, breadth, or wall-clock -- those remain genuinely behind (tiny models, no GPU kernels). expect_exit: 0 Sovereign: imports nx_nofloat_autograd (the pure-integer engine) + nx_syscalls; the __f32 builtins appear ONLY here to demonstrate the FLOAT competitor (the training engine itself stays float-free). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_nofloat_train_exceed.nx

imports: nx_nofloat_autograd.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 te_puts sys_write sys_mmap te_num sys_mmap ↻ sys_write ↻ te_chk te_puts ↻ te_dw sys_mmap ↻ nfa_leaf nfa_new nfa_matvec nfa_new ↻ nfa_mse nfa_new ↻ nfa_vadd 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 sys_exit

structs

none

consts

21const K_MAGIC_16777216: i64 = 16777216
22const K_MAGIC_16777220: i64 = 16777220
23const K_MAGIC_2048: i64 = 2048
24const K_MAGIC_65536: i64 = 65536
25const K_MAGIC_131072: i64 = 131072
26const K_MAGIC_32768: i64 = 32768
27const K_MAGIC_98304: i64 = 98304

functions

29func te_puts(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 2: te_chkmain calls 1: sys_write
30func te_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
31func te_chk(name: *u8, cond: i64) -> i64 { if cond==1 { te_puts(" PASS " as *u8) } else { te_puts(" FAIL " as *u8) } te_puts(name); te_puts("\n" as *u8); return cond }
called by 1: main calls 1: te_puts
35func te_dw(tape: *i64, vals: *i64, grads: *i64, st: *i64, order: *i64, X: *i64, Y: *i64, T: i64, dw: *i64) -> i64
56func main() -> i64