code wiki / _hdl_build / nx_nofloat_bpe_lm_gate.nx

nx_nofloat_bpe_lm_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_bpe_lm_gate.nx

9726 B149 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_bpe_lm_gate.nx -- CAPSTONE: the WHOLE sovereign efficient text pipeline wired END-TO-END, pure no-float Q16. Composes R2 (learned BPE, nx_nofloat_bpe_gate) + R1 (the no-float transformer LM): text -> learn K BPE merges -> compress to sub-word tokens -> remap to a compact vocab -> the no-float LM trains to model the token stream -> autoregressive argmax generation -> decode tokens back through the merges to bytes -> the ORIGINAL text. T1: the LM learns the BPE-token stream (argmax generation reproduces every token). T2: END-TO-END LOSSLESS -- the decoded generation equals the original text, byte-exact (the full tokenize->train->generate->detokenize loop is correct). T3: EFFICIENCY -- the BPE token stream is shorter than the char stream (fewer tokens to model). Sovereign: nx_nofloat_autograd + nx_syscalls. Reuses verified pieces (BPE merge-learn, clm_fwd attention LM, fixed-T argmax decode, recursive merge-expand). expect_exit: 0

dependencies 3 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_nofloat_bpe_lm_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 slen sys_mmap g_pn sys_mmap ↻ sys_write ↻ dini 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 ↻

structs

none

consts

15const Q16: i64 = 65536
16const STRIDE: i64 = 320

functions

19func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
20func 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
21func expand(tok: i64, ma: *i64, mb: *i64, out: *u8, w: *i64) -> i64
called by 2: expandmain calls 1: expand
26func 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
54func step_all(tape: *i64, grads: *i64, W: *i64, WN: *i64, leaves: *i64, lr: i64, clip: i64, gb: *i64) -> i64
called by 1: do_train calls 2: nfa_gradnfa_sgd
59func 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
called by 1: main calls 3: clm_fwdnfa_backwardstep_all
64func 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: main
65func main() -> i64