code wiki / _hdl_build / _t4b_closed_loop_authored.nx

_t4b_closed_loop_authored.nx

buildroot/runtime/_hdl_build/_t4b_closed_loop_authored.nx

20156 B465 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

_t4b_closed_loop_authored.nx -- T4b: the CLOSED-LOOP FIRST TURN. The first model trained EXCLUSIVELY on team-generated, gate-verified data: the synthesis corpus (knowledge/library/synth_corpus.log SYNTH rows). Task: expr -> spec (which spec does this team-synthesized expression solve), an exact 7-class mapping (verified conflict-free). Uses the NEW verified-gradient CE loss (tg_celoss op 6, gradcheck-gated) -- the one-hot-MSE workaround is retired on its first outing. The T4 lesson set is APPLIED, not rediscovered: centered features, inverse-frequency class weights, full-batch accumulation + gated AdamW, deterministic early stop. Emits a machine-readable training report (knowledge/status/train_report_t4b.log TRIAGE-* rows) for the nx_train_triage organ. GATES: P parse+dict+consistency (identical features MUST agree on the label -- the under-determined-data check) | Q trained to 100% (per-class pred counts == data counts, loss decreased) | R BIT-EXACT two-run. Tamper hook: argv[1] corpus path override. LAWS: struct-free, flat ifs, no &&/||, no unary-minus literals. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_tgrad_core.nx _t4b_closed_loop_authored.nx

imports: nx_tgrad_core.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main _tg_puts sys_write sys_openat_append b4_fp b4_fn sys_now_realtime_sec sys_mmap sys_clock_gettime_real b4_parse sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close b4_match b4_nameq _tg_num sys_mmap ↻ sys_write ↻ b4_bp _tg_puts ↻ b4_fp ↻ b4_bn _tg_num ↻ b4_fn ↻ nx_f32_neg tg_q nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 nx_i32_to_f32 ↻ nx_f32_div ↻ b4_train

structs

none

consts

16const B4_EPOCHS: i64 = 2000
17const B4_LOGEVERY: i64 = 100
18const B4_INB: i64 = 24
19const B4_HID: i64 = 16
20const B4_MAXCLS: i64 = 16
21const B4_MAXROWS: i64 = 256

functions

23func b4_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 2: b4_bpmain
24func b4_fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
called by 2: b4_bnmain
25func b4_bp(fd: i64, s: *u8) -> i64 { _tg_puts(s); b4_fp(fd, s); return 0 }
called by 1: main calls 2: _tg_putsb4_fp
26func b4_bn(fd: i64, v: i64) -> i64 { _tg_num(v); b4_fn(fd, v); return 0 }
called by 1: main calls 2: _tg_numb4_fn
28func b4_match(b: *u8, i: i64, n: i64, lit: *u8) -> i64
called by 1: b4_parse
37func b4_nameq(a: *u8, b: *u8) -> i64
called by 1: b4_parse
49func b4_parse(cpath: *u8, dict: *u8, nspecp: *i64, labels: *i64, exprs: *u8) -> i64
called by 1: main calls 3: sys_read_fileb4_matchb4_nameq
138func b4_fwd(w: *i64, x: *i64, nspec: i64, outv: *i64) -> i64
165func t4b_zero(w: *i64, b1o: i64, w2o: i64) -> i64
called by 1: b4_train
171func t4_initb(p: *i64, n: i64, salt: i64, den: i64) -> i64
called by 1: b4_train calls 2: nx_f32_negtg_q
183func b4_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, xs: *i64, ts: *i64, wts: *i64, cnt: i64, nspec: i64, w: *i64, curve: *i64, curven: *i64, out2: *i64) -> i64
285func main(argc: i64, argv: *i64) -> i64