code wiki / _hdl_build / nx_f32_bricks_hw_gate.nx
nx_f32_bricks_hw_gate.nx
buildroot/runtime/_hdl_build/nx_f32_bricks_hw_gate.nx
about
nx_f32_bricks_hw_gate.nx -- DIFFERENTIAL gate for the hardware twins of three f32 tower bricks (nx_f32_gelu,
nx_f32_layernorm, nx_f32_softmax, 2026-09-14): each twin must return the IDENTICAL bits to the software oracle it
replaced (the _sw body kept verbatim in the same file) over a dense grid and over pseudo-random rows, so "IEEE
round-to-nearest on both sides" is measured, never assumed. Planted controls prove the comparator can fail: one
input nudged by one ulp must change the answer, and a perturbed gamma must change a LayerNorm row. Declared in
organ_gate.conf. expect_exit: 0 license_tier: ORIGINAL
dependencies 7 imports · 0 importers
imports: nx_gate_verdict.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nxnx_f32_gelu.nxnx_f32_layernorm.nxnx_f32_softmax.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 BH_GRID: i64 = 4096 // grid points across the range below |
| 16 | const BH_RANGE: i64 = 16 // gelu/erf grid spans -8..+8, the region where erf is not saturated |
| 17 | const BH_HALF_RANGE: i64 = 8 |
| 18 | const BH_ROWS: i64 = 16 |
| 19 | const BH_DIM: i64 = 64 |
| 20 | const BH_NOISE_MUL: i64 = 1103515245 // LCG multiplier (Knuth/glibc), a published PRNG constant, not a tunable |
| 21 | const BH_NOISE_INC: i64 = 12345 |
| 22 | const BH_NOISE_MASK: i64 = 0x7fffffff |
| 23 | const BH_NOISE_SPAN: i64 = 1000 // pseudo-random values land in -4.000 .. +4.000 (thousandths) |
| 24 | const BH_NOISE_CENTER: i64 = 4000 |
| 25 | const BH_MILLI: i64 = 1000 |
| 26 | const BH_EPS_MICRO: i64 = 1 // LayerNorm eps 1e-6 as micro units |
| 27 | const BH_MICRO: i64 = 1000000 |
functions
| 30 | func bh_noise() -> i64 { g_bh_seed = (g_bh_seed * BH_NOISE_MUL + BH_NOISE_INC) & BH_NOISE_MASK; return g_bh_seed } called by 1: bh_rand_f32 |
| 32 | func bh_rand_f32() -> i64 |
| 37 | func main() -> i64 |