mistralrs_core/dummy_paged_attention/
config.rspub trait ModelConfigLike {
fn num_layers(&self) -> usize;
fn hidden_size(&self) -> usize;
fn num_kv_heads(&self) -> usize;
fn num_attn_heads(&self) -> usize;
fn k_head_dim(&self) -> usize {
self.hidden_size() / self.num_attn_heads()
}
fn v_head_dim(&self) -> usize {
self.hidden_size() / self.num_attn_heads()
}
}
#[derive(Clone)]
pub struct ModelConfigMetadata {
pub num_layers: usize,
pub hidden_size: usize,
pub num_kv_heads: usize,
pub num_attn_heads: usize,
pub sliding_window: Option<usize>,
pub k_head_dim: Option<usize>,
pub v_head_dim: Option<usize>,
}
impl ModelConfigLike for ModelConfigMetadata {
fn hidden_size(&self) -> usize {
self.hidden_size
}
fn num_attn_heads(&self) -> usize {
self.num_attn_heads
}
fn num_kv_heads(&self) -> usize {
self.num_kv_heads
}
fn num_layers(&self) -> usize {
self.num_layers
}
fn k_head_dim(&self) -> usize {
self.k_head_dim
.unwrap_or(self.hidden_size() / self.num_attn_heads())
}
fn v_head_dim(&self) -> usize {
self.v_head_dim
.unwrap_or(self.hidden_size() / self.num_attn_heads())
}
}