nx_f32_rmsnorm.nx
buildroot/runtime/nx_f32_rmsnorm.nx
about
nx_f32_rmsnorm.nx -- bits-up f32 RMSNorm.
L7 / L8 composition brick. The first ML normalization primitive
fully written in our bits-up IEEE 754 binary32 substrate:
ss = sum_i (x[i] * x[i])
mean_ss = ss / n
denom = sqrt(mean_ss + eps)
inv_denom = 1 / denom
out[i] = x[i] * gamma[i] * inv_denom
Composes:
L4 f32: mul, add, sqrt, div, cvt (i32 -> f32 for the n constant)
No libm. No compiler-builtin float. Every op routes through the
bits-up substrate from this session's arc.
Reference (the standard RMSNorm definition):
Zhang + Sennrich 2019, "Root Mean Square Layer Normalization"
(paper PDF; the math is a published recipe, no code borrowed)
genealogy_id: zhang_sennrich_2019_rms_norm + ieee754_f32_compose
lineage_id: substrate_f32_rmsnorm_v1
dependencies 5 imports · 18 importers
diagram shows first 10 each side; +0 more imports, +8 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nxnx_f32.nxnx_f32_div.nxnx_f32_cvt.nx
imported by: nx_f32_dit_block_tiny.nxnx_f32_llama_block.nxnx_f32_llama_block_test.nxnx_f32_llama_block_v4.nxnx_f32_llama_block_v4_test.nxnx_f32_llama_v4b.nxnx_f32_llama_v4p.nxnx_f32_llm.nxnx_f32_llm_probe.nxnx_f32_llm_v4.nxnx_f32_qwen_layer.nxnx_f32_rmsnorm_test.nxnx_f32_transformer.nxnx_llm_diff_probe.nxnx_llm_layerlens_probe.nxnx_qwen_hybrid_attn.nxnx_qwen_hybrid_ffn.nxnx_zimage_real_op.nx
structs
| none |
consts
| 31 | const NX_F32_RMSN_ONE: i64 = 0x3F800000 // 1.0 |
| 32 | const NX_F32_RMSN_OK: nx_int = 0 |
| 33 | const NX_F32_RMSN_ERR_BAD_DIM: nx_int = 1 |
| 34 | const NX_F32_RMSN_N_VERDICTS: nx_int = 2 |
functions
| 36 | func nx_f32_rmsnorm_verdict_is_valid(v: nx_int) -> nx_int called by 1: main |
| 51 | func nx_f32_rmsnorm(x: *i64, gamma: *i64, n: nx_int, |