code wiki / (root) / nx_pool_stale_gate.nx

nx_pool_stale_gate.nx

buildroot/runtime/nx_pool_stale_gate.nx

8243 B177 linesdepth 7pulls 9 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_pool_stale_gate.nx -- STRESS REPRODUCER for the 2026-07-15 run-to-run greedy divergence (proven by exact-repeat 1.5B ruler runs: identical binary+args+weights, different outputs at near-tie forks; 0.5B byte-stable). Hypothesis class: a pooled op's nx_pool_wait(done0+bands) occasionally returns with a band UNFINISHED (early wake / counter anomaly / ctx hijack) -> the next stage reads a stale band -> perturbed logits flip ties. This gate hammers the EXACT usage idiom of nx_nofloat_llm's pooled kernels (delta-wait + shared ctx arena + shared activation scratch, band-parallel disjoint writes) at high op counts and CHECKS three invariants after EVERY wait: I1 STAMP every band wrote its per-op serial stamp (no missing/unfinished band) I2 VALUE every band's dst equals the exact expected sum of THIS op's activations (no stale-input read, no hijacked-ctx compute) I3 COUNTER tasks_completed advanced by exactly +bands across the wait (no over/under-count) Any violation prints op#, band, got/want and the gate goes RED = reproducer captured. A clean 200k-op run is evidence the race is NOT in this idiom (pool+chan+wait) and the hunt moves up/down a layer. T1: 200k ops x n_workers bands, zero violations T2 NEG-CONTROL: sabotage mode (one band deliberately not submitted, wait shortened) MUST be caught by I1 Return from main (pool reap). No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_thread_pool.nx nx_pool_stale_gate.nx

imports: nx_syscalls.nxnx_thread_pool.nx

imported by: nobody (leaf or entry point)

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

main psg_w sys_write nx_pool_new nx_hw_worker_count nx_hw_cpu_count sys_mmap sys_munmap sys_mmap ↻ nx_chan_new sys_mmap ↻ _nx_chan_cell sys_thread_create nx_thread_spawn sys_mmap ↻ nx_thread_spawn_fn sys_mmap ↻ psg_n psg_w ↻ sys_mmap ↻ sys_write ↻ sys_mmap ↻ sys_now_ms sys_mmap ↻ sys_clock_gettime_mono 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

structs

none

consts

20const PSG_N: i64 = 4096 // activation length per op
21const PSG_OPS: i64 = 200000 // ops (~70 tokens' worth of 1.5B submit volume)

functions

28func psg_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: psg_nmain calls 1: sys_write
29func psg_n(v: i64) -> i64
called by 1: main calls 3: psg_wsys_mmapsys_write
45func _psg_task(ctx_i: i64) -> i64
60func main() -> i64