pub struct LayoutConfig {
pub num_blocks: usize,
pub num_layers: usize,
pub outer_dim: usize,
pub page_size: usize,
pub inner_dim: usize,
pub alignment: usize,
pub dtype_width_bytes: usize,
pub num_heads: Option<usize>,
}Expand description
Configuration for block layouts.
The #[validate] attributes on fields are checked during layout construction
(e.g., FullyContiguousLayout::new_internal(), LayerSeparateLayout::new_internal()),
not at builder .build() time.
Fields§
§num_blocks: usizeNumber of blocks
num_layers: usizeNumber of layers
outer_dim: usizeNumber of outer dimensions
page_size: usizePage size
inner_dim: usizeInner dimension
alignment: usizeAlignment
dtype_width_bytes: usizeData type
num_heads: Option<usize>Number of attention heads (optional).
When provided, enables KvBlockLayout support for universal formats.
The head dimension can be computed as: inner_dim / (page_size * num_heads).
Required for:
- Universal layout transformations
- Per-head memory region access
Implementations§
Source§impl LayoutConfig
impl LayoutConfig
pub fn required_bytes(&self) -> usize
Sourcepub fn bytes_per_block(&self) -> usize
pub fn bytes_per_block(&self) -> usize
Get the number of bytes per block.
This is the total size of a single block across all layers and outer dimensions.
Sourcepub fn head_dim(&self) -> Option<usize>
pub fn head_dim(&self) -> Option<usize>
Get the head dimension if num_heads is specified.
Computes inner_dim / (page_size * num_heads).
§Returns
Some(head_dim) if num_heads is set, None otherwise.
Sourcepub fn supports_kv_block_layout(&self) -> bool
pub fn supports_kv_block_layout(&self) -> bool
Check if this config supports KvBlockLayout operations.
Returns true if num_heads is set and the dimensions are valid
(inner_dim is evenly divisible by page_size * num_heads).
Sourcepub fn validate_for_kv_block_layout(&self) -> Result<(), ValidationError>
pub fn validate_for_kv_block_layout(&self) -> Result<(), ValidationError>
Validate that this config supports KvBlockLayout operations.
§Returns
Ok(()) if valid, Err with details otherwise.
Trait Implementations§
Source§impl Clone for LayoutConfig
impl Clone for LayoutConfig
Source§fn clone(&self) -> LayoutConfig
fn clone(&self) -> LayoutConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LayoutConfig
impl Debug for LayoutConfig
Source§impl<'de> Deserialize<'de> for LayoutConfig
impl<'de> Deserialize<'de> for LayoutConfig
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>,
impl Eq for LayoutConfig
Source§impl PartialEq for LayoutConfig
impl PartialEq for LayoutConfig
Source§impl Serialize for LayoutConfig
impl Serialize for LayoutConfig
impl StructuralPartialEq for LayoutConfig
Source§impl Validate for LayoutConfig
impl Validate for LayoutConfig
Source§impl<'v_a> ValidateArgs<'v_a> for LayoutConfig
impl<'v_a> ValidateArgs<'v_a> for LayoutConfig
Auto Trait Implementations§
impl Freeze for LayoutConfig
impl RefUnwindSafe for LayoutConfig
impl Send for LayoutConfig
impl Sync for LayoutConfig
impl Unpin for LayoutConfig
impl UnsafeUnpin for LayoutConfig
impl UnwindSafe for LayoutConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request