Skip to main content

SequentialDecisionDriver

Struct SequentialDecisionDriver 

Source
pub struct SequentialDecisionDriver<B, S>
where B: SamplingBackend, S: Sampler<B>,
{ /* private fields */ }
Expand description

Statically dispatched sequential token resolver.

The driver owns one sampler per prediction and one optional backend random state. Forced tokens and diagnostic logits remain backend-native values.

Implementations§

Source§

impl<B, S> SequentialDecisionDriver<B, S>
where B: SamplingBackend, S: Sampler<B>,

Source

pub fn new( plan: SequentialDecisionPlan<B::Token>, samplers: Vec<S>, temperatures: Vec<f32>, random: Option<B::RandomState>, ) -> Result<Self, SequentialDecisionPlanError>

Creates a driver with exactly one sampler and temperature per prediction.

Source

pub const fn plan(&self) -> &SequentialDecisionPlan<B::Token>

Borrows the validated decision plan.

Source

pub fn next_prediction(&self) -> usize

Returns the next prediction ordinal expected at a traversal boundary.

Source

pub fn decisions(&self) -> &[SequentialDecision<B::Token>]

Returns resolved decisions in canonical order.

Source

pub fn diagnostics(&self) -> &[SequentialDecisionDiagnostic<B::Logits>]

Returns retained diagnostic logits in canonical order.

Source

pub const fn random_state(&self) -> Option<&B::RandomState>

Borrows the backend random state after all decisions made so far.

Source

pub fn fully_forced_tail_decision( &self, prediction: usize, remaining_units: usize, ) -> Result<FullyForcedTailDecision, SequentialDecisionError<B::Error>>

Validates whether remaining_units is exactly one fully forced tail.

Source

pub fn forced_tail_tokens( &self, prediction: usize, count: usize, domains: impl IntoIterator<Item = TokenDomain>, context: &B::Context, ) -> Result<Vec<B::Token>, SequentialDecisionError<B::Error>>

Returns cloned forced tokens for a tail already proven skippable.

Source

pub fn commit_forced_tail( &mut self, prediction: usize, tokens: Vec<B::Token>, ) -> Result<(), SequentialDecisionError<B::Error>>

Records a proven and architecture-accepted forced tail.

Source

pub fn resolve( &mut self, prediction: usize, logits: &B::Logits, domain: TokenDomain, context: &B::Context, ) -> Result<B::Token, SequentialDecisionError<B::Error>>

Resolves one executed prediction from backend-native logits.

Source

pub fn finish(&self) -> Result<(), SequentialDecisionError<B::Error>>

Validates that every planned prediction was resolved exactly once.

Source

pub fn finish_into_sampling_state( self, ) -> Result<SequentialSamplingState<S, B::RandomState>, SequentialDecisionError<B::Error>>

Finishes the existing decision sequence and returns its advanced sampler and backend-random states for transactional publication.

Decisions and diagnostics remain inspectable until this method consumes the driver. A caller can therefore copy any required output metadata before atomically adopting these state components.

Auto Trait Implementations§

§

impl<B, S> Freeze for SequentialDecisionDriver<B, S>

§

impl<B, S> RefUnwindSafe for SequentialDecisionDriver<B, S>

§

impl<B, S> Send for SequentialDecisionDriver<B, S>

§

impl<B, S> Sync for SequentialDecisionDriver<B, S>

§

impl<B, S> Unpin for SequentialDecisionDriver<B, S>

§

impl<B, S> UnsafeUnpin for SequentialDecisionDriver<B, S>

§

impl<B, S> UnwindSafe for SequentialDecisionDriver<B, S>

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, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.