nx_native_rmsnorm_bench.nx
buildroot/runtime/nx_native_rmsnorm_bench.nx
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
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
structs
| none |
consts
| 17 | const K_MAGIC_2048: i64 = 2048 |
| 18 | const K_MAGIC_5000: i64 = 5000 |
functions
| 20 | func main() -> i64 calls 1: sys_mmap |