code wiki / _hdl_build / nx_nofloat_adamw_gate.nx

nx_nofloat_adamw_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_adamw_gate.nx

8035 B130 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_adamw_gate.nx -- HARD-EVIDENCE gate for the Q16 AdamW optimizer (nfa_adamw), with a MEASURED exceed over plain SGD. On an ILL-CONDITIONED linear regression (two features of very different scales: col0 ~ O(1), col1 ~ O(1/40)), one global SGD learning-rate either crawls on the small-curvature direction or diverges on the large one. AdamW normalizes each parameter's step by its own running gradient scale, so it converges FAR faster. Pure integer Q16 -> bit-exact/deterministic. T1 AdamW converges : from zero, AdamW drives the SSE loss to ~0 (it works). T2 MEASURED exceed : at the SAME step budget, AdamW's final loss is MUCH lower than tuned SGD's (and AdamW reaches the loss threshold in FAR fewer steps). Numbers printed. T3 SGD really struggles: SGD's final loss on this conditioning stays high (the problem is genuinely hard for one global rate) -- so T2 is a real win, not a strawman. T4 bit-exact : two AdamW runs give IDENTICAL integer weights (determinism). Evidence -> knowledge/status/nofloat_adamw.log. Sovereign: nx_nofloat_autograd + nx_syscalls. expect_exit: 0

dependencies 3 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_nofloat_adamw_gate.nx

imports: nx_nofloat_autograd.nxnx_syscalls.nxnx_gate_emit_lib.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 reg_grad nfa_leaf nfa_new nfa_matmul 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 nfa_val nfa_sgd nfa_adamw nfa_qmul ↻ nfa_isqrt ↻ g_pn sys_mmap ↻ sys_write ↻ g_check g_puts ↻

structs

none

consts

19const ALOG: *u8 = "knowledge/status/nofloat_adamw.log"
20const Q16: i64 = 65536

functions

23func a_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: main calls 1: sys_write
24func a_wn(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(fd,"-" as *u8,1);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;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(fd,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
27func reg_grad(tape: *i64, vals: *i64, grads: *i64, st: *i64, Wp: *i64, X: *i64, Y: *i64, T: i64, g: *i64) -> i64
45func main() -> i64