code wiki / _hdl_build / nx_nofloat_train_exceed.nx
nx_nofloat_train_exceed.nx
buildroot/runtime/_hdl_build/nx_nofloat_train_exceed.nx
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
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
structs
| none |
consts
| 21 | const K_MAGIC_16777216: i64 = 16777216 |
| 22 | const K_MAGIC_16777220: i64 = 16777220 |
| 23 | const K_MAGIC_2048: i64 = 2048 |
| 24 | const K_MAGIC_65536: i64 = 65536 |
| 25 | const K_MAGIC_131072: i64 = 131072 |
| 26 | const K_MAGIC_32768: i64 = 32768 |
| 27 | const K_MAGIC_98304: i64 = 98304 |
functions
| 29 | func 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 } |
| 30 | func 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 } |
| 31 | func 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 } |
| 35 | func te_dw(tape: *i64, vals: *i64, grads: *i64, st: *i64, order: *i64, X: *i64, Y: *i64, T: i64, dw: *i64) -> i64 |
| 56 | func main() -> i64 |