code wiki / _hdl_build / nx_nofloat_generalize_gate.nx
nx_nofloat_generalize_gate.nx
buildroot/runtime/_hdl_build/nx_nofloat_generalize_gate.nx
about
nx_nofloat_generalize_gate.nx -- HELD-OUT RULE GENERALIZATION in pure integer Q16 (CAP-NF-GENERALIZE). The
real test of learning vs memorization: train the no-float char-LM on a periodic sequence "abcabc..." (it must
learn the first-order RULE a->b, b->c, c->a), then evaluate on data it NEVER trained on:
T1 a HELD-OUT string "cabcab..." (SAME rule, DIFFERENT string) -> high next-char accuracy (>> chance 1/3).
Succeeding on a SHIFTED string proves the model learned the CHAR-rule, not position-by-position memorization.
T2 (teeth) a CONTROL "acbacb..." (DIFFERENT rule a->c,c->b,b->a) -> ~chance accuracy. Proves the model applies
the SPECIFIC learned rule (it is not outputting constants or trivially-correct).
Lean (nx_cc .s ceiling): exactly 2 clm_fwd call sites -- do_train (helper) + eval_acc (helper, called twice).
HONEST: first-order periodic rule on a tiny task = a real but modest generalization (not deep in-context learning).
Sovereign: nx_nofloat_autograd + nx_syscalls. expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_nofloat_autograd.nxnx_g_puts_lib.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
| 14 | const Q16: i64 = 65536 |
functions
| 16 | func g_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 } |
| 17 | func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: main |
| 18 | func 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 |
| 19 | func amx(tape: *i64, vals: *i64, logn: i64, r: i64, V: i64) -> i64 { let o: i64=tape[7*logn+5]; var b: i64=0; var bv: i64=vals[o+r*V]; var j: i64=1; while j<V { if vals[o+r*V+j]>bv { bv=vals[o+r*V+j]; b=j } j=j+1 } return b } called by 1: eval_acc |
| 21 | func clm_fwd(tape: *i64, vals: *i64, st: *i64, W: *i64, ids: *i64, tgt: *i64, T: i64, dm: i64, V: i64, scale: i64, leaves: *i64) -> i64 called by 2: do_traineval_acc calls 10: nfa_leafnfa_embednfa_rmsnorm_rowsnfa_matmulnfa_ropenfa_matmul_nt+4 |
| 49 | func step_all(tape: *i64, grads: *i64, W: *i64, WN: *i64, leaves: *i64, nW: i64, lr: i64, clip: i64, gb: *i64) -> i64 |
| 55 | func do_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, W: *i64, WN: *i64, ids: *i64, tgt: *i64, T: i64, dm: i64, V: i64, scale: i64, leaves: *i64, gb: *i64, steps: i64) -> i64 |
| 61 | func eval_acc(tape: *i64, vals: *i64, st: *i64, W: *i64, ids2: *i64, T: i64, dm: i64, V: i64, scale: i64, leaves: *i64) -> i64 |
| 68 | func main() -> i64 |