code wiki / _hdl_build / nx_nofloat_scale2_gate.nx

nx_nofloat_scale2_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_scale2_gate.nx

6619 B108 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_scale2_gate.nx -- R4 DEPTH test: does a 2-BLOCK no-float LM reach the richer-grammar floor where the single block plateaued (ppl ~8.5)? Empirical (the lesson: TEST, don't assert). Same richer grammar (DET2->ADJ4->NOUN5->VERB5, vocab 16) + dm=32, but TWO stacked pre-norm attention blocks. SGD lr=0.2 (the best single-block optimizer config). Floor = avg(ln2,ln4,ln5,ln5)=1324 milli-nats (ppl 3.76); uniform=2773. T1 held-out CE << uniform (learned). T2 held-out CE ~= floor (near-OPTIMAL -> R4 lands). If T2 fails too, depth is NOT the lever and the boundary is genuinely optimization/compute (honest stop). expect_exit: 0 Sovereign: nx_nofloat_autograd + nx_syscalls.

dependencies 3 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_nofloat_scale2_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 dini do_train make_stream4 lcg clm2 nfa_leaf nfa_new nfa_embed nfa_new ↻ block nfa_leaf ↻ nfa_rmsnorm_rows nfa_new ↻ nfa_qmul nfa_isqrt nfa_matmul nfa_new ↻ nfa_rope nfa_new ↻ nfa_fxexp nfa_cosf nfa_reduce2pi nfa_cosq nfa_sinf nfa_reduce2pi ↻ nfa_sinq nfa_qmul ↻ nfa_matmul_nt nfa_new ↻ nfa_cmul nfa_new ↻ nfa_qmul ↻ nfa_softmax_rows nfa_new ↻ nfa_fxexp ↻ nfa_vadd

structs

none

consts

11const Q16: i64 = 65536
12const UNIFORM_MNAT: i64 = 2773
13const FLOOR_MNAT: i64 = 1324

functions

16func 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
17func lcg(st: *i64) -> i64 { st[0]=(st[0]*1103515245 + 12345) & 2147483647; return (st[0] >> 15) }
called by 1: make_stream4
18func make_stream4(S: *i64, tgt: *i64, P: i64, st: *i64) -> i64
called by 2: do_traineval_ce calls 1: lcg
25func block(tape: *i64, vals: *i64, st: *i64, nHin: i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, dm: i64, scale: i64, lv: *i64, base: i64) -> i64
46func clm2(tape: *i64, vals: *i64, st: *i64, W: *i64, ids: *i64, tgt: *i64, T: i64, dm: i64, V: i64, scale: i64, lv: *i64) -> i64
59func step_all(tape: *i64, grads: *i64, W: *i64, WN: *i64, lv: *i64, lr: i64, clip: i64, gb: *i64) -> i64
called by 1: do_train calls 2: nfa_gradnfa_sgd
64func do_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, W: *i64, WN: *i64, S: *i64, tgt: *i64, P: i64, dm: i64, V: i64, scale: i64, lv: *i64, gb: *i64, steps: i64, sdat: *i64) -> i64
69func eval_ce(tape: *i64, vals: *i64, st: *i64, W: *i64, S: *i64, tgt: *i64, P: i64, dm: i64, V: i64, scale: i64, lv: *i64, N: i64, sdat: *i64) -> i64
called by 1: main calls 3: make_stream4clm2nfa_val
76func main() -> i64