code wiki / (root) / nx_nofloat_moe_real_gate.nx

nx_nofloat_moe_real_gate.nx

buildroot/runtime/nx_nofloat_moe_real_gate.nx

15039 B311 linesdepth 9pulls 19 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_moe_real_gate.nx -- MoE rung 3 (2026-07-15): REAL MoE WEIGHTS, LAZILY. Loads a real sparse-MoE gguf (OLMoE-1B-7B: 64 experts, top-8, per-expert ff=1024, D=2048 -- the canonical small real MoE) and runs ONE real MoE-FFN through our integer machinery with LAZY PER-SELECTED-EXPERT dequant -- the design the operator's environment correction settled (dequant-once-everything is the WRONG shape for MoE; sparsity means only K experts' weights are touched per token, so fetch exactly those). Composes the proven pieces: nac_read_config (+ the MoE metadata keys), nx_gguf 3-D tensor info, dequant_row / dequant_to_q16 windows, mm_out_in / fx_exp / silu / qmul. HONEST SCOPE: this rung proves REAL-WEIGHT ROUTING + LAZY FETCH + THE MIX MECHANISM on blk.0 -- NOT a faithful OLMoE model output (full arch = QK-norm etc., a later rung). T1 MoE METADATA read from the model itself: expert_count=64, expert_used_count=8 (olmoe.* keys) T2 3-D expert tensors located, dims EXACT (gate/up [D,ff,E]; down [ff,D,E]; router [D,E] 2-D) T3 LAZY-SLICE LIAR-KILLER: bulk expert-slice dequant (type-aware block offset) == per-row dequant_row on sampled rows x sampled experts x gate+down, EXACT (0 mismatches) -- kills offset-math bugs T4 REAL ROUTING: top-8 = 8 distinct ids; deterministic repeat; a second input selects a DIFFERENT set (the real router discriminates -- the neg-control against constant routing) T5 REAL MIX: K experts lazily fetched (counter == 8), output dense-nonzero, byte-identical repeat Requires /home/elderwesto/nx_stage/nx_moe_model.gguf. ~4.4GB read; slices ~400MB. Return from main. No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 10 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_le.nx nx_tensor.nx nx_gguf.nx nx_gguf_load.nx nx_gguf_meta.nx nx_nofloat_llm.nx nx_nofloat_arch.nx nx_gate_verdict.nx nx_nofloat_moe_real_gate.nx

imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_tensor.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_nofloat_llm.nxnx_nofloat_arch.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 mr_w sys_write sys_mmap sys_now_ms sys_mmap ↻ sys_clock_gettime_mono sys_map_file sys_openat_rd sys_lseek sys_close mr_n mr_w ↻ sys_mmap ↻ sys_write ↻ nx_gguf_parse nx_le_read_u32 nx_le_read_u64 nx_le_read_u32 ↻ _gguf_skip_value nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gguf_skip_value ↻ sys_mmap ↻ nac_read_config sys_mmap ↻ nx_gguf_meta_find nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gmeta_bytes_equal nx_gguf_skip_value _gguf_skip_value ↻ nx_gguf_meta_read_string_l nx_le_read_u64 ↻ nx_gguf_meta_read_string_p nac_u32 sys_mmap ↻ nac_key nx_gguf_meta_find ↻ nx_gguf_meta_read_u32

structs

none

consts

none

functions

29func mr_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: mr_nmain calls 1: sys_write
30func mr_n(v: i64) -> i64
called by 1: main calls 3: mr_wsys_mmapsys_write
43func mr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
44func mr_det(i: i64) -> i64 { return ((i * 2654435761) % 8191) - 4095 }
called by 1: main
49func mr_val_byteoff(ty: i64, voff: i64) -> i64
called by 1: main calls 2: sys_mmapnf_type_stride
55func main() -> i64