code wiki / (root) / nx_ta_transformer_gradcheck_gate.nx

nx_ta_transformer_gradcheck_gate.nx

buildroot/runtime/nx_ta_transformer_gradcheck_gate.nx

10564 B207 linesdepth 6pulls 15 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_ta_transformer_gradcheck_gate.nx -- LIAR-KILL for the 9 f32 transformer ops added to nx_autograd_tensor (2026-07-09, for the R3e neural reader). Each backward identity was HAND-PORTED from its Q16 nfa_* twin; a transposed index or flipped sign would train the reader to garbage and waste the slow f32 run. This gate verifies every one by FINITE DIFFERENCE: build op -> scalar loss (mse-vs-0, or the CE itself for softce) -> analytic grad (ta_backward) vs numeric grad ((L(+h)-L(-h))/2h). A wrong identity => order-of-magnitude/sign mismatch. Requires each op to show a NON-TRIVIAL gradient (|g|>=20 milli) so it cannot pass at 0==0. PASS <op> for each of: matmul, matmul_nt, cmul, softmax_rows(causal), rope_tab, hadamard, silu, rmsnorm_rows, softce_rows. expect_exit: 0 license_tier: ORIGINAL Sovereign: nx_autograd_tensor + nx_syscalls.

dependencies 2 imports · 0 importers

nx_autograd_tensor.nx nx_syscalls.nx nx_ta_transformer_gradcheck_ga

imports: nx_autograd_tensor.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 gt_puts sys_write sys_mmap ta_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 ta_rope_build_tab ta_rope_ang nx_f32_log nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_exp_field ↻ nx_f32_mant_field ↻ nx_f32_sub nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_neg nx_f32_add ↻ nx_f32_div ↻ nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 ↻ nx_i32_to_f32 ↻ nx_f32_div ↻ nx_f32_mul ↻ nx_f32_exp nx_f32_classify ↻

structs

none

consts

none

functions

13func gt_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: gt_cellmain calls 1: sys_write
14func gt_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
called by 2: gt_cellmain calls 2: sys_mmapsys_write
16func gt_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: gt_cell
19func gt_cell(Lp: i64, Lm: i64, h2: i64, ana: i64, nt: *i64) -> i64
32func bld_matmul(tape: *i64, vals: *i64, st: *i64, A: *i64, B: *i64, Z: *i64) -> i64
called by 1: main calls 3: ta_leafta_matmulta_mse
40func bld_matmul_nt(tape: *i64, vals: *i64, st: *i64, A: *i64, B: *i64, Z: *i64) -> i64
called by 1: main calls 3: ta_leafta_matmul_ntta_mse
48func bld_cmul(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64, c: i64) -> i64
called by 1: main calls 3: ta_leafta_cmulta_mse
55func bld_smrows(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64) -> i64
called by 1: main calls 3: ta_leafta_softmax_rowsta_mse
62func bld_rope(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64, tab: *i64) -> i64
called by 1: main calls 3: ta_leafta_rope_tabta_mse
69func bld_had(tape: *i64, vals: *i64, st: *i64, A: *i64, B: *i64, Z: *i64) -> i64
called by 1: main calls 3: ta_leafta_hadamardta_mse
77func bld_silu(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64) -> i64
called by 1: main calls 3: ta_leafta_siluta_mse
84func bld_rms(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64) -> i64
called by 1: main calls 3: ta_leafta_rmsnorm_rowsta_mse
91func bld_softce(tape: *i64, vals: *i64, st: *i64, A: *i64, ids: *i64) -> i64
called by 1: main calls 2: ta_leafta_softce_rows
97func main() -> i64