nx_native_softmax_bench.nx
buildroot/runtime/nx_native_softmax_bench.nx
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
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
| 18 | const K_MAGIC_2048: i64 = 2048 |
functions
| 20 | func main() -> i64 calls 1: sys_mmap |