code wiki / _hdl_build / nx_nofloat_block_gate.nx

nx_nofloat_block_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_block_gate.nx

17397 B295 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_block_gate.nx -- HARD-EVIDENCE gate for a COMPLETE pre-norm TRANSFORMER BLOCK backprop + train, in PURE INTEGER Q16 (CAP-NF-BLOCK). The block (single-head) is the real Qwen-style shape: H = X + Wo * Attn( RoPE, scaled, causal-softmax )( rmsnorm_rows(X) ) [attention sublayer + residual] Y = H + SwiGLU-FFN( rmsnorm_rows(H) ) [FFN sublayer + residual] SwiGLU-FFN(z) = Wd * ( silu(Wg*z) (*) (Wu*z) ) Composed ENTIRELY from gradcheck-verified ops (rmsnorm_rows, matmul, matmul_nt, rope, cmul, softmax_rows, silu, hadamard, vadd, mse). No new backward math -- this proves the COMPOSITION trains. A1 hadamard gradcheck : loss=mse(a(*)b,t); dL/da == finite diff. A2 rmsnorm_rows gradcheck: per-token norm; dL/dx == finite diff. A3 FULL-BLOCK gradcheck wrt Wd (down-proj, short path): dL/dWd == finite diff. A4 FULL-BLOCK gradcheck wrt Wq (the LONGEST chain: through FFN, residual, attention, RoPE, softmax): measured. B the BLOCK TRAINS : with all weights fixed except the down-proj Wd, Y is LINEAR in Wd (convex MSE) -> train Wd from zero to a realizable teacher target; assert loss collapses + Wd converges. A weight DEEP in a full transformer block is driven by the block's own end-to-end backward. C bit-exact ; D neg-control teeth. Evidence -> knowledge/status/nofloat_block.log. Sovereign: nx_nofloat_autograd + nx_syscalls (pure integer). HONEST scope: single-head; multi-head/GQA + multi-block stack are the remaining COMPOSITION. expect_exit: 0

dependencies 3 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_nofloat_block_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 one_gradcheck sys_mmap ↻ one_loss nfa_leaf nfa_new nfa_hadamard nfa_new ↻ nfa_qmul nfa_rmsnorm_rows nfa_new ↻ nfa_qmul ↻ nfa_isqrt nfa_mse 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 one_lossval sys_mmap ↻ one_loss ↻ nfa_val g_abs

structs

none

consts

24const BLOG: *u8 = "knowledge/status/nofloat_block.log"
25const Q16: i64 = 65536

functions

28func g_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 2: one_gradcheckmain
29func b_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
30func b_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
33func one_loss(tape: *i64, vals: *i64, st: *i64, op: i64, Xs: *i64, Bs: *i64, Ts: *i64, r: i64, c: i64, leaves: *i64) -> i64
44func one_lossval(tape: *i64, vals: *i64, st: *i64, op: i64, Xs: *i64, Bs: *i64, Ts: *i64, r: i64, c: i64) -> i64
49func one_gradcheck(tape: *i64, vals: *i64, grads: *i64, st: *i64, op: i64, Xs: *i64, Bs: *i64, Ts: *i64, r: i64, c: i64, h: i64, tol_q: i64, floor_q: i64, worst: *i64) -> i64
77func blk_fwd(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, T: i64, dm: i64, ffn: i64, scale: i64, leaves: *i64) -> i64
109func blk_loss(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, Ts: *i64, T: i64, dm: i64, ffn: i64, scale: i64, leaves: *i64) -> i64
114func blk_lossval(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, Ts: *i64, T: i64, dm: i64, ffn: i64, scale: i64) -> i64
called by 1: main calls 3: sys_mmapblk_lossnfa_val
119func blk_out(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, T: i64, dm: i64, ffn: i64, scale: i64, outY: *i64) -> i64
called by 1: main calls 3: sys_mmapblk_fwdnfa_val
127func main() -> i64