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
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
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
structs
| none |
consts
| 15 | const Q16: i64 = 65536 |
| 16 | const STRIDE: i64 = 320 |
functions
| 19 | func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: main |
| 20 | 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 |
| 21 | func expand(tok: i64, ma: *i64, mb: *i64, out: *u8, w: *i64) -> i64 |
| 26 | 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_trainmain calls 10: nfa_leafnfa_embednfa_rmsnorm_rowsnfa_matmulnfa_ropenfa_matmul_nt+4 |
| 54 | func step_all(tape: *i64, grads: *i64, W: *i64, WN: *i64, leaves: *i64, lr: i64, clip: i64, gb: *i64) -> i64 |
| 59 | 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 |
| 64 | 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: main |
| 65 | func main() -> i64 |