Skip to main content

AttnWeights

Struct AttnWeights 

Source
pub struct AttnWeights {
    pub q_proj: WeightMatrix,
    pub k_proj: WeightMatrix,
    pub v_proj: WeightMatrix,
    pub o_proj: WeightMatrix,
    pub norm_weight: Vec<f32>,
    pub q_norm: Option<Vec<f32>>,
    pub k_norm: Option<Vec<f32>>,
    pub q_bias: Option<Vec<f32>>,
    pub k_bias: Option<Vec<f32>>,
    pub v_bias: Option<Vec<f32>>,
    pub post_attn_norm: Option<Vec<f32>>,
    pub post_ffn_norm: Option<Vec<f32>>,
}

Fields§

§q_proj: WeightMatrix§k_proj: WeightMatrix§v_proj: WeightMatrix§o_proj: WeightMatrix§norm_weight: Vec<f32>§q_norm: Option<Vec<f32>>

OLMoE-style QK-RMSNorm (attn_q_norm/attn_k_norm GGUF tensors), applied to the whole q_proj/k_proj output (width n_heads*head_dim / n_kv_heads*head_dim) before RoPE – confirmed against OlmoeAttention.forward in transformers/models/olmoe/modeling_olmoe.py (q_norm(q_proj(x)), k_norm(k_proj(x)), both plain whole-vector RMSNorm, not per-head). None for every model that doesn’t ship these tensors – absent, not zero/identity-weighted, so existing presets/fixtures are byte-for-byte unaffected.

Qwen3 / Gemma3 ship the same tensor names with length head_dim (per-head). Which style is used is selected by ModelConfig::qk_norm_style (refined at load from weight length).

§k_norm: Option<Vec<f32>>§q_bias: Option<Vec<f32>>

Qwen2/Qwen2-MoE-family QKV attention bias (attn_{q,k,v}.bias GGUF tensors, real config.qkv_bias), added elementwise to the corresponding projection’s output before QK-norm/RoPE – confirmed against the real transformers source (Qwen2MoeAttention.__init__: q_proj = nn.Linear(..., bias= config.qkv_bias), same for k_proj/v_proj; o_proj has no bias). Found as a real, previously-unhandled architecture gap: ferrox’s generic GGUF loader silently ignored these real tensors entirely, producing fluent-but-wrong output on a real downloaded Qwen1.5-MoE checkpoint (same failure class as OLMoE’s missing QK-norm). None for every model that doesn’t ship these tensors.

§k_bias: Option<Vec<f32>>§v_bias: Option<Vec<f32>>§post_attn_norm: Option<Vec<f32>>

Gemma 2+/3 post-attention RMSNorm (blk.N.post_attention_norm.weight / llama.cpp attn_post_norm). Applied to attention output before the residual add. None for Llama/Qwen/OLMoE.

§post_ffn_norm: Option<Vec<f32>>

Gemma 2+/3 post-FFN RMSNorm (blk.N.post_ffw_norm.weight).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.