Skip to main content

ActiveSequence

Struct ActiveSequence 

Source
pub struct ActiveSequence { /* private fields */ }
Expand description

A sequence that is actively being built, with the ability to add tokens and commit to hashes TODO: reuse tokens

Implementations§

Source§

impl ActiveSequence

Auto-generated by derive_getters::Getters.

Source

pub fn unique_blocks(&self) -> &Vec<UniqueBlock>

Get field unique_blocks from instance of ActiveSequence.

Source

pub fn block_hashes(&self) -> &Vec<BlockHash>

Get field block_hashes from instance of ActiveSequence.

Source

pub fn plhs(&self) -> &Vec<PositionalLineageHash>

Get field plhs from instance of ActiveSequence.

Source

pub fn block_size(&self) -> usize

Get field block_size from instance of ActiveSequence.

Source

pub fn max_output_tokens(&self) -> usize

Get field max_output_tokens from instance of ActiveSequence.

Source

pub fn generated_tokens(&self) -> usize

Get field generated_tokens from instance of ActiveSequence.

Source

pub fn planned_output_ids(&self) -> &Option<Vec<u32>>

Get field planned_output_ids from instance of ActiveSequence.

Source

pub fn num_input_tokens(&self) -> usize

Get field num_input_tokens from instance of ActiveSequence.

Source

pub fn num_allocated_tokens(&self) -> usize

Get field num_allocated_tokens from instance of ActiveSequence.

Source

pub fn enable_prefix_caching(&self) -> bool

Get field enable_prefix_caching from instance of ActiveSequence.

Source

pub fn emit_token_ids(&self) -> bool

Get field emit_token_ids from instance of ActiveSequence.

Source§

impl ActiveSequence

Source

pub fn new( tokens: Vec<u32>, max_output_tokens: usize, block_size: Option<usize>, enable_prefix_caching: bool, emit_token_ids: bool, ) -> Self

Create a new ActiveSequence instance with the provided tokens

Source

pub fn new_with_planned_output_ids( tokens: Vec<u32>, max_output_tokens: usize, block_size: Option<usize>, enable_prefix_caching: bool, emit_token_ids: bool, planned_output_ids: Option<Vec<u32>>, ) -> Self

Source

pub fn extra_tokens(&self) -> u32

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn prepare_allocation(&self, cumulative_tokens: usize) -> Option<MoveBlock>

Build a MoveBlock::Use signal for blocks up to cumulative_tokens without updating internal state. Returns None if no new blocks are needed. Call commit_allocation after the signal is successfully processed.

Source

pub fn positional_lineage_hashes(&self) -> &[PositionalLineageHash]

Positional lineage hashes for all fully-tokenised blocks in the sequence. Mirrors block_hashes() but returns the PLH identity used by kvbm-logical.

Source

pub fn block_token_ids(&self) -> Vec<Vec<u32>>

Materialize every complete block’s token IDs.

§Panics

Panics for native flat sequences that were created without token-ID event emission, because those sequences intentionally discard completed prompt and decode blocks.

Source

pub fn commit_allocation(&mut self, cumulative_tokens: usize)

Commit a successful allocation by advancing num_allocated_tokens.

Source

pub fn allocate_blocks_for_chunk( &mut self, cumulative_tokens: usize, ) -> Option<MoveBlock>

Prepare + commit in one call (convenience for paths where failure is impossible).

Source

pub fn take_creation_signal(&mut self) -> Option<MoveBlock>

Allocate all remaining blocks at once (backward compat).

Source

pub fn new_with_signal( tokens: Vec<u32>, max_output_tokens: usize, block_size: Option<usize>, enable_prefix_caching: bool, ) -> (Self, Option<MoveBlock>)

Create a new ActiveSequence instance and return the creation signal

Source

pub fn push(&mut self, token: u32) -> Option<Vec<MoveBlock>>

Push a token to the sequence

Source

pub fn generate(&mut self) -> Vec<MoveBlock>

Generate a random token, push it to the sequence, and increment generation count.

This function:

  • Generates a random token and adds it to the current sequence
  • Acquires a new partial block if needed or promotes an existing partial block to a full block
  • Returns appropriate signals for the G1 manager to process
§Panics

Calling this function when max_output_tokens has already been reached will cause a panic. Always check generated_tokens < max_output_tokens before calling this method.

Source

pub fn generate_token(&mut self) -> (u32, Vec<MoveBlock>)

Generate the next output token, push it to the sequence, and return the token alongside any KV movement signals.

Source

pub fn free_signal(&self) -> Vec<MoveBlock>

Free the currently active allocation footprint.

Source

pub fn reset_with_signal(&mut self) -> Vec<MoveBlock>

Move the request to a preempted state and return the free signals from freeing current blocks. Upon preemption, the sequence retains the tokens generated during the decode phase (if any). Resets num_allocated_tokens so re-admission will re-allocate from scratch.

Source

pub fn pop(&mut self)

Pops the last token in the sequence.

This is only used to undo a freshly generated decode token after a failed allocation/preemption path. Under that invariant, the token being removed must be in the current partial block, so we only need to drop the trailing partial UniqueBlock when the sequence length returns to an exact block boundary. Using this to unwind arbitrary prompt history would be incorrect.

If this contract is violated in release builds, legacy token storage preserves its historical no-op on an empty buffer, while flat storage panics to surface the invalid rollback.

Trait Implementations§

Source§

impl Debug for ActiveSequence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Validate for ActiveSequence

Source§

impl<'v_a> ValidateArgs<'v_a> for ActiveSequence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more