pub struct GenericKvCacheHandle { /* private fields */ }Expand description
Generic KV cache handle usable by any model architecture.
Implementations§
Source§impl GenericKvCacheHandle
impl GenericKvCacheHandle
pub fn new( num_layers: usize, num_heads: usize, head_dim: usize, device: CandleDevice, seq_len: usize, cache_id: String, ) -> Self
pub fn with_sequence_length(&self, seq_len: usize) -> Self
pub fn request_cache_id(&self) -> &str
Trait Implementations§
Source§impl Clone for GenericKvCacheHandle
impl Clone for GenericKvCacheHandle
Source§fn clone(&self) -> GenericKvCacheHandle
fn clone(&self) -> GenericKvCacheHandle
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GenericKvCacheHandle
impl Debug for GenericKvCacheHandle
Source§impl KvCacheHandle for GenericKvCacheHandle
impl KvCacheHandle for GenericKvCacheHandle
Source§fn block_table(&self) -> &BlockTable
fn block_table(&self) -> &BlockTable
Get block table for this cache
Source§fn block_table_mut(&mut self) -> &mut BlockTable
fn block_table_mut(&mut self) -> &mut BlockTable
Get mutable block table (for extending)
Source§fn num_layers(&self) -> usize
fn num_layers(&self) -> usize
Get number of layers cached
Source§fn key_cache(&self, _layer: usize) -> Result<Option<TensorRef>>
fn key_cache(&self, _layer: usize) -> Result<Option<TensorRef>>
Get key cache for specific layer (returns tensor reference)
Source§fn value_cache(&self, _layer: usize) -> Result<Option<TensorRef>>
fn value_cache(&self, _layer: usize) -> Result<Option<TensorRef>>
Get value cache for specific layer
Source§fn clone_handle(&self) -> Result<Arc<dyn KvCacheHandle>>
fn clone_handle(&self) -> Result<Arc<dyn KvCacheHandle>>
Clone handle (creates new reference, not deep copy)
Source§fn stats(&self) -> CacheHandleStats
fn stats(&self) -> CacheHandleStats
Get cache statistics
Source§fn num_tokens(&self) -> usize
fn num_tokens(&self) -> usize
Get number of tokens stored in cache
Source§fn kv_cache(
&self,
layer: usize,
) -> Result<(Option<Arc<dyn TensorLike>>, Option<Arc<dyn TensorLike>>), FerrumError>
fn kv_cache( &self, layer: usize, ) -> Result<(Option<Arc<dyn TensorLike>>, Option<Arc<dyn TensorLike>>), FerrumError>
Get both key and value caches for layer
Auto Trait Implementations§
impl Freeze for GenericKvCacheHandle
impl RefUnwindSafe for GenericKvCacheHandle
impl Send for GenericKvCacheHandle
impl Sync for GenericKvCacheHandle
impl Unpin for GenericKvCacheHandle
impl UnsafeUnpin for GenericKvCacheHandle
impl UnwindSafe for GenericKvCacheHandle
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more