Skip to main content

TextGenerationDriver

Struct TextGenerationDriver 

Source
pub struct TextGenerationDriver<'a, B: TextGenerationBackend> { /* private fields */ }
Expand description

Exclusive execution owner for detached ordinary continuations.

The same machine drives the existing borrowed iterators. This owner allows a facade to retain separate continuations while serially switching independently saved native model states. It does not switch those native states itself: the facade must compose the backend’s validated state-exchange mechanism. Native objects need not implement Send or Sync.

Implementations§

Source§

impl<'a, B: TextGenerationBackend> TextGenerationDriver<'a, B>

Source

pub fn new(runtime: &'a mut ModelRuntime<B>) -> Self

Exclusively borrows the runtime while this driver exists. A continuation retained after driver drop can be cleaned up but cannot attach to another driver, even one borrowing the same runtime.

Source

pub fn runtime(&self) -> &ModelRuntime<B>

Read-only access for exact loaded-session discovery and native estimates.

Source

pub fn start<C: TokenFilterController>( &mut self, prompt: B::Prompt, config: TextGenerationConfig, controller: C, ) -> Result<TextGenerationContinuation<B, C>, ControlledTextGenerationError<B::Error, C::Error>>

Starts the existing ordinary machine with an opaque prepared prompt. Neither model execution nor token sampling occurs here.

Source

pub fn quiescent<'d, 's, C: TokenFilterController>( &'d mut self, state: &'s mut TextGenerationContinuation<B, C>, ) -> Result<TextContinuationBoundary<'d, 's, B, C>, TextContinuationError<B::Error, C::Error>>

Lends the completed ordinary state to portable snapshot composition. All native work and the preceding bounded record batch must be settled. The guard holds both mutable borrows, preventing advancement while native copies, compatibility validation and host-state installation are composed.

Source

pub fn advance<C: TokenFilterController>( &mut self, state: &mut TextGenerationContinuation<B, C>, ) -> Result<Option<ControlledToken<B::Token>>, TextContinuationError<B::Error, C::Error>>

Advances at most one constraint-committed canonical token using the ordinary sampler and pending input. Call take_completed_step before advancing again or composing a pause/snapshot boundary.

Source

pub fn take_completed_step<C: TokenFilterController>( &mut self, state: &mut TextGenerationContinuation<B, C>, ) -> Result<Option<CapturedStep>, TextContinuationError<B::Error, C::Error>>

Settles exact native completion and moves out the single bounded record batch. It remains available after failure for attributed error evidence; draining never turns a failed continuation into a resumable one.

Source

pub fn enable_capture<C: TokenFilterController>( &mut self, state: &mut TextGenerationContinuation<B, C>, plan: AdmittedCapturePlan, ) -> Result<(), CaptureError>

Installs observations before the first model prediction.

Source

pub fn enable_interventions<C: TokenFilterController>( &mut self, state: &mut TextGenerationContinuation<B, C>, capture: AdmittedCapturePlan, plan: AdmittedInterventionPlan, ) -> Result<(), CaptureError>

Installs immutable observation/intervention admissions before execution.

Source§

impl<B: NativeTextStateBackend> TextGenerationDriver<'_, B>

Source

pub fn estimate_native_state<C: TokenFilterController>( &self, state: &TextGenerationContinuation<B, C>, saved: Option<&B::NativeTextState>, ) -> Result<Option<SnapshotEstimate>, TextContinuationError<B::Error, C::Error>>

Estimates installed or saved native state at a completed continuation boundary. Portable composition adds all host-state estimates and reserves resources before calling either copying operation below.

Source

pub fn capture_native_state<C: TokenFilterController>( &mut self, state: &TextGenerationContinuation<B, C>, ) -> Result<B::NativeTextState, TextContinuationError<B::Error, C::Error>>

Copies the installed model state through its existing completion owner. Caller must first reserve the complete snapshot’s resource estimate.

Source

pub fn copy_native_state<C: TokenFilterController>( &mut self, state: &TextGenerationContinuation<B, C>, saved: &B::NativeTextState, ) -> Result<B::NativeTextState, TextContinuationError<B::Error, C::Error>>

Independently copies a compatible saved slot after resource reservation. The currently installed continuation remains unchanged.

Source

pub fn exchange_native_state<C: TokenFilterController>( &mut self, state: &TextGenerationContinuation<B, C>, slot: &mut B::NativeTextState, ) -> Result<(), TextContinuationError<B::Error, C::Error>>

Exchanges the installed native state with a previously copied slot. The facade pairs this with the corresponding detached continuation and semantic state before advancing again. No token or sampler advances here.

Auto Trait Implementations§

§

impl<'a, B> !UnwindSafe for TextGenerationDriver<'a, B>

§

impl<'a, B> Freeze for TextGenerationDriver<'a, B>
where &'a mut ModelRuntime<B>: Freeze,

§

impl<'a, B> RefUnwindSafe for TextGenerationDriver<'a, B>
where &'a mut ModelRuntime<B>: RefUnwindSafe,

§

impl<'a, B> Send for TextGenerationDriver<'a, B>
where &'a mut ModelRuntime<B>: Send,

§

impl<'a, B> Sync for TextGenerationDriver<'a, B>
where &'a mut ModelRuntime<B>: Sync,

§

impl<'a, B> Unpin for TextGenerationDriver<'a, B>
where &'a mut ModelRuntime<B>: Unpin,

§

impl<'a, B> UnsafeUnpin for TextGenerationDriver<'a, B>
where &'a mut ModelRuntime<B>: UnsafeUnpin,

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.