Skip to main content

ReplicatedTextSessionMechanisms

Trait ReplicatedTextSessionMechanisms 

Source
pub trait ReplicatedTextSessionMechanisms<A, B>
where B: SubmissionBackend<Executor = <<B as NeuralBackend>::Tensor as Tensor>::Context>, A: LayeredArchitecture<B, Self::State>, Self::State: RuntimeState<B>, Self::ResidentPolicy: LayerwisePolicy<B, A::Unit, Error = Self::PolicyError>, Self::BoundedPolicy: LayerwisePolicy<B, A::Unit, Error = Self::PolicyError>,
{ type State: RuntimeState<B>; type PolicyError; type ResidentPolicy: LayerwisePolicy<B, A::Unit, Error = Self::PolicyError>; type BoundedPolicy: LayerwisePolicy<B, A::Unit, Error = Self::PolicyError>; type StateCheckpoint; type StateReport; type ExecutionReport; type Error;
Show 16 methods // Required methods fn prepare_materialization( &mut self, architecture: &mut A, layout: &ExecutionUnitLayout, units: &mut [A::Unit], source_architecture: Option<&mut A>, source_units: Option<&mut [A::Unit]>, tasks: &[ReplicatedTextMaterializationTask], addressable_parameters: &[String], context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>; fn realize_state( &mut self, selected: &SelectedStateRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::State, Self::Error>; fn resident_policy( &mut self, architecture: &mut A, units: Vec<A::Unit>, selected: &SelectedReplicatedTextRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::ResidentPolicy, Self::Error>; fn bounded_policy( &mut self, architecture: &mut A, selected: &SelectedReplicatedTextRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::BoundedPolicy, Self::Error>; fn index_text_output( &mut self, output: B::Tensor, sequence_index: i32, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<B::Tensor, Self::Error>; fn checkpoint_state( &mut self, state: &Self::State, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::StateCheckpoint, Self::Error>; fn restore_state( &mut self, state: &mut Self::State, checkpoint: Self::StateCheckpoint, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>; fn load_prompt_cache( &mut self, directory: &Path, expected: &PromptCacheDescriptor, identity: &PromptCacheModelIdentity, prefix_token_ids: &[u32], selected: &SelectedStateRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(Self::State, PromptCacheManifest), Self::Error>; fn save_prompt_cache( &mut self, state: &mut Self::State, destination: &Path, descriptor: PromptCacheDescriptor, prefix_token_ids: &[u32], options: &PromptCacheOptions, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<PromptCacheManifest, Self::Error>; fn state_report( &self, state: &Self::State, ) -> Result<Self::StateReport, Self::Error>; fn execution_report( &self, residency: LayerWeightResidency, bounded: Option<&Self::BoundedPolicy>, ) -> Result<Self::ExecutionReport, Self::Error>; fn complete( &mut self, output: &B::Tensor, state: &Self::State, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>; // Provided methods fn take_materialization_report( &mut self, ) -> Result<Option<WeightMaterializationReport>, Self::Error> { ... } fn configure_partition( &mut self, _target_layout: LocalModelLayout, _source_layout: Option<LocalModelLayout>, _rank: CacheRankIdentity, _global_layer_start: usize, ) { ... } fn prepare_partition_materialization( &mut self, architecture: &mut A, global_layout: &ExecutionUnitLayout, addresses: &[ExecutionUnitAddress], task_partition: &ReplicatedTextMaterializationPartitionPlan, units: &mut [A::Unit], source_architecture: Option<&mut A>, source_units: Option<&mut [A::Unit]>, tasks: &[ReplicatedTextMaterializationTask], addressable_parameters: &[String], context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error> { ... } fn fork_prediction_target_state( &mut self, state: &Self::State, selected: &SelectedStateRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::State, Self::Error> { ... }
}
Expand description

Backend mechanisms used by the generic replicated-text constructor.

Implementations allocate native state, prepare exact materialization tasks, supply a bounded residency policy, persist opaque state bytes, apply a requested native tensor index, and retain resources through final completion. The trait receives selected values but no family identity or caller selection request.

Required Associated Types§

Source

type State: RuntimeState<B>

Concrete mutable-state realization paired with the architecture.

Source

type PolicyError

Shared failure type for resident and bounded runtime policies.

Source

type ResidentPolicy: LayerwisePolicy<B, A::Unit, Error = Self::PolicyError>

Concrete policy that owns fully resident bound units.

Source

type BoundedPolicy: LayerwisePolicy<B, A::Unit, Error = Self::PolicyError>

Concrete policy used for host-windowed or disk-streamed traversal.

Source

type StateCheckpoint

Opaque state checkpoint owned by the backend mechanism.

