pub struct ModelDef {
pub name: String,
pub description: Option<String>,
pub vocab_size: usize,
pub max_seq_len: usize,
pub hidden_size: usize,
pub num_layers: usize,
pub block: BlockDef,
pub pattern: Option<Vec<BlockDef>>,
pub embeddings: EmbeddingsConfig,
pub output: OutputConfig,
}Expand description
Parsed model definition from MAL
Fields§
§name: String§description: Option<String>§vocab_size: usizeNumber of token IDs exposed by the tokenizer and model API. Parameter storage is padded internally for efficient accelerator kernels.
max_seq_len: usize§num_layers: usize§block: BlockDef§pattern: Option<Vec<BlockDef>>Optional heterogeneous layer pattern, repeated cyclically across
num_layers (e.g. [mamba, mamba, attn]). Overrides block when set.
embeddings: EmbeddingsConfig§output: OutputConfigImplementations§
Source§impl ModelDef
impl ModelDef
Sourcepub fn block_for_layer(&self, i: usize) -> &BlockDef
pub fn block_for_layer(&self, i: usize) -> &BlockDef
Block definition for layer i: cycles through pattern when set,
otherwise the homogeneous block.
Sourcepub fn dt_rank(&self, ssm: &SsmDef) -> usize
pub fn dt_rank(&self, ssm: &SsmDef) -> usize
Effective Δ rank for an SSM mixer (paper default: ceil(hidden/16))
Sourcepub fn num_heads(&self) -> usize
pub fn num_heads(&self) -> usize
Query-head count of the homogeneous/default block.
Pattern-aware callers should use Self::block_for_layer and
BlockDef::num_heads instead.
Sourcepub fn num_kv_heads(&self) -> usize
pub fn num_kv_heads(&self) -> usize
Key/value-head count of the homogeneous/default block.
Pattern-aware callers should use Self::block_for_layer and
BlockDef::num_kv_heads instead.
Sourcepub fn head_dim(&self) -> usize
pub fn head_dim(&self) -> usize
Attention-head width of the homogeneous/default block.
Pattern-aware callers should use Self::block_for_layer and
BlockDef::head_dim instead.
Sourcepub fn intermediate_size(&self) -> usize
pub fn intermediate_size(&self) -> usize
FFN width of the homogeneous/default block.
Pattern-aware callers should use Self::block_for_layer and
BlockDef::intermediate_size instead.
Sourcepub fn norm_eps(&self) -> f64
pub fn norm_eps(&self) -> f64
Normalization epsilon of the homogeneous/default block.
Pattern-aware callers should use Self::block_for_layer and
BlockDef::norm_eps instead.
Sourcepub fn rope_theta(&self) -> f64
pub fn rope_theta(&self) -> f64
RoPE theta of the homogeneous/default block.
Pattern-aware callers should use Self::block_for_layer and
BlockDef::rope_theta instead.
Sourcepub fn padded_vocab_size(&self) -> usize
pub fn padded_vocab_size(&self) -> usize
Vocabulary rows stored by embeddings and the output projection.
Keeping this derived preserves a single logical vocabulary in MAL and checkpoint configs while giving GPU kernels an aligned output dimension.
Sourcepub fn estimated_params(&self) -> usize
pub fn estimated_params(&self) -> usize
Count trainable parameters implied by the model definition.