pub struct BlockTable {
pub physical_blocks: SmallVec<[u32; 8]>,
pub logical_to_physical: SmallVec<[u32; 8]>,
pub sequence_length: usize,
pub block_size: usize,
}Expand description
Block table for mapping logical to physical cache blocks
Fields§
§physical_blocks: SmallVec<[u32; 8]>Physical block IDs allocated for this sequence
logical_to_physical: SmallVec<[u32; 8]>Mapping from logical to physical block indices
sequence_length: usizeCache-fill bookkeeping owned by the KvCacheManager that allocated
this handle. Not authoritative for engine-side position tracking:
only updated by the manager that minted the handle (Paged sets it
at allocate-time and never bumps it; Default ignores initial_tokens
and leaves it at 0; GenericKvCacheHandle is the only one updated
per decode step, via with_sequence_length). The engine sources the
“where is the next token written” answer from SequenceState
(input_tokens.len() + generated_tokens.len() - 1) — see
ContinuousBatchEngine::process_batch_unified / run_batch_decode.
block_size: usizeBlock size (tokens per block)
Implementations§
Source§impl BlockTable
impl BlockTable
Sourcepub fn new(block_size: usize) -> BlockTable
pub fn new(block_size: usize) -> BlockTable
Create new block table
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Get number of blocks allocated
Sourcepub fn blocks_needed_for_length(length: usize, block_size: usize) -> usize
pub fn blocks_needed_for_length(length: usize, block_size: usize) -> usize
Get required number of blocks for sequence length
Sourcepub fn has_free_space(&self) -> bool
pub fn has_free_space(&self) -> bool
Check if can accommodate more tokens without new blocks
Sourcepub fn free_tokens(&self) -> usize
pub fn free_tokens(&self) -> usize
Get number of free tokens in allocated blocks
Sourcepub fn add_blocks(&mut self, blocks: &[u32])
pub fn add_blocks(&mut self, blocks: &[u32])
Add blocks to the table
Sourcepub fn extend_sequence(
&mut self,
additional_tokens: usize,
) -> Result<(), FerrumError>
pub fn extend_sequence( &mut self, additional_tokens: usize, ) -> Result<(), FerrumError>
Extend sequence length
Trait Implementations§
Source§impl Clone for BlockTable
impl Clone for BlockTable
Source§fn clone(&self) -> BlockTable
fn clone(&self) -> BlockTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more