pub trait PartitionedLayeredArchitecture<B, S>: ParallelLayeredArchitecture<B, S>where
B: NeuralBackend,
S: RuntimeState<B>,{
type Boundary: ArchitectureBoundary;
// Required methods
fn boundary_schema(&self) -> Result<Self::Boundary, Self::Error>;
fn begin_partition<'a>(
&mut self,
input: LayeredPartitionInput<'a, B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>,
mask: Option<&B::Tensor>,
state: &mut S,
expected: &StateLayout,
first_state_ordinal: usize,
context: &<B::Tensor as Tensor>::Context,
) -> Result<LayeredForwardState<B::Tensor, Self::ForwardContext>, Self::Error>;
fn begin_partition_parallel<'a>(
&mut self,
input: LayeredPartitionInput<'a, B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>,
mask: Option<&B::Tensor>,
state: &mut S,
expected: &StateLayout,
first_state_ordinal: usize,
parallel: &B::ParallelContext,
context: &<B::Tensor as Tensor>::Context,
) -> Result<LayeredForwardState<B::Tensor, Self::ForwardContext>, Self::Error>;
fn finish_partition(
&mut self,
hidden: &B::Tensor,
state: &mut S,
forward: &Self::ForwardContext,
owns_output: bool,
parallel: Option<&B::ParallelContext>,
context: &<B::Tensor as Tensor>::Context,
) -> Result<LayeredPartitionOutput<B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>, Self::Error>;
// Provided methods
fn enter_partition_group(
&mut self,
group: usize,
initial: &B::Tensor,
state: &mut S,
forward: &mut Self::ForwardContext,
parallel: Option<&B::ParallelContext>,
context: &<B::Tensor as Tensor>::Context,
) -> Result<B::Tensor, Self::Error> { ... }
fn leave_partition_group(
&mut self,
group: usize,
hidden: &B::Tensor,
state: &mut S,
forward: &mut Self::ForwardContext,
parallel: Option<&B::ParallelContext>,
context: &<B::Tensor as Tensor>::Context,
) -> Result<B::Tensor, Self::Error> { ... }
}Expand description
Architecture-owned preparation for rank-local partition execution.
The neutral partition driver owns validation, group sequencing, and output ownership. Architectures own the semantic conversion of partition inputs, entry into and completion of their selected execution group, and typed partition output.
Required Associated Types§
Sourcetype Boundary: ArchitectureBoundary
type Boundary: ArchitectureBoundary
Architecture-owned schema for primary and auxiliary partition transport.
Required Methods§
Sourcefn boundary_schema(&self) -> Result<Self::Boundary, Self::Error>
fn boundary_schema(&self) -> Result<Self::Boundary, Self::Error>
Derives the complete transport schema from the normalized architecture.
Sourcefn begin_partition<'a>(
&mut self,
input: LayeredPartitionInput<'a, B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>,
mask: Option<&B::Tensor>,
state: &mut S,
expected: &StateLayout,
first_state_ordinal: usize,
context: &<B::Tensor as Tensor>::Context,
) -> Result<LayeredForwardState<B::Tensor, Self::ForwardContext>, Self::Error>
fn begin_partition<'a>( &mut self, input: LayeredPartitionInput<'a, B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>, mask: Option<&B::Tensor>, state: &mut S, expected: &StateLayout, first_state_ordinal: usize, context: &<B::Tensor as Tensor>::Context, ) -> Result<LayeredForwardState<B::Tensor, Self::ForwardContext>, Self::Error>
Prepares a replicated partition from tokens or upstream hidden state.
Sourcefn begin_partition_parallel<'a>(
&mut self,
input: LayeredPartitionInput<'a, B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>,
mask: Option<&B::Tensor>,
state: &mut S,
expected: &StateLayout,
first_state_ordinal: usize,
parallel: &B::ParallelContext,
context: &<B::Tensor as Tensor>::Context,
) -> Result<LayeredForwardState<B::Tensor, Self::ForwardContext>, Self::Error>
fn begin_partition_parallel<'a>( &mut self, input: LayeredPartitionInput<'a, B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>, mask: Option<&B::Tensor>, state: &mut S, expected: &StateLayout, first_state_ordinal: usize, parallel: &B::ParallelContext, context: &<B::Tensor as Tensor>::Context, ) -> Result<LayeredForwardState<B::Tensor, Self::ForwardContext>, Self::Error>
Prepares the tensor-parallel form of the same partition.
Sourcefn finish_partition(
&mut self,
hidden: &B::Tensor,
state: &mut S,
forward: &Self::ForwardContext,
owns_output: bool,
parallel: Option<&B::ParallelContext>,
context: &<B::Tensor as Tensor>::Context,
) -> Result<LayeredPartitionOutput<B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>, Self::Error>
fn finish_partition( &mut self, hidden: &B::Tensor, state: &mut S, forward: &Self::ForwardContext, owns_output: bool, parallel: Option<&B::ParallelContext>, context: &<B::Tensor as Tensor>::Context, ) -> Result<LayeredPartitionOutput<B::Tensor, <Self::Boundary as ArchitectureBoundary>::Boundary<B::Tensor>>, Self::Error>
Emits an architecture partition after its execution group has closed.
Provided Methods§
Sourcefn enter_partition_group(
&mut self,
group: usize,
initial: &B::Tensor,
state: &mut S,
forward: &mut Self::ForwardContext,
parallel: Option<&B::ParallelContext>,
context: &<B::Tensor as Tensor>::Context,
) -> Result<B::Tensor, Self::Error>
fn enter_partition_group( &mut self, group: usize, initial: &B::Tensor, state: &mut S, forward: &mut Self::ForwardContext, parallel: Option<&B::ParallelContext>, context: &<B::Tensor as Tensor>::Context, ) -> Result<B::Tensor, Self::Error>
Enters the selected execution group after the partition input has been prepared. The default is the ordinary layered group entry with no graph dependencies; graph architectures may override this when their partition input is already assembled.
Sourcefn leave_partition_group(
&mut self,
group: usize,
hidden: &B::Tensor,
state: &mut S,
forward: &mut Self::ForwardContext,
parallel: Option<&B::ParallelContext>,
context: &<B::Tensor as Tensor>::Context,
) -> Result<B::Tensor, Self::Error>
fn leave_partition_group( &mut self, group: usize, hidden: &B::Tensor, state: &mut S, forward: &mut Self::ForwardContext, parallel: Option<&B::ParallelContext>, context: &<B::Tensor as Tensor>::Context, ) -> Result<B::Tensor, Self::Error>
Completes the selected execution group before the architecture emits its final value or typed pipeline boundary.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".