pub trait NativeTextStateBackend: TextGenerationBackend {
type NativeTextState;
// Required methods
fn native_text_state_support(runtime: &ModelRuntime<Self>) -> ControlSupport;
fn estimate_native_text_state(
runtime: &ModelRuntime<Self>,
saved: Option<&Self::NativeTextState>,
) -> Result<Option<SnapshotEstimate>, Self::Error>;
fn capture_native_text_state(
runtime: &mut ModelRuntime<Self>,
) -> Result<Self::NativeTextState, Self::Error>;
fn copy_native_text_state(
runtime: &mut ModelRuntime<Self>,
saved: &Self::NativeTextState,
) -> Result<Self::NativeTextState, Self::Error>;
fn validate_native_text_state(
runtime: &ModelRuntime<Self>,
saved: &Self::NativeTextState,
) -> Result<(), Self::Error>;
fn exchange_native_text_state(
runtime: &mut ModelRuntime<Self>,
slot: &mut Self::NativeTextState,
) -> Result<(), Self::Error>;
// Provided method
fn estimate_native_text_growth(
_runtime: &ModelRuntime<Self>,
_saved: &Self::NativeTextState,
_additional_input_tokens: u64,
) -> Result<Option<u64>, Self::Error> { ... }
}Expand description
Native persistent-state mechanisms for ordinary text generation.
These operations cover the model’s complete mutable execution state and native metadata, not the sampler, pending input or facade semantic state. Portable composition must reserve known costs before copying and combine all of those owners before advertising a complete generation snapshot. Backends cooperate with their existing submission authority and recovery owner.
Required Associated Types§
Sourcetype NativeTextState
type NativeTextState
Independently writable, opaque, in-process native state slot. Sharing immutable weights is allowed; cloning mutable storage handles is not.
Required Methods§
Sourcefn native_text_state_support(runtime: &ModelRuntime<Self>) -> ControlSupport
fn native_text_state_support(runtime: &ModelRuntime<Self>) -> ControlSupport
Side-effect-free support facts for this exact loaded execution. This is a primitive report, not full generation-snapshot capability discovery.
Sourcefn estimate_native_text_state(
runtime: &ModelRuntime<Self>,
saved: Option<&Self::NativeTextState>,
) -> Result<Option<SnapshotEstimate>, Self::Error>
fn estimate_native_text_state( runtime: &ModelRuntime<Self>, saved: Option<&Self::NativeTextState>, ) -> Result<Option<SnapshotEstimate>, Self::Error>
Estimates copying installed state (None) or a compatible saved slot.
Unknown costs remain explicit and must be rejected before copying.
Sourcefn capture_native_text_state(
runtime: &mut ModelRuntime<Self>,
) -> Result<Self::NativeTextState, Self::Error>
fn capture_native_text_state( runtime: &mut ModelRuntime<Self>, ) -> Result<Self::NativeTextState, Self::Error>
Captures independent state after portable resource reservation. Returns only after successful exact native completion. Failure never changes the logical source state; unresolved work remains retained and fenced.
Sourcefn copy_native_text_state(
runtime: &mut ModelRuntime<Self>,
saved: &Self::NativeTextState,
) -> Result<Self::NativeTextState, Self::Error>
fn copy_native_text_state( runtime: &mut ModelRuntime<Self>, saved: &Self::NativeTextState, ) -> Result<Self::NativeTextState, Self::Error>
Copies a reusable saved slot without installing it or replaying input. The source remains unchanged even if allocation or completion fails.
Sourcefn validate_native_text_state(
runtime: &ModelRuntime<Self>,
saved: &Self::NativeTextState,
) -> Result<(), Self::Error>
fn validate_native_text_state( runtime: &ModelRuntime<Self>, saved: &Self::NativeTextState, ) -> Result<(), Self::Error>
Validates exact executable identity, geometry and safe native boundary before any state mutation. A different compatible-looking model fails.
Sourcefn exchange_native_text_state(
runtime: &mut ModelRuntime<Self>,
slot: &mut Self::NativeTextState,
) -> Result<(), Self::Error>
fn exchange_native_text_state( runtime: &mut ModelRuntime<Self>, slot: &mut Self::NativeTextState, ) -> Result<(), Self::Error>
Atomically exchanges installed and saved state, without copying tensor
data. The old installed state is returned in slot. On error neither
logical state changes; unresolved native failure may fence the engine.
Provided Methods§
Sourcefn estimate_native_text_growth(
_runtime: &ModelRuntime<Self>,
_saved: &Self::NativeTextState,
_additional_input_tokens: u64,
) -> Result<Option<u64>, Self::Error>
fn estimate_native_text_growth( _runtime: &ModelRuntime<Self>, _saved: &Self::NativeTextState, _additional_input_tokens: u64, ) -> Result<Option<u64>, Self::Error>
Conservative additional logical retention through at most this many new input tokens, starting from the saved state. Includes cache capacity growth and initially absent recurrent/convolution components, without executing input. Unknown growth disables runnable branches, not immutable snapshots.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".