code wiki / (root) / nx_q8_coldwarm.nx

nx_q8_coldwarm.nx

buildroot/runtime/nx_q8_coldwarm.nx

3696 B96 linesdepth 10pulls 30 transitivereach 0 importersview sourcekind tooltopic q8
docsdependenciesstructsconstsfunctions

about

nx_q8_coldwarm.nx -- decides the post-futex decode-matmul direction: COMPUTE-bound (kernel work: AVX2/multi-acc pays) vs COLD-STREAMING-bound (fewer bytes / batch tokens pays). Measures the SAME production Q8_0 matmul two ways at FULL-MODEL working-set scale (~209MB, like the real forward's 24 distinct layers read once/token): WARM = one weight buffer, REPS reps (cache-resident after pass 1). COLD = NB DISTINCT buffers (aggregate >> LLC), one matmul each, never reused (the forward's true access pattern). COLD/WARM ~1 -> compute-bound (kernel is the lever). COLD/WARM >>1 -> cold DRAM streaming (fewer bytes / batch is the lever). license_tier: ORIGINAL expect_exit: 0

dependencies 8 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_le.nx nx_f32.nx nx_f32_cvt.nx nx_thread_pool.nx nx_f32_lazy_weight.nx nx_fmt.nx nx_q8_coldwarm.nx

imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_f32.nxnx_f32_cvt.nxnx_thread_pool.nxnx_f32_lazy_weight.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 sys_mmap cw_lcg nx_i32_to_f32 nx_lw_shared_pool nx_pool_is_native cw_weight sys_mmap ↻ cw_lcg ↻ nx_f32_lazy_weight_new_q8_ sys_mmap ↻ sys_now_us sys_mmap ↻ sys_clock_gettime_mono nx_f32_lazy_matmul 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_lw_shared_pool ↻ _lw_try_fill _lw_budget sys_mmap ↻ nx_lw_shared_pool ↻ nx_pool_n_completed ↻

structs

none

consts

21const MK: i64 = 896
22const NG: i64 = 4864 // W_gate width; one buf = 896*4864*34/32 = 4.63MB
23const Q8B: i64 = 34
24const Q8V: i64 = 32
25const NB: i64 = 48 // 48 * 4.63MB = 222MB ~ full model, >> LLC

functions

27func cw_nl() -> i64 { fmt_puts("\n" as *u8); return 0 }
called by 2: cw_repmain calls 1: fmt_puts
28func cw_lcg(s: i64) -> i64 { var v: i64 = s * 1103515245 + 12345; v = v & 2147483647; return v }
called by 2: cw_weightmain
29func cw_weight(seed: i64) -> *NxF32LazyWeight
47func cw_rep(tag: *u8, us: i64, calls: i64) -> i64
called by 1: main calls 3: fmt_putsfmt_putncw_nl
60func main() -> i64