code wiki / _hdl_build / nx_nofloat_multihead_gate.nx

nx_nofloat_multihead_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_multihead_gate.nx

15939 B260 linesdepth 3pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_multihead_gate.nx -- HARD-EVIDENCE gate for MULTI-HEAD attention in pure integer Q16. The defining transformer feature: split Q/K/V into H heads (slice_cols), run the verified attention core per head (RoPE + scaled causal softmax + A.V), concat the heads (concat_cols), then the output projection. Backprops end-to-end. A1 slice_cols gradcheck : extract cols backward (scatter) == finite differences. A2 concat_cols gradcheck : concat backward (split) == finite differences. A3 multi-head gradcheck wrt Wq : the gradient through BOTH heads (slice+RoPE+softmax+A.V+concat+proj) == FD. D neg-control teeth ; C bit-exact. B multi-head LEARNS : with attention fixed, the output projection Wo is trained (AdamW) to a realizable target; loss collapses -> the multi-head output path trains. Evidence -> knowledge/status/nofloat_multihead.log. Sovereign: nx_nofloat_autograd + nx_syscalls. expect_exit: 0

dependencies 4 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_gate_verdict.nx nx_nofloat_multihead_gate.nx

imports: nx_nofloat_autograd.nxnx_syscalls.nxnx_gate_emit_lib.nxnx_gate_verdict.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 nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ lm_init nfa_leaf nfa_new nfa_slice_cols nfa_new ↻ nfa_mse nfa_new ↻ nfa_backward nfa_qmul nfa_silud nfa_sigmoid nfa_fxexp nfa_qmul ↻ nfa_isqrt vm_isqrt nfa_fxexp ↻ nfa_cosf nfa_reduce2pi nfa_cosq nfa_qmul ↻ nfa_sinf nfa_reduce2pi ↻

structs

none

consts

18const MLOG: *u8 = "knowledge/status/nofloat_multihead.log"
19const Q16: i64 = 65536

functions

22func g_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
23func m_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 m_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 lm_init(arr: *i64, n: i64, seed: i64) -> i64 { var i: i64=0; while i<n { arr[i] = (((i*7 + seed*13 + 1) % 11) - 5) * 13107; i=i+1 } return 0 }
called by 1: main
30func mha_fwd(tape: *i64, vals: *i64, st: *i64, W: *i64, X: *i64, T: i64, dm: i64, hd: i64, H: i64, scale: i64, leaves: *i64) -> i64
62func mha_loss(tape: *i64, vals: *i64, st: *i64, W: *i64, X: *i64, Tg: *i64, T: i64, dm: i64, hd: i64, H: i64, scale: i64, leaves: *i64) -> i64
67func mha_lossval(tape: *i64, vals: *i64, st: *i64, W: *i64, X: *i64, Tg: *i64, T: i64, dm: i64, hd: i64, H: i64, scale: i64) -> i64
called by 1: main calls 3: sys_mmapmha_lossnfa_val
72func mha_out(tape: *i64, vals: *i64, st: *i64, W: *i64, X: *i64, T: i64, dm: i64, hd: i64, H: i64, scale: i64, outv: *i64) -> i64
called by 1: main calls 3: sys_mmapmha_fwdnfa_val
80func main() -> i64