code wiki / _hdl_build / nx_nofloat_scale_gate.nx

nx_nofloat_scale_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_scale_gate.nx

11570 B182 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

STATUS 2026-06-23: PARTIAL / NOT REGISTERED -- HONEST documented attempt mapping the frontier. On the richer 4-category grammar (vocab 16) at dm=32, a SINGLE-BLOCK no-float LM SCALES and LEARNS STRUCTURE but does NOT reach optimality at tractable compute: - low-lr clipped SGD (0.1): plateaus at uniform (CE ~2738 ~= ln16 2773) -- too-small steps. - higher-lr clipped SGD (0.2): ESCAPES the plateau, CE ~2135 (perplexity ~8.5) = clearly BELOW uniform (2773 / ppl 16) so it learned the category structure, but still well ABOVE the floor (1324 / ppl 3.76) = NOT near-optimal. lr 0.3 / more steps did not improve (plateaus ~2135-2295). THIS IS THE BEST RESULT. - lr DECAY (0.2->0.02): WORSE (CE 2510) -- the low late-lr can't progress; not the fix. - AdamW: diverges at lr>=0.01 / stalls at uniform at lr<=0.003 on this model (a narrow unstable band). NOTE: I hypothesized this was a Q16 g^2-UNDERFLOW and built a Q32-moment Adam to fix it -- but a CONTROLLED small-gradient fit CONVERGES under BOTH Q16 and Q32 moments (loss 112 vs 85), so that hypothesis is NOT confirmed; the transformer-specific divergence cause is NOT isolated. (over-claim retracted; gate deleted.) - DEPTH-2 (two stacked blocks, SGD 0.2): CE 2236 ~= single-block 2135 -- DEPTH DOES NOT HELP (tested, then deleted). So capacity/depth is NOT the bottleneck. So R4-FULL = PARTIAL, and the boundary is now precisely located: NOT a missing mechanism, NOT capacity/depth (depth tested), but fixed-point OPTIMIZATION reaching sharp output distributions + compute -- a novel-optimizer / much-more-compute investment (operator-gated). The 3-category LANDING (nx_nofloat_landing_gate) IS near-optimal and stands. (don't-lie: not registered, NOT claimed GREEN -- near-optimal genuinely fails here.) nx_nofloat_scale_gate.nx -- R4 SCALE-UP (the frontier step): grow BOTH the language and the model, and show the no-float LM stays NEAR-OPTIMAL. Richer grammar (4 categories, vocab 16): DET(2) -> ADJ(4) -> NOUN(5) -> VERB(5) -> DET ... (e.g. "the big cat ran a red dog sat"). Bigger model dm=32. Fresh-random members each stream -> the model learns the GRAMMAR, measured by HELD-OUT perplexity vs the richer information floor. Floor = avg(ln2,ln4,ln5,ln5) = 1.324 nats (perplexity 3.76; members are random within category so unbeatable); uniform baseline = ln(16) = 2.773 nats (perplexity 16). T1 held-out CE << uniform (learned the richer language). T2 held-out CE ~= the richer floor (near-OPTIMAL at scale = the model scaled up cleanly). Pure integer Q16. HONEST: richer but still a CONSTRAINED domain (open multi-topic prose is the remaining compute frontier). Sovereign: nx_nofloat_autograd + nx_syscalls. expect_exit: 0

dependencies 3 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_nofloat_scale_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 clm_fwd nfa_leaf nfa_new nfa_embed nfa_new ↻ 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_qmul ↻ nfa_sinf nfa_reduce2pi ↻ nfa_sinq nfa_qmul ↻ 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

33const Q16: i64 = 65536
34const UNIFORM_MNAT: i64 = 2773 // ln(16)
35const FLOOR_MNAT: i64 = 1324 // avg(ln2,ln4,ln5,ln5)

functions

38func 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
39func lcg(st: *i64) -> i64 { st[0]=(st[0]*1103515245 + 12345) & 2147483647; return (st[0] >> 15) }
called by 1: make_stream4
41func make_stream4(S: *i64, tgt: *i64, P: i64, st: *i64) -> i64
called by 2: do_traineval_ce calls 1: lcg
54func 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
87func adamw32_one(w: *i64, g: *i64, m: *i64, v: *i64, n: i64, lr: i64, b1: i64, b2: i64, eps: i64, t: i64) -> i64
called by 1: adamw_all calls 1: nfa_isqrt
108func adamw_all(tape: *i64, grads: *i64, W: *i64, WN: *i64, M: *i64, Vv: *i64, leaves: *i64, nW: i64, t: i64, lr: i64, clip: i64, gb: *i64) -> i64
118func do_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, W: *i64, WN: *i64, M: *i64, Vv: *i64, S: *i64, tgt: *i64, P: i64, dm: i64, V: i64, scale: i64, leaves: *i64, gb: *i64, steps: i64, sdat: *i64) -> i64
137func eval_ce(tape: *i64, vals: *i64, st: *i64, W: *i64, S: *i64, tgt: *i64, P: i64, dm: i64, V: i64, scale: i64, leaves: *i64, N: i64, sdat: *i64) -> i64
called by 1: main calls 3: make_stream4clm_fwdnfa_val
144func main() -> i64