Skip to main content

ExpertRouteTensorMovement

Trait ExpertRouteTensorMovement 

Source
pub trait ExpertRouteTensorMovement<T> {
    type Error;

    // Required methods
    fn shape(&self, value: &T) -> Vec<usize>;
    fn gather_rows(
        &mut self,
        value: &T,
        rows: &[usize],
    ) -> Result<T, Self::Error>;
    fn gather_route_values(
        &mut self,
        value: &T,
        flattened_routes: &[usize],
    ) -> Result<T, Self::Error>;
    fn scatter_add_rows(
        &mut self,
        value: T,
        destination_rows: &[usize],
        output_rows: usize,
    ) -> Result<T, Self::Error>;
}
Expand description

Backend-neutral tensor movement needed by an expert-exchange protocol.

Architecture code supplies already validated row and flattened-route indices. Implementations retain tensor storage and completion ownership; they do not receive expert identities, topology, or model-family policy.

Required Associated Types§

Source

type Error

Tensor movement failure.

Required Methods§

Source

fn shape(&self, value: &T) -> Vec<usize>

Returns the logical tensor shape without materializing its values.

Source

fn gather_rows(&mut self, value: &T, rows: &[usize]) -> Result<T, Self::Error>

Duplicates and reorders leading-axis rows in the supplied order.

Source

fn gather_route_values( &mut self, value: &T, flattened_routes: &[usize], ) -> Result<T, Self::Error>

Selects flattened route scalars and returns them as [routes, 1].

Source

fn scatter_add_rows( &mut self, value: T, destination_rows: &[usize], output_rows: usize, ) -> Result<T, Self::Error>

Additively combines route rows into their architecture source rows.

Every input row must be consumed exactly once. Repeated destination rows are intentional and implement weighted routed-expert summation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§