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

10108 B157 linesdepth 3pulls 7 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 4 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_emit_lib.nx nx_gate_verdict.nx nx_nofloat_bpe_lm_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 g_puts sys_write slen 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 ↻ 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 vm_isqrt nfa_matmul nfa_new ↻ nfa_rope nfa_new ↻ nfa_fxexp nfa_cosf nfa_reduce2pi

structs

none

consts

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

functions

20func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
21func 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
22func expand(tok: i64, ma: *i64, mb: *i64, out: *u8, w: *i64) -> i64
called by 2: expandmain calls 1: expand
27func 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
55func 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
60func 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
65func 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
66func main() -> i64