code wiki / _hdl_build / nx_fnet_model_gate.nx

nx_fnet_model_gate.nx

buildroot/runtime/_hdl_build/nx_fnet_model_gate.nx

13133 B285 linesdepth 6pulls 15 transitivereach 0 importersview sourcekind gate/prooftopic fnet
docsdependenciesstructsconstsfunctions

about

nx_fnet_model_gate.nx -- GATE for MODEL-001: the FIRST end-to-end sovereign SUB-QUADRATIC MODEL. A real sequence classifier with no attention anywhere: tokens -> EMBED (trained) -> FNET token-mix (sub-quadratic) -> relu FFN -> linear -> softmax-CE Trained by AdamW JOINTLY over the embedding table + FFN/head weights. The embedding has no attention matrix and no quadratic cost -- token mixing is the parameter-free Fourier transform. Embeddings are trained without a dedicated op: the tape yields dL/dx at the input leaf, which is SCATTERED back into the embedding rows. Task: classify whether token[0] > token[3] over 8 length-4 sequences (vocab 4). This genuinely needs the FNet to MIX positions 0 and 3 and the relu to compare -- a bag-of-words linear model cannot do it. G_train the model learns: accuracy >= 7/8 AND final loss < first loss. G_repro bit-exact: train twice -> identical accuracy + final loss bits. Evidence -> knowledge/status/fnet_model.log (FNETMODELGATE authored=organ ... verdict=GREEN). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_autograd_tensor.nx nx_syscalls.nx nx_fnet_model_gate.nx

imports: nx_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

main sys_mmap mo_train ta_det_init ta_constf 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 sys_mmap ↻ ta_constf ↻ mo_build ta_leaf ta_new sys_mmap ↻ mo_embed ta_fnet ta_new ↻ sys_mmap ↻ fnet_mix_f32 sys_mmap ↻ fftf_twiddles fftf_q16_to_f32 fx_cos fx_sin fftf_fwd nx_fft_log2 nx_fft_bit_reverse nx_f32_sub nx_f32_mul nx_f32_add ta_relu ta_new ↻ nx_f32_gt nx_f32_lt nx_f32_is_nan

structs

none

consts

18const MV: i64 = 4 // vocab
19const MN: i64 = 4 // sequence length
20const MD: i64 = 4 // d_model
21const MH: i64 = 8 // FFN hidden
22const MC: i64 = 2 // classes
23const MND: i64 = 16 // MN*MD (flattened FNet output)
25const MO_LOG: *u8 = "knowledge/status/fnet_model.log"

functions

27func mo_w(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 1: main calls 1: sys_write
28func mo_wn(fd: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
40func mo_embed(E: *i64, seq: *i64, soff: i64, xout: *i64) -> i64
called by 2: mo_buildmo_predict
52func mo_fwd(tape: *i64, vals: *i64, st: *i64, x: *i64, nW1: i64, nb1: i64, nW2: i64, nb2: i64) -> i64
61func mo_build(tape: *i64, vals: *i64, st: *i64, E: *i64, W1: *i64, b1: *i64, W2: *i64, b2: *i64,
92func mo_predict(tape: *i64, vals: *i64, st: *i64, E: *i64, W1: *i64, b1: *i64, W2: *i64, b2: *i64, seqs: *i64, s: i64) -> i64
106func mo_adamw(p: *i64, m: *i64, v: *i64, g: *i64, n: i64, lr: i64, beta1: i64, beta2: i64, om1: i64, om2: i64, eps: i64, c1: i64, c2: i64) -> i64
121func mo_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, E: *i64, W1: *i64, b1: *i64, W2: *i64, b2: *i64,
207func main() -> i64