pub enum SequencePool {
KvBased(KvCachePool),
Ssm(SsmStatePool),
}Expand description
Dispatch-enum over the two pool backends.
At model-load time the engine inspects the loaded architecture and
constructs either a KvBased pool (for any transformer) or an Ssm pool
(for Mamba-2 and similar). Both variants expose the same interface through
SequencePool’s methods.
§KV-based pooling
The KV-based variant stores state in a KvCachePool of page-sized slabs.
Slots are identified by page indices returned by KvCachePool::alloc.
§SSM pooling
The SSM variant stores the full per-layer recurrent state in an
SsmStatePool. The alloc_ssm / release_ssm helpers delegate to it.
Variants§
KvBased(KvCachePool)
Attention-transformer pool (KV cache pages).
Ssm(SsmStatePool)
SSM pool (per-layer recurrent hidden states).
Implementations§
Source§impl SequencePool
impl SequencePool
Sourcepub fn alloc_kv(&mut self) -> PoolResult<usize>
pub fn alloc_kv(&mut self) -> PoolResult<usize>
Allocate a slot from the KV-based pool.
Returns the page index on success.
§Errors
PoolError::Exhausted if the pool is full.
PoolError::InvalidSlot(usize::MAX) if called on an Ssm variant.
Sourcepub fn free_kv(&mut self, page_idx: usize) -> PoolResult<()>
pub fn free_kv(&mut self, page_idx: usize) -> PoolResult<()>
Sourcepub fn alloc_ssm(&mut self, request_id: u64) -> PoolResult<usize>
pub fn alloc_ssm(&mut self, request_id: u64) -> PoolResult<usize>
Allocate an SSM slot bound to request_id.
§Errors
PoolError::Exhausted if the pool is full.
PoolError::InvalidSlot(usize::MAX) if called on a KvBased variant.
Sourcepub fn release_ssm(&mut self, idx: usize) -> PoolResult<()>
pub fn release_ssm(&mut self, idx: usize) -> PoolResult<()>
Release an SSM slot by index.
§Errors
PoolError::InvalidSlot if idx is invalid or already free, or if
called on a KvBased variant.
Sourcepub fn ssm_slot(&self, idx: usize) -> Option<&SequenceSlot>
pub fn ssm_slot(&self, idx: usize) -> Option<&SequenceSlot>
Get an immutable reference to an SSM slot.
Returns None for KV-based pools or out-of-range indices.
Sourcepub fn ssm_slot_mut(&mut self, idx: usize) -> Option<&mut SequenceSlot>
pub fn ssm_slot_mut(&mut self, idx: usize) -> Option<&mut SequenceSlot>
Get a mutable reference to an SSM slot.
Returns None for KV-based pools or out-of-range indices.
Sourcepub fn is_kv_based(&self) -> bool
pub fn is_kv_based(&self) -> bool
Returns true if this pool uses the KV-cache backend.
Auto Trait Implementations§
impl Freeze for SequencePool
impl !RefUnwindSafe for SequencePool
impl !Send for SequencePool
impl !Sync for SequencePool
impl Unpin for SequencePool
impl UnsafeUnpin for SequencePool
impl !UnwindSafe for SequencePool
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
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>
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>
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