code wiki / (root) / nx_native_rmsnorm_bench.nx

nx_native_rmsnorm_bench.nx

buildroot/runtime/nx_native_rmsnorm_bench.nx

1855 B63 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind benchtopic native
docsdependenciesstructsconstsfunctions

about

nx_native_rmsnorm_bench.nx -- LLM-relevant RMSNorm kernel. Third dominant kernel in transformer-forward (matmul + softmax + RMSNorm = the trio). RMSNorm = rsqrt(mean(x^2) + eps) * x. Per-token, per-residual-stream-position, per-layer (so for a 22-layer Llama with 2048 tokens, 22 * 2048 = ~45k RMSNorm calls). Workload: RMSNorm over a 2048-element residual stream, 5000 iterations. Per iteration: dot product of x with itself, divide by N, integer sqrt approximation, then multiply each element. The substrate uses Q10 fixed-point. Integer sqrt is via Newton iteration; we measure the dot product + divide + multiply-back loop, skipping the sqrt step.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_native_rmsnorm_bench.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap

structs

none

consts

17const K_MAGIC_2048: i64 = 2048
18const K_MAGIC_5000: i64 = 5000

functions

20func main() -> i64
calls 1: sys_mmap