code wiki / (root) / nx_nofloat_moe_gate.nx

nx_nofloat_moe_gate.nx

buildroot/runtime/nx_nofloat_moe_gate.nx

11364 B285 linesdepth 9pulls 18 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_moe_gate.nx -- gates the no-float MoE FFN layer (MoE rung 1, 2026-07-15). The lib does router -> deterministic top-K -> fx_exp softmax -> K SwiGLU experts -> weighted mix, all Q16 integer. Teeth (every one deterministic; an INDEPENDENT serial reference implementation lives in THIS file with REVERSED reduction orders -- exact integer sums are order-free, so lib and reference must agree to the BIT): T1 EXACT vs the independent reverse-order reference on 3 distinct inputs (0 mismatched cells) T2 determinism: repeat call byte-identical (and T1's order-reversal already proves order-invariance) T3 sparsity REAL + router alive: exactly K experts computed per forward (cnt), >=2 distinct experts selected across the 3 inputs (the router discriminates; selections logged) T4 NEG-CONTROLS: (a) corrupting one router row CHANGES a selection (routing is weight-driven, not fabricated); (b) dense K=E output DIFFERS from sparse K=2 (sparsity has measurable effect) T5 work happened: >= half the output cells nonzero on every input Synthetic Q16 weights/inputs from a fixed integer formula (no randomness, no clock). Runs in ms. expect_exit: 0 license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_nofloat_moe.nx nx_gate_verdict.nx nx_nofloat_moe_gate.nx

imports: nx_syscalls.nxnx_nofloat_moe.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main mg_w sys_write sys_mmap mg_det nmoe_forward mm_out_in fx_exp qmul silu qmul ↻ sigmoid fx_exp ↻ mg_ref_forward mg_ref_dot_rev silu ↻ mg_n mg_w ↻ sys_mmap ↻ sys_write ↻ gv_ctr sys_mmap ↻ gv_verdict gv_puts sys_write ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real gv_cat sys_write ↻

structs

none

consts

none

functions

18func mg_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: mg_nmain calls 1: sys_write
19func mg_n(v: i64) -> i64
called by 1: main calls 3: mg_wsys_mmapsys_write
33func mg_det(i: i64) -> i64 { return ((i * 2654435761) % 8191) - 4095 }
called by 1: main
36func mg_ref_dot_rev(a: *i64, W: *i64, o: i64, ind: i64) -> i64
called by 1: mg_ref_forward
42func mg_ref_forward(mp: *i64) -> i64
called by 1: main calls 2: mg_ref_dot_revsilu
110func main() -> i64