code wiki / _hdl_build / nx_nofloat_scale_ffn_gate.nx

nx_nofloat_scale_ffn_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_scale_ffn_gate.nx

8410 B134 linesdepth 3pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_scale_ffn_gate.nx -- R4 FINAL test: the COMPLETE transformer block (attention + FFN) on the richer grammar. All prior scale attempts were ATTENTION-ONLY (no FFN) -- but a real transformer block has an FFN, the per-token nonlinear map that can turn a token's category into a SHARP output distribution. Honesty requires testing the complete architecture before concluding the floor is unreachable. Strongest single shot = FFN + mini-batch averaging (lowest-noise training). Richer 4-cat grammar (vocab 16), dm=32, ffn=64. floor = avg(ln2,ln4,ln5,ln5)=1324 milli-nats (ppl 3.76); uniform = ln(16)=2773; attention-only plateaued ~2135. T1 held-out CE << uniform. T2 held-out CE ~= floor (near-OPTIMAL -> the FFN was the missing piece -> R4 lands). If T2 fails too, the tractable levers (optimizer x6 + complete architecture) are EXHAUSTED -> R4-FULL genuinely needs compute-scale (operator-gated), the honest end of the road. expect_exit: 0 Sovereign: nofloat_autograd. D001 MIGRATION 2026-08-25: this gate hand-rolled g_check plus a pass/total counter pair and printed its verdict as prose, so its EXIT CODE did not carry its verdict. It now inherits nx_gate_verdict: gv_ctr makes declared and executed tooth counts ONE number, and gv_verdict's return value IS the exit code. BOTH original assertions are preserved verbatim; the only other change is binding their bare comparison literals to named bounds, which leaves the arithmetic byte-for-byte identical.

dependencies 4 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_gate_verdict.nx nx_nofloat_scale_ffn_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 gv_ctr 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 ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ dini g_puts sys_write ↻ do_train_batch make_stream4 lcg clm_ffn nfa_leaf nfa_new nfa_embed nfa_new ↻ nfa_rmsnorm_rows nfa_new ↻ nfa_qmul nfa_isqrt vm_isqrt nfa_matmul nfa_new ↻ nfa_rope

structs

none

consts

20const Q16: i64 = 65536
21const UNIFORM_MNAT: i64 = 2773
22const FLOOR_MNAT: i64 = 1324
25const LEARNED_FRAC_NUM: i64 = 7
26const LEARNED_FRAC_DEN: i64 = 10
28const FLOOR_TOL_MNAT: i64 = 200

functions

31func dini(a: *i64, n: i64, sd: i64) -> i64 { var i: i64=0; while i<n { a[i]=(((i*7+sd*13+1)%11)-5)*13107; i=i+1 } return 0 }
called by 1: main
32func lcg(st: *i64) -> i64 { st[0]=(st[0]*1103515245 + 12345) & 2147483647; return (st[0] >> 15) }
called by 1: make_stream4
33func make_stream4(S: *i64, tgt: *i64, P: i64, st: *i64) -> i64
called by 2: do_train_batcheval_ce calls 1: lcg
41func clm_ffn(tape: *i64, vals: *i64, st: *i64, W: *i64, ids: *i64, tgt: *i64, T: i64, dm: i64, ffn: i64, V: i64, scale: i64, lv: *i64) -> i64
75func do_train_batch(tape: *i64, vals: *i64, grads: *i64, st: *i64, W: *i64, WN: *i64, gacc: *i64, S: *i64, tgt: *i64, P: i64, dm: i64, ffn: i64, V: i64, scale: i64, lv: *i64, gb: *i64, outer: i64, B: i64, lr: i64, sdat: *i64) -> i64
95func eval_ce(tape: *i64, vals: *i64, st: *i64, W: *i64, S: *i64, tgt: *i64, P: i64, dm: i64, ffn: i64, V: i64, scale: i64, lv: *i64, N: i64, sdat: *i64) -> i64
called by 1: main calls 3: make_stream4clm_ffnnfa_val
102func main() -> i64