nx_moe_gate.nx
buildroot/runtime/nx_moe_gate.nx
about
nx_moe_gate.nx -- MEASURED gate for the sovereign MoE sparse FFN
(nx_moe). PURE (no model, fast):
NEG alloc rejects k > n_experts and zero dims
ROUTE organ's top-k == an INDEPENDENT largest-logits scan (same
tie rule); renormalized probs sum to 1 within 2^-15
ONE==FFN n_experts=1, top_k=1: nx_moe_forward BIT-EXACT equals the
bare expert FFN (softmax(single)=1.0 exactly, p*y=y)
SPARSE n=8, k=2, m=3: touch counters total EXACTLY m*k=6 -- the
sparsity is measured, not asserted
MIX forward's accumulation BIT-EXACT vs an oracle assembling
route + expert_ffn + p-weighted sum in the same documented
order
DET forward twice -> identical bits
license_tier: ORIGINAL expect_exit: 0
dependencies 10 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nxnx_f32_softmax.nxnx_f32_matmul_t.nxnx_f32_activations.nxnx_moe.nxnx_fmt.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
| 60 | const MG_HD: nx_int = 8 |
| 61 | const MG_FD: nx_int = 16 |
functions
| 29 | func mg_nl() -> i64 { fmt_puts("\n" as *u8); return 0 } |
| 30 | func mg_lcg(s: i64) -> i64 { var v: i64 = s * 1103515245 + 12345; v = v & 2147483647; return v } called by 1: mg_fill |
| 31 | func mg_fill(p: *i64, n: nx_int, state: *i64) -> i64 |
| 43 | func mg_fill_layer(L: *NxMoeLayer, state: *i64) -> i64 |
| 54 | func mg_cmp(a: *i64, b: *i64, n: nx_int) -> i64 called by 1: main |
| 63 | func main() -> i64 |