Expand description
CPU forward-pass primitives: RMS-norm, SiLU, sparse SwiGLU FFN.
Functions§
- add_
rmsnorm_ fused_ into - Fused residual addition and RMSNorm into a caller-owned buffer:
h += delta, thenout = rms_norm(h, weight). This avoids a separate pass overhfor the residual addition and sum of squares. - gelu_
tanh - SiLU activation function.
tanh-approximated GELU (Gemma’s GeGLU gate; HF
gelu_pytorch_tanh). - rms_
norm - RMS normalization with explicit weight semantics.
- rms_
norm_ into rms_normwriting into a caller-owned buffer — the decode hot path calls this twice per layer; the returning variant allocated each time.- silu
- sparse_
ffn_ forward - Sparse SwiGLU FFN: compute only
active_indicesneurons. - sparse_
ffn_ forward_ pair - Fused two-position sparse FFN: gate/up/down weight rows are streamed from memory ONCE for both positions. Bit-identical to two single calls (per-position accumulation order is unchanged).