code wiki / _hdl_build / nx_t2lm_register.nx

nx_t2lm_register.nx source

↩ module page · 38 lines · 3242 B

1// nx_t2lm_register.nx -- registers T2 rung 2a (first language model) via the Librarian. 2// ENGINEER evidence = the 4-gate LM module re-run RIGHT HERE. license_tier: ORIGINAL 3import "nx_cap_register.nx" 4import "nx_capreg_librarian.nx" 5import "nx_syscalls.nx" 6 7func lmr_run(path: *u8) -> i64 { 8 let pid: i64 = sys_fork() 9 if pid == 0 { 10 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 11 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 12 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0 13 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 14 sys_execve(path, argv, envp); sys_exit(127) 15 } 16 let st: *i64 = sys_mmap(16) as *i64 17 sys_wait4(pid, st, 0) 18 return st[0] 19} 20 21func main() -> i64 { 22 var allok: i64 = 1 23 if lmr_run("/tmp/_t2_bigram_lm_authored.sov.elf" as *u8) != 0 { allok = 0 } 24 cr_w(1, "ENGINEER: T2-LM gate (vocab-reload / analytic-oracle / context-used / bit-exact) pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8) 25 let eng: i64 = ig_engineer(1, 1, 1, allok) 26 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1) 27 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) } 28 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 29 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 30 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 31 let idx: i64 = cl_next_idx(lp, jp) 32 let ok: i64 = cl_register_dual(lp, jp, idx, 5, 33 2, "GEN T2-RUNG2a FIRST-LANGUAGE-MODEL (training-substrate ladder; MODELWRIGHT). _t2_bigram_lm_authored = next-token model over the TRAINED BPE vocab (RELOADED from knowledge/store/bpe_vocab_v1.txt -- proves the persisted vocab round-trips into a consumer) on the team corpus. Smallest honest LM: logits = W[cur] (320x320, multiclass logistic regression = CONVEX so zero-init exact, no symmetry trap), verified-CE loss (op6, softmax now CACHED in node field 7 at forward -- measured keystone, backward exp-free; gradcheck + T4b re-proven green on the changed core), full-batch accumulation + gated AdamW, deterministic early stop. THE ORACLE IS ANALYTIC: optimal cross-entropies computed in closed form from integer counts of the SAME token stream (H_uni=4061 millinat, H_bigram=1218, midpoint 2639). GATES 4/4: V vocab reload (64 BPEMERGE rows); O structure exists (H_bi < H_uni, analytic); L LEARNED final CE 2482 millinat < H_uni AND <= midpoint = the model PROVABLY uses context (distance-to-optimum 444 permil of the gap, reported never asserted; converged ep19); B bit-exact two-run 102400 cells. Deterministic greedy sample generates corpus-shaped text (SYNTH verdict=...). Emits TRIAGE report train_report_t2lm.log -> third lane in train_reports.conf (live sweep: CONVERGED-HEALTHY). Token cap printed never silent (1200 of 6813). NEXT: hidden-state LM (matmul node + nonlinear context compression) -> tiny decoder w/ attention backward -> RLVR on synthesis verdicts" as *u8) 34 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) } 35 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED via Librarian alloc+dual-write (T2 rung 2a first language model)\n" as *u8) 36 sys_exit(0) 37 return 0 38}