code wiki / _hdl_build / nx_f32_miniqwen_train_gate.nx
nx_f32_miniqwen_train_gate.nx
buildroot/runtime/_hdl_build/nx_f32_miniqwen_train_gate.nx
dependencies 4 imports · 0 importers
imports: nx_gate_gn.nxnx_gate_base.nxnx_autograd_tensor.nxnx_syscalls.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
| 23 | const VMAX: i64 = 40 |
| 24 | const DM: i64 = 32 // model dim = head_dim (single head, v1) |
| 25 | const HF: i64 = 64 // FFN hidden |
| 26 | const NLAYERS: i64 = 2 |
| 27 | const TMAX: i64 = 64 |
| 28 | const EPOCHS: i64 = 1400 |
| 29 | const NODES: i64 = 128 |
| 30 | const CELLS: i64 = 200000 |
functions
| 32 | func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" calls 1: gw |
| 34 | func gm(x: i64) -> i64 { return gn(ta_f32_to_milli(x)) } |
| 35 | func f32c(a: i64, b: i64) -> i64 { return nx_f32_div(nx_i32_to_f32(a), nx_i32_to_f32(b)) } called by 1: main |
| 36 | func f32_absx(x: i64) -> i64 { return x & 0x7FFFFFFF } |
| 37 | func f32_lex(x: i64, y: i64) -> i64 { if nx_f32_gt(x,y)==1 { return 0 } return 1 } |
| 38 | func f32_sqrtx(x: i64) -> i64 { if (x & 0x7FFFFFFF)==0 { return nx_i32_to_f32(0) } var y: i64=x; var i: i64=0; while i<16 { y=nx_f32_div(nx_f32_add(y, nx_f32_div(x,y)), nx_i32_to_f32(2)); i=i+1 } return y } |
| 41 | func build_rope(COS: *i64, SIN: *i64, ROT: *i64) -> i64 |
| 65 | func rope_node(tape: *i64, vals: *i64, st: *i64, xn: i64, COSn: i64, SINn: i64, ROTn: i64) -> i64 |
| 74 | func build_fwd(tape: *i64, vals: *i64, st: *i64, M: *i64, toks: *i64, T: i64, vv: i64, scale: i64, Xsrc: *i64, COS: *i64, SIN: *i64, ROT: *i64, lv: *i64) -> i64 |
| 121 | func loss_of(tape: *i64, vals: *i64, M: *i64, toks: *i64, tgt: *i64, T: i64, vv: i64, scale: i64, Xsrc: *i64, COS: *i64, SIN: *i64, ROT: *i64, lv: *i64) -> i64 |
| 127 | func det_fill(dst: *i64, n: i64, seed: i64) -> i64 { var i: i64=0; while i<n { let s: i64=(((i*2654435761)+seed) % 13) - 6; dst[i]=f32c(s, 100); i=i+1 } return 0 } |
| 128 | func argmax_row(vals: *i64, tape: *i64, lg: i64, row: i64, vv: i64) -> i64 { let off: i64=tape[7*lg+5]+row*vv; var bi: i64=0; var o: i64=1; while o<vv { if nx_f32_gt(vals[off+o], vals[off+bi])==1 { bi=o } o=o+1 } return bi } |
| 129 | func adam_step(P: *i64, Gd: *i64, Mo: *i64, Vo: *i64, cnt: i64, lr: i64, b1: i64, b2: i64, bc1: i64, bc2: i64, aeps: i64) -> i64 |
| 135 | func main() -> i64 |