code wiki / _hdl_build / nx_f32_matmul_block_gate.nx

nx_f32_matmul_block_gate.nx

buildroot/runtime/_hdl_build/nx_f32_matmul_block_gate.nx

6245 B99 linesdepth 8pulls 17 transitivereach 0 importersview sourcekind gate/prooftopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_matmul_block_gate.nx -- referee for the 4x4 register-blocked matmul_t (nx_f32_matmul_t.mmt_block, 2026-09-15). The blocked kernel claims BIT-EXACT equality with mmt_range (the serial reference every other matmul_t path is judged against) on every shape: the interior 4x4 blocks, the ragged right edge (n not a multiple of 4), the ragged bottom edge (m not a multiple of 4), both edges at once, m=1 decode rows, k below and above the block, and the cross-encoder's own shapes (T x 384 x 1536, T x 1536 x 384, T x 384 x 384). Equality is asserted on every output cell of every shape -- a tolerance would be the wrong oracle for a change that only re-interleaves independent sums. The fills are a seeded integer LCG mapped to small f32 values so every product and sum is reproducible on any host. The gate also TIMES the reference and the blocked kernel on the cross-encoder FFN shape and prints both as values (never a threshold: a storming host would make a speed tooth flaky, and the number is the evidence the plan row cites). license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_f32_matmul_t.nx nx_f32_cvt.nx nx_syscalls.nx nx_gate_verdict.nx nx_f32_matmul_block_gate.nx

imports: nx_f32_matmul_t.nxnx_f32_cvt.nxnx_syscalls.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 gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ gv_check_eq gv_check gv_puts ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap g_shape sys_mmap ↻ g_fill g_lcg nx_i32_to_f32 mmt_range nx_f32_matmul_t_blocked mmt_block sys_mmap ↻ sys_munmap ↻ g_diff_cells sys_munmap ↻

structs

none

consts

15const G_I64: i64 = 8
16const G_SEED_A: i64 = 7
17const G_SEED_B: i64 = 11
18const G_LCG_MUL: i64 = 1103515245
19const G_LCG_ADD: i64 = 12345
20const G_LCG_MASK: i64 = 2147483647
21const G_FILL_MOD: i64 = 16
22const G_FILL_OFF: i64 = 8
23const G_T: i64 = 300 // a typical nfcorpus pair length
24const G_D: i64 = 384
25const G_I: i64 = 1536
26const G_SHAPES: i64 = 12
27const G_S_W: i64 = 3
28const G_USEC: i64 = 1000000
29const G_NSEC_PER_USEC: i64 = 1000
30const G_PERMIL: i64 = 1000

functions

32func g_lcg(s: i64) -> i64 { var v: i64 = s * G_LCG_MUL + G_LCG_ADD; v = v & G_LCG_MASK; return v }
called by 1: g_fill
33func g_fill(p: *i64, count: i64, seed: i64) -> i64
called by 2: g_shapemain calls 2: g_lcgnx_i32_to_f32
39func g_same(a: *i64, b: *i64, count: i64) -> i64 { var i: i64 = 0; while i < count { if a[i] != b[i] { return 0 } i = i + 1 } return 1 }
40func g_diff_cells(a: *i64, b: *i64, count: i64) -> i64 { var d: i64 = 0; var i: i64 = 0; while i < count { if a[i] != b[i] { d = d + 1 } i = i + 1 } return d }
called by 2: g_shapemain
41func g_now_us() -> i64 { let ts: *i64 = sys_mmap(2 * G_I64) as *i64; sys_clock_gettime_mono(ts); let v: i64 = ts[0] * G_USEC + ts[1] / G_NSEC_PER_USEC; sys_munmap(ts as *u8, 2 * G_I64); return v }
43func g_shape(m: i64, k: i64, n: i64, seed: i64) -> i64
57func main() -> i64