code wiki / (root) / nx_native_softmax_bench.nx

nx_native_softmax_bench.nx

buildroot/runtime/nx_native_softmax_bench.nx

1870 B61 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind benchtopic native
docsdependenciesstructsconstsfunctions

about

nx_native_softmax_bench.nx -- LLM-relevant softmax kernel. One of the three kernels that dominate transformer-forward time: matmul (already measured in nx_native_matmul_bench) softmax (this bench) RMSNorm (nx_native_rmsnorm_bench) Softmax over a vector: max-subtract for numerical stability, then exp + sum + divide. Substrate uses Q10 fixed-point so "exp" is a polynomial / table approximation; here we measure the dominant-cost integer arithmetic (max + sum + division) skipping the exp step (still LLM-relevant: attention weights pass through softmax once per token per head). Workload: softmax over 2048-element vectors, 1000 iterations.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_native_softmax_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

18const K_MAGIC_2048: i64 = 2048

functions

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