nx_ta_transformer_gradcheck_gate.nx
buildroot/runtime/nx_ta_transformer_gradcheck_gate.nx
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
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
structs
| none |
consts
| none |
functions
| 13 | func 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 } |
| 14 | func 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 } |
| 16 | func gt_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x } called by 1: gt_cell |
| 19 | func gt_cell(Lp: i64, Lm: i64, h2: i64, ana: i64, nt: *i64) -> i64 |
| 32 | func bld_matmul(tape: *i64, vals: *i64, st: *i64, A: *i64, B: *i64, Z: *i64) -> i64 |
| 40 | func bld_matmul_nt(tape: *i64, vals: *i64, st: *i64, A: *i64, B: *i64, Z: *i64) -> i64 |
| 48 | func bld_cmul(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64, c: i64) -> i64 |
| 55 | func bld_smrows(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64) -> i64 |
| 62 | func bld_rope(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64, tab: *i64) -> i64 |
| 69 | func bld_had(tape: *i64, vals: *i64, st: *i64, A: *i64, B: *i64, Z: *i64) -> i64 |
| 77 | func bld_silu(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64) -> i64 |
| 84 | func bld_rms(tape: *i64, vals: *i64, st: *i64, A: *i64, Z: *i64) -> i64 |
| 91 | func bld_softce(tape: *i64, vals: *i64, st: *i64, A: *i64, ids: *i64) -> i64 |
| 97 | func main() -> i64 |