Skip to main content

TextSnapshotBackend

Trait TextSnapshotBackend 

Source
pub trait TextSnapshotBackend: NativeTextStateBackend {
    type SamplingState;

Show 14 methods // Required methods fn sampling_state(state: &Self::TextGenerationState) -> &Self::SamplingState; fn install_sampling_state( state: &mut Self::TextGenerationState, sampling: Self::SamplingState, ); fn assemble_generation_state( sampling: Self::SamplingState, capture: Option<CaptureSession>, ) -> Self::TextGenerationState; fn sampling_prediction(sampling: &Self::SamplingState) -> u64; fn estimate_sampling_state( runtime: &ModelRuntime<Self>, sampling: &Self::SamplingState, ) -> Result<Option<SnapshotEstimate>, Self::Error>; fn copy_sampling_state( runtime: &mut ModelRuntime<Self>, sampling: &Self::SamplingState, ) -> Result<Self::SamplingState, Self::Error>; fn estimate_pending_input( runtime: &ModelRuntime<Self>, input: Option<PendingTextInput<&Self::Prompt, &Self::Token>>, ) -> Result<Option<SnapshotEstimate>, Self::Error>; fn copy_pending_input( runtime: &mut ModelRuntime<Self>, input: Option<PendingTextInput<&Self::Prompt, &Self::Token>>, ) -> Result<Option<PendingTextInput<Self::Prompt, Self::Token>>, Self::Error>; fn capture_run(state: &Self::TextGenerationState) -> Option<&CaptureSession>; fn capture_run_mut( state: &mut Self::TextGenerationState, ) -> Option<&mut CaptureSession>; fn estimate_child_capture( runtime: &ModelRuntime<Self>, shape: &[u64], selection: &CaptureSelection, slice: &ResolvedCaptureSlice, ) -> Result<CaptureUsage, CaptureError>; fn child_intervention_estimator( runtime: &ModelRuntime<Self>, ) -> Result<Arc<dyn InterventionEstimator>, CaptureError>; // Provided methods fn continuation_input_tokens( _input: Option<PendingTextInput<&Self::Prompt, &Self::Token>>, _predictions: u64, ) -> Option<u64> { ... } fn estimate_sampling_growth( _runtime: &ModelRuntime<Self>, _sampling: &Self::SamplingState, _predictions: u64, ) -> Result<Option<u64>, Self::Error> { ... }
}
Expand description

Native ordinary-generation mechanisms used by the portable snapshot driver. Capture/intervention ownership stays in the shared CaptureSession; adapters expose that owner and perform native copying, never duplicate its bookkeeping.

Required Associated Types§

Source

type SamplingState

Sampling parameters, penalties/history, adaptive state, exact RNG and absolute next-prediction position. Copies must have isolated mutable state.

Required Methods§

Source

fn sampling_state(state: &Self::TextGenerationState) -> &Self::SamplingState

Borrows the native sampling component without changing it.

Source

fn install_sampling_state( state: &mut Self::TextGenerationState, sampling: Self::SamplingState, )

Installs an independently copied sampler after native restoration succeeds. Must be infallible, submit no work and leave capture ownership unchanged.

Source

fn assemble_generation_state( sampling: Self::SamplingState, capture: Option<CaptureSession>, ) -> Self::TextGenerationState

Creates child backend state from prepared sampling and shared capture owners. No new random draw, model execution, or admission occurs here.

Source

fn sampling_prediction(sampling: &Self::SamplingState) -> u64

Absolute next prediction, including the inherited prefix.

Source

fn estimate_sampling_state( runtime: &ModelRuntime<Self>, sampling: &Self::SamplingState, ) -> Result<Option<SnapshotEstimate>, Self::Error>

Complete known logical sampling-state copy cost, without native allocation.

Source

fn copy_sampling_state( runtime: &mut ModelRuntime<Self>, sampling: &Self::SamplingState, ) -> Result<Self::SamplingState, Self::Error>

Isolates all mutable sampling state and establishes exact native completion.

Source

fn estimate_pending_input( runtime: &ModelRuntime<Self>, input: Option<PendingTextInput<&Self::Prompt, &Self::Token>>, ) -> Result<Option<SnapshotEstimate>, Self::Error>

Complete known cost for preserving pending prefill/decode input. Unsupported input kinds, including media for a text-only realization, return unknown.

Source

fn copy_pending_input( runtime: &mut ModelRuntime<Self>, input: Option<PendingTextInput<&Self::Prompt, &Self::Token>>, ) -> Result<Option<PendingTextInput<Self::Prompt, Self::Token>>, Self::Error>

Copies pending input without executing it, sampling or retokenizing.

Source

fn capture_run(state: &Self::TextGenerationState) -> Option<&CaptureSession>

Existing shared observation/intervention owner, when enabled.

Source

fn capture_run_mut( state: &mut Self::TextGenerationState, ) -> Option<&mut CaptureSession>

Mutably borrows that same owner for validated, non-refunding restoration.

Source

fn estimate_child_capture( runtime: &ModelRuntime<Self>, shape: &[u64], selection: &CaptureSelection, slice: &ResolvedCaptureSlice, ) -> Result<CaptureUsage, CaptureError>

Actual native capture facts for shared child re-admission.

Source

fn child_intervention_estimator( runtime: &ModelRuntime<Self>, ) -> Result<Arc<dyn InterventionEstimator>, CaptureError>

Actual intervention estimator for this loaded backend, kept out of saved metadata.

Provided Methods§

Source

fn continuation_input_tokens( _input: Option<PendingTextInput<&Self::Prompt, &Self::Token>>, _predictions: u64, ) -> Option<u64>

Upper bound on input tokens submitted by the next predictions decisions, including the pending prompt or last committed token exactly once.

Source

fn estimate_sampling_growth( _runtime: &ModelRuntime<Self>, _sampling: &Self::SamplingState, _predictions: u64, ) -> Result<Option<u64>, Self::Error>

Additional sampler and pending-input retention through those decisions. Includes future history and lazily created native RNG/input storage.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§