Last updated: 2026-06-12

Inference Runtime

Residual Rms Norm

All API Sections

T-CPU residual add + RMS norm implementation.

Computes: output = weight * rms_norm(x + residual)

2 exports shown

struct

Params

#
pub const Params = struct

Inputs and outputs for one fused residual-add + RMS-norm call.

Parameters

x
Hidden state to normalize after residual addition.
residual
Residual contribution added element-wise to `x` before normalization.
weight
Per-channel learned scale applied after RMS normalization.
output
Destination hidden state of length `>= x.len`.
eps
Small constant added inside the square root to keep division numerically stable.

src/zinc_rt/isa/cpu_zig/residual_rms_norm.zig:12

function

run

#
pub fn run(params: Params) !void

Compute `output = weight * (x + residual) / sqrt(mean((x + residual)^2) + eps)`.

Fuses the post-attention/post-MLP residual add with the RMS norm so the sum lives only in registers; matches the GPU kernel that the Vulkan path uses on the decode hot loop. companion slice is shorter than `x`, otherwise void.

Parameters

params
Inputs, residual, learned scale, output slice, and `eps`; see `Params`.

Returns

`error.EmptyInput` when inputs are zero-length, `error.ShapeMismatch` when any

src/zinc_rt/isa/cpu_zig/residual_rms_norm.zig:26