Mojo struct
PagedKVCacheCollection
struct PagedKVCacheCollection[dtype_: DType, kv_params_: KVCacheStaticParams, page_size: Int]
Fields
- blocks (
NDBuffer[PagedKVCacheCollection[dtype_, kv_params_, page_size].dtype, 6, MutAnyOrigin, PagedKVCacheCollection[dtype_, kv_params_, page_size].blocks_shape, PagedKVCacheCollection[dtype_, kv_params_, page_size].blocks_stride]): - cache_lengths (
NDBuffer[DType.uint32, 1, MutAnyOrigin]): - lookup_table (
NDBuffer[DType.uint32, 2, MutAnyOrigin]): - max_seq_length (
UInt32): - max_cache_length (
UInt32): - kv_cache_dynamic_shape (
IndexList[4]): - kv_cache_dynamic_strides (
IndexList[4]):
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
KVCollectionT,
Movable,
UnknownDestructibility
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = True
__del__is_trivial
alias __del__is_trivial = True
__moveinit__is_trivial
alias __moveinit__is_trivial = True
blocks_shape
alias blocks_shape = DimList(Dim(), Dim(2 if (PagedKVCacheCollection[dtype_, kv_params_, page_size].kv_params.is_mla.__bool__() ^ True) else 1), Dim(), Dim(page_size), Dim(Int(PagedKVCacheCollection[dtype_, kv_params_, page_size].kv_params)), Dim(Int(PagedKVCacheCollection[dtype_, kv_params_, page_size].kv_params)))
blocks_stride
alias blocks_stride = _strides_from_shape[PagedKVCacheCollection[dtype_, kv_params_, page_size].blocks_shape]()
blocks_type
alias blocks_type = NDBuffer[PagedKVCacheCollection[dtype_, kv_params_, page_size].dtype, 6, MutAnyOrigin, PagedKVCacheCollection[dtype_, kv_params_, page_size].blocks_shape, PagedKVCacheCollection[dtype_, kv_params_, page_size].blocks_stride]
CacheType
alias CacheType = PagedKVCache[PagedKVCacheCollection[dtype_, kv_params_, page_size].dtype, PagedKVCacheCollection[dtype_, kv_params_, page_size].kv_params, page_size]
dtype
alias dtype = dtype_
kv_params
alias kv_params = kv_params_
name_str
alias name_str = "paged"
Methods
__init__
__init__(out self, blocks: NDBuffer[PagedKVCacheCollection[dtype_, kv_params_, page_size].dtype, 6, MutAnyOrigin], cache_lengths: NDBuffer[DType.uint32, 1, MutAnyOrigin], lookup_table: NDBuffer[DType.uint32, 2, MutAnyOrigin], max_seq_length: UInt32, max_cache_length: UInt32)
get_key_cache
get_key_cache(self, layer_idx: Int) -> PagedKVCache[PagedKVCacheCollection[dtype_, kv_params_, page_size].dtype, PagedKVCacheCollection[dtype_, kv_params_, page_size].kv_params, page_size]
Returns:
PagedKVCache
get_value_cache
get_value_cache(self, layer_idx: Int) -> PagedKVCache[PagedKVCacheCollection[dtype_, kv_params_, page_size].dtype, PagedKVCacheCollection[dtype_, kv_params_, page_size].kv_params, page_size]
Returns:
PagedKVCache
cache_length
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!