code wiki / (root) / nx_f32_ffn_path_gate.nx

nx_f32_ffn_path_gate.nx

buildroot/runtime/nx_f32_ffn_path_gate.nx

4232 B118 linesdepth 10pulls 30 transitivereach 0 importersview sourcekind gate/prooftopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_ffn_path_gate.nx -- ISOLATED, host-noise-immune proof that the F32 packed range-dot cached path beats the scalar threaded matmul_t at the real FFN decode shape (m=1, k=896, n=4864 = Qwen W_gate). Both paths run in the SAME loaded conditions, so the RATIO holds even when the host is noisy (the trap that contaminated the full-forward profiler). Warms the cache first so the timed cached calls are pure SIMD dots (the fill is one-time, amortized across all tokens in the real forward). Exact-int regime (dense small-int f32) so bit-exact compare across the two different accumulation orders (scalar sequential vs 8-wide) is legitimate. Checks: 1 cached (range-dot) result == scalar matmul_t, bit-exact 2 cached path >= floor x faster than scalar over N reps (both timed threaded; ratio printed) lineage_id: f32_ffn_path_gate_v1

dependencies 4 imports · 0 importers

nx_f32_lazy_weight.nx nx_f32_matmul_t.nx nx_f32_cvt.nx nx_fmt.nx nx_f32_ffn_path_gate.nx

imports: nx_f32_lazy_weight.nxnx_f32_matmul_t.nxnx_f32_cvt.nxnx_fmt.nx

imported by: nobody (leaf or entry point)

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

main fg_fill fg_lcg nx_i32_to_f32 nx_lw_shared_pool nx_pool_is_native nx_f32_matmul_t_pool sys_mmap nx_pool_n_completed nx_atom_load_i64 nx_pool_submit nx_atom_faa_i64 nx_chan_send nx_chan_try_send _nx_chan_cell nx_thread_yield _pool_futex_wake_all sys_futex_wake nx_pool_wait nx_atom_load_i64 ↻ nx_thread_yield ↻ nx_atom_store_i64 _pool_futex_wait sys_futex_wait sys_munmap nx_f32_lazy_weight_new_f32 sys_mmap ↻ fg_poison nx_f32_lazy_matmul nx_f32_matmul_t_pool ↻ nx_lw_shared_pool ↻ _lw_try_fill _lw_budget sys_mmap ↻ nx_lw_shared_pool ↻ nx_pool_n_completed ↻ nx_pool_submit ↻ nx_pool_wait ↻ sys_munmap ↻ _lw_cached_matmul

structs

none

consts

27const FK: i64 = 896 // hidden
28const FN: i64 = 4864 // ffn (W_gate n)
29const FREPS: i64 = 200
30const FFLOOR_X100: i64 = 150

functions

32func fg_lcg(s: i64) -> i64
called by 1: fg_fill
38func fg_fill(p: *i64, count: i64, seed: i64, half: i64) -> i64
called by 1: main calls 2: fg_lcgnx_i32_to_f32
48func fg_same(a: *i64, b: *i64, count: i64) -> i64
called by 1: main
53func fg_poison(p: *i64, count: i64) -> i64
called by 1: main
58func fg_nl() -> i64 { fmt_puts("\n" as *u8); return 0 }
called by 1: main calls 1: fmt_puts
60func main() -> i64