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>,
impl<B, S> SequentialDecisionDriver<B, S>where
B: SamplingBackend,
S: Sampler<B>,
Sourcepub fn new(
plan: SequentialDecisionPlan<B::Token>,
samplers: Vec<S>,
temperatures: Vec<f32>,
random: Option<B::RandomState>,
) -> Result<Self, SequentialDecisionPlanError>
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.
Sourcepub const fn plan(&self) -> &SequentialDecisionPlan<B::Token>
pub const fn plan(&self) -> &SequentialDecisionPlan<B::Token>
Borrows the validated decision plan.
Sourcepub fn next_prediction(&self) -> usize
pub fn next_prediction(&self) -> usize
Returns the next prediction ordinal expected at a traversal boundary.
Sourcepub fn decisions(&self) -> &[SequentialDecision<B::Token>]
pub fn decisions(&self) -> &[SequentialDecision<B::Token>]
Returns resolved decisions in canonical order.
Sourcepub fn diagnostics(&self) -> &[SequentialDecisionDiagnostic<B::Logits>]
pub fn diagnostics(&self) -> &[SequentialDecisionDiagnostic<B::Logits>]
Returns retained diagnostic logits in canonical order.
Sourcepub const fn random_state(&self) -> Option<&B::RandomState>
pub const fn random_state(&self) -> Option<&B::RandomState>
Borrows the backend random state after all decisions made so far.
Sourcepub fn fully_forced_tail_decision(
&self,
prediction: usize,
remaining_units: usize,
) -> Result<FullyForcedTailDecision, SequentialDecisionError<B::Error>>
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.
Sourcepub fn forced_tail_tokens(
&self,
prediction: usize,
count: usize,
domains: impl IntoIterator<Item = TokenDomain>,
context: &B::Context,
) -> Result<Vec<B::Token>, SequentialDecisionError<B::Error>>
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.
Sourcepub fn commit_forced_tail(
&mut self,
prediction: usize,
tokens: Vec<B::Token>,
) -> Result<(), SequentialDecisionError<B::Error>>
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.
Sourcepub fn resolve(
&mut self,
prediction: usize,
logits: &B::Logits,
domain: TokenDomain,
context: &B::Context,
) -> Result<B::Token, SequentialDecisionError<B::Error>>
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.
Sourcepub fn finish(&self) -> Result<(), SequentialDecisionError<B::Error>>
pub fn finish(&self) -> Result<(), SequentialDecisionError<B::Error>>
Validates that every planned prediction was resolved exactly once.
Sourcepub fn finish_into_sampling_state(
self,
) -> Result<SequentialSamplingState<S, B::RandomState>, SequentialDecisionError<B::Error>>
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.