code wiki / _hdl_build / _t4_first_model_authored.nx
_t4_first_model_authored.nx
buildroot/runtime/_hdl_build/_t4_first_model_authored.nx
about
_t4_first_model_authored.nx -- T4 of the training-substrate ladder: the FIRST REAL MODEL.
Composes the GATED T6/T5 core (nx_tgrad_core.nx, extracted verbatim from _tensor_grad_authored.nx)
into two trained models, all bits-up sovereign f32, zero randomness:
LANE 1 (nonconvex proof): XOR via a 2-4-1 relu MLP + AdamW, deterministic symmetry-breaking
init (the zero-init relu trap documented at T6 is closed by a FIXED pattern table, not RNG --
gate-proven here; the principled-init research row stays open in the roadmap).
LANE 2 (REAL TEAM DATA): 8-way service-class model on the ACTUAL elder census
(knowledge/status/elder_census.log) -- first 6 name bytes -> {svc,gen,data,orch,worker,mon,util,other}.
PARSE ORACLE: the census file carries its own ground truth (CENSUS-SUM per-class counts);
the parsed+deduped dataset must match it EXACTLY before training is even attempted.
GATES: O census-parse==CENSUS-SUM oracle | G XOR learned (loss<1/100, 4/4 preds within 1/4)
| H census train accuracy == services (100%, per-class pred counts == ground truth)
| I BIT-EXACT two-run training, BOTH lanes (the standing EXCEED axis).
Evidence: loss curve + verdicts appended to knowledge/status/modelwright.log (MODELWRIGHT rows
= the role's first durable evidence; the scorecard reads this file).
LAWS: struct-free, flat ifs, no &&/||, no unary-minus literals, no randomness. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
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
structs
| none |
consts
| 19 | const T4_XOR_EPOCHS: i64 = 1500 |
| 20 | const T4_CEN_EPOCHS: i64 = 1500 |
| 21 | const T4_LOG_EVERY: i64 = 100 |
| 22 | const T4_HID: i64 = 24 |
| 23 | const T4_INB: i64 = 8 |
| 24 | const T4_NCLS: i64 = 8 |
| 25 | const T4_MAXSVC: i64 = 200 |
functions
| 28 | func t4_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 } |
| 29 | func t4_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 } |
| 31 | func t4_bp(fd: i64, s: *u8) -> i64 { _tg_puts(s); t4_fp(fd, s); return 0 } |
| 32 | func t4_bn(fd: i64, v: i64) -> i64 { _tg_num(v); t4_fn(fd, v); return 0 } |
| 36 | func t4_init(p: *i64, n: i64, salt: i64, den: i64) -> i64 |
| 47 | func t4_match(b: *u8, i: i64, n: i64, lit: *u8) -> i64 |
| 57 | func t4_tokeq(b: *u8, i: i64, le: i64, lit: *u8) -> i64 called by 1: t4_classid |
| 69 | func t4_keynum(b: *u8, ls: i64, le: i64, key: *u8) -> i64 |
| 88 | func t4_classid(b: *u8, i: i64, le: i64) -> i64 |
| 99 | func t4_nameq(a: *u8, b: *u8) -> i64 called by 1: t4_parse |
| 112 | func t4_parse(cpath: *u8, names: *u8, labels: *i64, sums: *i64) -> i64 |
| 183 | func t4_featurize(names: *u8, labels: *i64, cnt: i64, xs: *i64, ts: *i64) -> i64 |
| 210 | func t4_w1n() -> i64 { return T4_HID * T4_INB } |
| 211 | func t4_b1o() -> i64 { return t4_w1n() } |
| 212 | func t4_w2o() -> i64 { return t4_w1n() + T4_HID } |
| 213 | func t4_b2o() -> i64 { return t4_w2o() + T4_NCLS * T4_HID } |
| 214 | func t4_tot() -> i64 { return t4_b2o() + T4_NCLS } |
| 217 | func t4_cen_fwd(w: *i64, x: *i64, out8: *i64) -> i64 |
| 249 | func t4_cen_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, xs: *i64, ts: *i64, wts: *i64, cnt: i64, w: *i64, logfd: i64, out2: *i64, curve: *i64, curven: *i64) -> i64 |
| 358 | func t4_xor_fwd(w: *i64, x0: i64, x1: i64) -> i64 |
| 376 | func t4_xor_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, w: *i64, out2: *i64) -> i64 |
| 436 | func main(argc: i64, argv: *i64) -> i64 |