pub struct Attention {Show 17 fields
pub heads: usize,
pub kv_heads: usize,
pub head_dim: usize,
pub value_dim: usize,
pub rope: Option<Rope>,
pub qk_norm: bool,
pub output_gate: bool,
pub fused_qkv: bool,
pub bias: bool,
pub output_bias: bool,
pub window: Option<Window>,
pub sinks: bool,
pub softcap: Option<f64>,
pub scale: f64,
pub temperature: Option<Temperature>,
pub qk_unit_norm: bool,
pub qk_norm_whole: bool,
}Expand description
Grouped-query attention, with the variants checkpoints use.
Fields§
§heads: usize§kv_heads: usize§head_dim: usizeQuery/key head width.
value_dim: usizeValue head width.
rope: Option<Rope>The rotary embedding, or None for a layer without positions (NoPE).
qk_norm: boolPer-head RMSNorm of the queries and keys before the rotation.
output_gate: boolThe query projection also produces a per-element gate, and the attention output is multiplied by its sigmoid (Qwen3.5/3.8).
fused_qkv: boolThe projections are one fused tensor (attn_qkv) rather than three.
bias: boolBiases on the query, key and value projections.
output_bias: boolA bias on the output projection (attn_output.bias): gpt-oss’s; Qwen2’s attention has none.
window: Option<Window>The positions each query keeps: the last W (Mistral, Gemma 2 and 3, gpt-oss), or its own chunk of C
(Llama 4’s rotated layers).
sinks: boolA learned per-head logit joins each softmax’s denominator (gpt-oss).
softcap: Option<f64>Soft-capping of the attention scores.
scale: f64The score scale (1/√head_dim unless the checkpoint says otherwise).
temperature: Option<Temperature>Each query scaled by a factor of its position before it scores (Llama 4’s rotation-free layers).
qk_unit_norm: boolA per-head RMSNorm of the queries and keys with no weight (Llama 4’s rotated layers, after the rotation: the same as before it, a rotation keeping each head’s norm).
qk_norm_whole: boolWith qk_norm, the queries and the keys are each normed across every head at once, their weights as wide as the
projections (MiniMax-M2’s qk_norm_type “per_layer”), rather than head by head.
Trait Implementations§
impl StructuralPartialEq for Attention
Auto Trait Implementations§
impl Freeze for Attention
impl RefUnwindSafe for Attention
impl Send for Attention
impl Sync for Attention
impl Unpin for Attention
impl UnsafeUnpin for Attention
impl UnwindSafe for Attention
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.