code wiki / (root) / nx_f32_rmsnorm.nx

nx_f32_rmsnorm.nx

buildroot/runtime/nx_f32_rmsnorm.nx

2948 B86 linesdepth 4pulls 6 transitivereach 78 importersview sourcekind librarytopic f32
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_f32.nx nx_f32_div.nx nx_f32_cvt.nx nx_f32_rmsnorm.nx nx_f32_dit_block_tiny.nx nx_f32_llama_block.nx nx_f32_llama_block_test.nx nx_f32_llama_block_v4.nx nx_f32_llama_block_v4_test.nx nx_f32_llama_v4b.nx nx_f32_llama_v4p.nx nx_f32_llm.nx nx_f32_llm_probe.nx nx_f32_llm_v4.nx

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

31const NX_F32_RMSN_ONE: i64 = 0x3F800000 // 1.0
32const NX_F32_RMSN_OK: nx_int = 0
33const NX_F32_RMSN_ERR_BAD_DIM: nx_int = 1
34const NX_F32_RMSN_N_VERDICTS: nx_int = 2

functions

36func nx_f32_rmsnorm_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
51func nx_f32_rmsnorm(x: *i64, gamma: *i64, n: nx_int,