Source

type StateReport

Backend-native mutable-state residency report.

Source

type ExecutionReport

Backend-native parameter/runtime residency report.

Source

type Error

Mechanism failure.

Required Methods§

Source

fn prepare_materialization( &mut self, architecture: &mut A, layout: &ExecutionUnitLayout, units: &mut [A::Unit], source_architecture: Option<&mut A>, source_units: Option<&mut [A::Unit]>, tasks: &[ReplicatedTextMaterializationTask], addressable_parameters: &[String], context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>

Consumes the exact selected parameter tasks before runtime construction.

Source

fn realize_state( &mut self, selected: &SelectedStateRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::State, Self::Error>

Realizes exactly the selected mutable-state components and placements.

Source

fn resident_policy( &mut self, architecture: &mut A, units: Vec<A::Unit>, selected: &SelectedReplicatedTextRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::ResidentPolicy, Self::Error>

Creates the concrete policy owning fully resident bound units.

Source

fn bounded_policy( &mut self, architecture: &mut A, selected: &SelectedReplicatedTextRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::BoundedPolicy, Self::Error>

Creates the concrete bounded-unit policy selected for this session.

Source

fn index_text_output( &mut self, output: B::Tensor, sequence_index: i32, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<B::Tensor, Self::Error>

Applies one neutral sequence-axis index to a complete architecture output.

Source

fn checkpoint_state( &mut self, state: &Self::State, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::StateCheckpoint, Self::Error>

Captures an opaque checkpoint of every live state component.

Source

fn restore_state( &mut self, state: &mut Self::State, checkpoint: Self::StateCheckpoint, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>

Restores every component from an opaque checkpoint.

Source

fn load_prompt_cache( &mut self, directory: &Path, expected: &PromptCacheDescriptor, identity: &PromptCacheModelIdentity, prefix_token_ids: &[u32], selected: &SelectedStateRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(Self::State, PromptCacheManifest), Self::Error>

Restores native state bytes from a validated prompt-cache artifact.

Source

fn save_prompt_cache( &mut self, state: &mut Self::State, destination: &Path, descriptor: PromptCacheDescriptor, prefix_token_ids: &[u32], options: &PromptCacheOptions, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<PromptCacheManifest, Self::Error>

Serializes native state bytes for a neutrally validated cache identity.

Source

fn state_report( &self, state: &Self::State, ) -> Result<Self::StateReport, Self::Error>

Reports the realized mutable-state storage.

Source

fn execution_report( &self, residency: LayerWeightResidency, bounded: Option<&Self::BoundedPolicy>, ) -> Result<Self::ExecutionReport, Self::Error>

Reports the selected resident or bounded runtime realization.

Source

fn complete( &mut self, output: &B::Tensor, state: &Self::State, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>

Retains final output and mutable state through exact completion.

Provided Methods§

Source

fn take_materialization_report( &mut self, ) -> Result<Option<WeightMaterializationReport>, Self::Error>

Takes the aggregate report produced while realizing the selected materialization tasks.

The neutral constructor calls this exactly once after successful preparation and retains the value with the completed session. This keeps report handoff in the same typed sequencing path as preparation instead of requiring an adapter-owned synchronization side channel.

Source

fn configure_partition( &mut self, _target_layout: LocalModelLayout, _source_layout: Option<LocalModelLayout>, _rank: CacheRankIdentity, _global_layer_start: usize, )

Configures rank-local neutral placement facts before partition payload preparation and state realization.

Source

fn prepare_partition_materialization( &mut self, architecture: &mut A, global_layout: &ExecutionUnitLayout, addresses: &[ExecutionUnitAddress], task_partition: &ReplicatedTextMaterializationPartitionPlan, units: &mut [A::Unit], source_architecture: Option<&mut A>, source_units: Option<&mut [A::Unit]>, tasks: &[ReplicatedTextMaterializationTask], addressable_parameters: &[String], context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>

Prepares exact payload work for an explicitly selected rank-local unit sequence.

The default is suitable for mechanisms whose ordinary preparation already accepts the global layout. Backends with distinct local-unit binding storage override this method while retaining the neutral construction sequencing.

Source

fn fork_prediction_target_state( &mut self, state: &Self::State, selected: &SelectedStateRealization, context: &<<B as NeuralBackend>::Tensor as Tensor>::Context, ) -> Result<Self::State, Self::Error>

Forks canonical state for one independently advanceable prediction lane.

The default composes ordinary realization and checkpoint restoration. Backends whose state carries immutable transaction identity, such as a paged-cache residency session, override this operation so copied content receives one coherent independent identity without weakening unrelated cross-session restore validation.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§