pub(crate) mod builder;
mod config;
mod fully_contiguous;
mod kv_block_layout;
mod layer_separate;
mod physical;
mod serialize;
mod validation;
#[cfg(all(test, feature = "testing-kvbm"))]
pub(super) mod tests;
pub use builder::PhysicalLayoutBuilder;
pub use config::{BlockDimension, LayoutConfig};
pub(crate) use fully_contiguous::FullyContiguousLayout;
pub use kv_block_layout::{BlockDim, KvBlockLayout};
pub(crate) use layer_separate::LayerSeparateLayout;
pub use physical::NixlMetadata;
pub use physical::PhysicalLayout;
pub(crate) use serialize::LayoutDescriptor;
pub use serialize::{BlockFormat, FullyContiguousDetails, LayerSeparateDetails, LayoutTypeDetails};
use anyhow::Result;
use serde::{Deserialize, Serialize};
pub(crate) use dynamo_memory::MemoryDescriptor;
pub use dynamo_memory::{Buffer, MemoryRegion};
pub trait Layout: Send + Sync + std::fmt::Debug {
fn config(&self) -> &LayoutConfig;
fn memory_regions(&self) -> &[Buffer];
fn memory_region(
&self,
block_id: usize,
layer_id: usize,
outer_id: usize,
) -> Result<MemoryRegion>;
fn required_allocations(&self) -> Vec<usize>;
fn is_fully_contiguous(&self) -> bool;
fn num_blocks(&self) -> usize;
fn num_layers(&self) -> usize;
fn outer_dim(&self) -> usize;
fn page_size(&self) -> usize;
fn inner_dim(&self) -> usize;
fn dtype_width_bytes(&self) -> usize;
fn serialization_details(&self) -> serialize::LayoutTypeDetails;
fn block_layout(&self) -> KvBlockLayout;
}
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) enum InnerShape {
Unknown,
NHD,
HND,
}
pub trait ContiguousBlockLayout: Send + Sync + std::fmt::Debug {
fn num_blocks(&self) -> usize;
fn bytes_per_block(&self) -> usize;
fn raw_block(&self, block_id: usize) -> Result<MemoryRegion>;
fn block_layout(&self) -> KvBlockLayout;
}