pub enum NormOp {
Rms(Vec<f32>),
LayerNormNoParams,
None,
}Expand description
The normalisation applied at one norm site.
Variants§
Rms(Vec<f32>)
RMSNorm with these learned weights. Every architecture on the generic path except the two families below.
LayerNormNoParams
Non-parametric LayerNorm: subtract the mean, divide by the standard deviation, no learned weight and no bias.
olmo (OLMo-1) and nothing else in llama.cpp. There is no
LayerNorm(Vec<f32>) beside this because no architecture ferrox
admits needs one: the weighted-LayerNorm rows (dbrx,
nemotron, orion, stablelm, …) all refuse for other
reasons too, and a variant with no caller is a variant that
silently rots.
None
No norm at all: the branch reads the raw residual.
olmo2 and exaone4. NOT “an RMSNorm whose weights are all
ones” – that would still divide by the RMS of the residual, and
the whole point of this variant is that nothing is divided.
Implementations§
Source§impl NormOp
impl NormOp
Sourcepub fn apply(&self, x: &[f32], eps: f32) -> Vec<f32>
pub fn apply(&self, x: &[f32], eps: f32) -> Vec<f32>
The site’s output: rms_norm(x, w, eps), the non-parametric
LayerNorm, or x itself.
Returns an owned vector in every arm, which is what every caller
already had: rms_norm allocates too.
eps is ModelConfig::rms_norm_eps, which for a LayerNorm
architecture is read from {arch}.attention.layer_norm_epsilon
– llama.cpp’s f_norm_eps rather than f_norm_rms_eps. The two
are one field here because no architecture reads both keys, and
loader.rs already accepted either spelling into that field
before this variant existed.
Sourcepub fn rms_weights(&self) -> Option<&[f32]>
pub fn rms_weights(&self) -> Option<&[f32]>
The weights a fused GPU kernel needs, or None when this site
has no RMSNorm weights and the kernel therefore must not run.
Every fused Metal launch that bakes an RMSNorm into its kernel
goes through here and falls back to the host body on None.
See the module docs for why that is a ? and not a comment.
Trait Implementations§
impl StructuralPartialEq for NormOp
Auto Trait Implementations§
impl Freeze for NormOp
impl RefUnwindSafe for NormOp
impl Send for NormOp
impl Sync for NormOp
impl Unpin for NormOp
impl UnsafeUnpin for NormOp
impl UnwindSafe for NormOp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more