pub struct BlockDef {
pub name: String,
pub attention: AttentionDef,
pub ssm: Option<SsmDef>,
pub ffn: FfnDef,
pub memory: Option<MemoryDef>,
pub norm: NormConfig,
pub norm_position: NormPosition,
pub residual: bool,
pub dropout: f64,
}Expand description
Transformer block definition
The mixer is attention by default; when ssm is set the block is a
Mamba block (attention settings are ignored).
Fields§
§name: String§attention: AttentionDef§ssm: Option<SsmDef>§ffn: FfnDef§memory: Option<MemoryDef>Optional fast-to-slow memory chain replacing the ordinary FFN branch. Omission preserves the historical model and checkpoint topology.
norm: NormConfig§norm_position: NormPosition§residual: bool§dropout: f64Implementations§
Source§impl BlockDef
impl BlockDef
Sourcepub fn is_ssm(&self) -> bool
pub fn is_ssm(&self) -> bool
Whether this block uses its state-space mixer instead of attention.
Sourcepub fn num_kv_heads(&self) -> usize
pub fn num_kv_heads(&self) -> usize
Configured key/value-head count, defaulting to the query-head count.
Sourcepub fn head_dim(&self, hidden_size: usize) -> usize
pub fn head_dim(&self, hidden_size: usize) -> usize
Configured head width, or an even split of hidden_size when omitted.
Sourcepub fn intermediate_size(&self, hidden_size: usize) -> usize
pub fn intermediate_size(&self, hidden_size: usize) -> usize
Configured FFN width, or four times hidden_size when omitted.
Sourcepub fn rope_theta(&self) -> f64
pub fn rope_theta(&self) -> f64
Effective RoPE theta, including the MAL default for non-RoPE blocks.
Sourcepub fn rope_scaling(&self) -> Option<f64>
pub fn rope_scaling(&self) -> Option<f64>
Optional RoPE scaling for this block.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BlockDef
impl<'de> Deserialize<'de> for BlockDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BlockDef
impl RefUnwindSafe for BlockDef
impl Send for BlockDef
impl Sync for BlockDef
impl Unpin for BlockDef
impl UnsafeUnpin for BlockDef
impl UnwindSafe for BlockDef
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
Mutably borrows from an owned value. Read more