nx_lw_cache_gate.nx
buildroot/runtime/nx_lw_cache_gate.nx
about
nx_lw_cache_gate.nx -- gate for the packed dequant-once cache in
nx_f32_lazy_weight (the m=1 decode lever: stop re-dequanting the
same weights every token; cached matmuls are pure packed
__f32x4_dot bands).
Exact-f32 regime construction as in nx_q4k_matmul_x4_gate (dense
d=1.0/sc=1 blocks -> integer dequant values 0..15; int A; all
|sums| < 2^24), so bit-exact comparison between the CACHED path
(x4 dot order) and the scalar streaming oracle is legitimate.
Checks (8):
1 scalar oracle OK (k=512, n=37, m=3)
2 first dispatch fills + matches oracle; pk_state=1; used bytes exact
3 second dispatch (new A) matches fresh oracle (cache reuse +
shared-pool delta-wait across fill+dot submissions)
4 m=1 decode shape via dispatcher matches oracle
5 budget refusal: fresh weight + tiny budget -> pk_state=-1 AND
result still matches oracle (streamed scalar-pool fallback)
6 stale k=1 shape surfaces NX_LW_ERR_INNER (guard before cache)
7 decode-shape speedup: cached reps vs streamed reps (same data,
bit-exact) -- floor cached >= 1.5x streamed; first-call fill
overhead printed for the honest record
8 cached and streamed big-shape outputs bit-identical
lineage_id: lw_cache_gate_v1
dependencies 3 imports · 0 importers
imports: nx_gate_verdict.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
structs
| none |
consts
| 31 | const LG_M: i64 = 3 |
| 32 | const LG_K: i64 = 512 |
| 33 | const LG_N: i64 = 37 |
| 35 | const LB_K: i64 = 1024 |
| 36 | const LB_N: i64 = 4864 |
| 37 | const LB_REPS: i64 = 3 |
| 39 | const LG_SPEEDUP_FLOOR_X100: i64 = 150 |
functions
| 41 | func l_lcg(s: i64) -> i64 |
| 47 | func l_block_dense(buf: *u8, off: i64, seed: i64) -> i64 |
| 69 | func l_fill_weights(buf: *u8, n_rows: i64, k: i64, seed: i64) -> i64 |
| 85 | func l_fill_a(p: *i64, count: i64, seed: i64, half: i64) -> i64 |
| 97 | func l_poison(p: *i64, count: i64) -> i64 called by 1: lwc_run |
| 107 | func l_same(a: *i64, b: *i64, count: i64) -> i64 called by 1: lwc_run |
| 116 | func l_nl() -> i64 |
| 121 | func lwc_run() -> i64 called by 1: main calls 13: l_fill_al_fill_weightsnx_lw_set_cache_budgetnx_f32_q4k_matmulfmt_putsl_nl+7 |
| 280 | func main() -> i64 |