code wiki / _hdl_build / nx_nofloat_vs_float_gate.nx

nx_nofloat_vs_float_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_vs_float_gate.nx

6497 B120 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_vs_float_gate.nx -- CROSS-VALIDATION: do we need the float equivalent? Answer: it already EXISTS (nx_autograd, the software-f32 scalar tape), and its right role is a VERIFICATION ORACLE + the exceed COMPETITOR -- NOT a parallel product stack. This gate USES that role: it builds the SAME graph loss = ( relu(w1*x + b1)*w2 + b2 )^2 in BOTH engines -- FLOAT via nx_autograd (ag_*, IEEE-754) and NO-FLOAT via nx_nofloat_autograd (nfa_*, integer Q16) -- and asserts the four parameter gradients AGREE (in milli-units). Two INDEPENDENT autograd implementations (different tapes, different number systems) computing the same gradients is far stronger evidence than finite differences alone. It directly answers the question: the float engine validates the no-float engine; we do not need to BUILD a float trainer (we have it) and do not need it in the PRODUCT (no-float is the reproducibility exceed) -- we need it exactly here, as the oracle. T1..T4: for each of {w1,b1,w2,b2}, |float_grad_milli - nofloat_grad_milli| < 60/1000. The true grads (analytic): w1=3.094, b1=4.125, w2=2.063, b2=2.750 -> both engines land on them. expect_exit: 0 license_tier: ORIGINAL imports: nx_autograd (->ag_*, ->nx_f32_*), nx_nofloat_autograd, nx_syscalls

dependencies 3 imports · 0 importers

nx_autograd.nx nx_nofloat_autograd.nx nx_syscalls.nx nx_nofloat_vs_float_gate.nx

imports: nx_autograd.nxnx_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 v_puts sys_write sys_mmap float_grads sys_mmap ↻ ag_leaf ag_constf nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 ag_add ag_mk nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ ag_mul ag_mk ↻ nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ ag_relu nx_f32_gt nx_f32_lt nx_f32_is_nan nx_f32_classify ↻ nx_f32_is_zero nx_f32_classify ↻ ag_mk ↻ ag_backward nx_f32_add ↻

structs

none

consts

none

functions

19func v_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: v_checkmain calls 1: sys_write
20func v_pn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
30func v_check(name: *u8, cond: i64) -> i64 { if cond==1 { v_puts(" PASS " as *u8) } else { v_puts(" FAIL " as *u8) } v_puts(name); v_puts("\n" as *u8); return cond }
calls 1: v_puts
31func v_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
34func f32_milli(v: i64) -> i64
47func q16_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)/65536; if neg==1 { return 0-m } return m }
called by 1: main
50func float_grads(gf: *i64) -> i64
69func nofloat_grads(gnf: *i64) -> i64
94func main() -> i64