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
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
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
structs
| none |
consts
| 15 | const G_I64: i64 = 8 |
| 16 | const G_SEED_A: i64 = 7 |
| 17 | const G_SEED_B: i64 = 11 |
| 18 | const G_LCG_MUL: i64 = 1103515245 |
| 19 | const G_LCG_ADD: i64 = 12345 |
| 20 | const G_LCG_MASK: i64 = 2147483647 |
| 21 | const G_FILL_MOD: i64 = 16 |
| 22 | const G_FILL_OFF: i64 = 8 |
| 23 | const G_T: i64 = 300 // a typical nfcorpus pair length |
| 24 | const G_D: i64 = 384 |
| 25 | const G_I: i64 = 1536 |
| 26 | const G_SHAPES: i64 = 12 |
| 27 | const G_S_W: i64 = 3 |
| 28 | const G_USEC: i64 = 1000000 |
| 29 | const G_NSEC_PER_USEC: i64 = 1000 |
| 30 | const G_PERMIL: i64 = 1000 |
functions
| 32 | func 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 |
| 33 | func g_fill(p: *i64, count: i64, seed: i64) -> i64 |
| 39 | func 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 } |
| 40 | func 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 } |
| 41 | func 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 } |
| 43 | func g_shape(m: i64, k: i64, n: i64, seed: i64) -> i64 |
| 57 | func main() -> i64 |