Skip to main content

TransportContext

Struct TransportContext 

Source
pub struct TransportContext<'a> { /* private fields */ }
Expand description

A StrategyContext over one Transport per worker.

This is the piece that was missing: StrategyExecutor was written and had nowhere to run, because nothing implemented the context it takes.

It deliberately does not send GetState/SetState over the wire, even though the worker now answers them: a Fit already returns its trained states in the plan result, so asking again would be a second round trip for something already in hand. Gradients are different — nothing else carries them — so those two do go to the worker.

Implementations§

Source§

impl<'a> TransportContext<'a>

Source

pub fn new( transports: Vec<Arc<dyn Transport>>, plan: &'a ExecutionPlan, catalog: &'a NodeCatalog, seed: Option<i64>, ) -> Self

One transport per worker, in the order the strategy will index them.

Source

pub fn with_targets(self, identities: Vec<WorkerIdentity>) -> Self

Name the workers, so a partition pinned to an id or a tag can find one. Without this, worker_for refuses rather than guessing.

Trait Implementations§

Source§

impl StrategyContext for TransportContext<'_>

Source§

fn num_workers(&self) -> usize

Number of available workers.
Source§

fn execute_on_worker( &self, worker_idx: usize, _plan: &Value, input: &Value, y: Option<&Value>, ) -> Result<HashMap<String, Value>>

Execute a plan on a specific worker (by index). Returns trained states.
Source§

fn get_state( &self, worker_idx: usize, node_ids: &[String], ) -> Result<HashMap<String, Value>>

Get trained states from a worker.
Source§

fn worker_for(&self, target: &RemoteTarget) -> Result<usize>

Which worker answers to target. Read more
Source§

fn execute_partition( &self, worker_idx: usize, node_ids: &[String], input: &Value, y: Option<&Value>, ) -> Result<(Value, HashMap<String, Value>)>

Run part of the graph on a worker, returning the activation and the states it learned. Read more
Source§

fn read_back_state( &self, worker_idx: usize, node_ids: &[String], ) -> Result<HashMap<String, Value>>

Read a worker’s state now, over the wire, rather than recalling what its last fit returned. Read more
Source§

fn set_state( &self, worker_idx: usize, states: &HashMap<String, Value>, ) -> Result<()>

Set states on a worker (e.g. after aggregation).
Source§

fn get_gradients( &self, worker_idx: usize, node_ids: &[String], ) -> Result<HashMap<String, Value>>

Get gradients from a worker.
Source§

fn apply_gradients( &self, worker_idx: usize, gradients: &HashMap<String, Value>, ) -> Result<()>

Apply gradients on a worker.

Auto Trait Implementations§

§

impl<'a> !Freeze for TransportContext<'a>

§

impl<'a> !RefUnwindSafe for TransportContext<'a>

§

impl<'a> !UnwindSafe for TransportContext<'a>

§

impl<'a> Send for TransportContext<'a>

§

impl<'a> Sync for TransportContext<'a>

§

impl<'a> Unpin for TransportContext<'a>

§

impl<'a> UnsafeUnpin for TransportContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

The receiver as &dyn Any, ready for downcast_ref.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more