l2norm_rows

Function l2norm_rows 

Source
pub fn l2norm_rows(x: &[f32], d: usize, eps: f32) -> Vec<f32>
Expand description

x / sqrt(sum(x^2) + eps) over the trailing dimension.

Deliberately not x / max(norm, eps). HF’s l2norm adds eps inside the square root to match the original FLA triton kernel, and the vLLM kernels do the same (b_q / tl.sqrt(tl.sum(b_q * b_q) + 1e-6)). The two forms differ for small-norm rows.