pub trait Transport: Send + Sync {
// Required methods
fn execute(
&self,
plan: &ExecutionPlan,
filters: &NodeCatalog,
input: &Value,
mode: &RunMode,
seed: Option<i64>,
) -> Result<(Value, HashMap<String, Value>)>;
fn get_state(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>;
fn set_state(&self, states: &HashMap<String, Value>) -> Result<()>;
fn get_gradients(
&self,
node_ids: &[String],
) -> Result<HashMap<String, Value>>;
fn apply_gradients(&self, gradients: &HashMap<String, Value>) -> Result<()>;
// Provided method
fn execute_node(
&self,
node_id: &str,
input: Option<&Value>,
) -> Result<Value> { ... }
}Expand description
Abstraction for communicating with remote workers. Implemented by WsTransport (WebSocket), but could be HTTP, gRPC, etc.
Required Methods§
Sourcefn execute(
&self,
plan: &ExecutionPlan,
filters: &NodeCatalog,
input: &Value,
mode: &RunMode,
seed: Option<i64>,
) -> Result<(Value, HashMap<String, Value>)>
fn execute( &self, plan: &ExecutionPlan, filters: &NodeCatalog, input: &Value, mode: &RunMode, seed: Option<i64>, ) -> Result<(Value, HashMap<String, Value>)>
Send a plan for execution and receive the output + trained states.
mode says what to do with the nodes, and carries the labels when
there are any. It replaced a fit_mode: bool sitting beside an
y: Option<&Value> — a flag selecting between two operations with
differently shaped results, and a parameter that meant nothing
unless the flag was set. It is the same RunMode the local
executor reads, so the two paths cannot disagree about what a fit is.
seed is the run’s experiment seed, and it is a parameter rather
than something the transport digs out because the transport has no
RunContext to dig in. Without it the worker salts nothing, and a
five-seed sweep run remotely shares one cache line across all five —
the worker protocol’s SerializedPlan::seed documents that as the
bug it exists to close, and this path was still passing None.
Sourcefn get_state(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
fn get_state(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
Request trained states from the remote worker.
Sourcefn set_state(&self, states: &HashMap<String, Value>) -> Result<()>
fn set_state(&self, states: &HashMap<String, Value>) -> Result<()>
Load states on the remote worker.
Sourcefn get_gradients(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
fn get_gradients(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
Request gradients from the remote worker.
Sourcefn apply_gradients(&self, gradients: &HashMap<String, Value>) -> Result<()>
fn apply_gradients(&self, gradients: &HashMap<String, Value>) -> Result<()>
Apply aggregated gradients on the remote worker.
Provided Methods§
Sourcefn execute_node(&self, node_id: &str, input: Option<&Value>) -> Result<Value>
fn execute_node(&self, node_id: &str, input: Option<&Value>) -> Result<Value>
Convenience: execute a single node remotely (used by the plan executor).
Unseeded, and it has to be: this takes a node id and nothing else,
so there is no run to take a seed from. Callers that have a
RunContext should go through Transport::execute with
ctx.seed instead of reaching for this.