Skip to main content

GraphSession

Struct GraphSession 

Source
pub struct GraphSession { /* private fields */ }
Expand description

The primary orchestrator: Graph + catalog + cache + events.

let mut lib = NodeCatalog::new();
lib.register("scaler", Box::new(MyScaler::new()));
lib.register("model", Box::new(MyModel::new()));

let mut session = GraphSession::new(graph, lib);
session.fit(&train_x, Some(&train_y))?;
let output = session.forward(&test_x)?;

Implementations§

Source§

impl GraphSession

Source

pub fn new(graph: Graph, catalog: NodeCatalog) -> Self

A session over graph with an in-memory cache and its own event bus; the with_* builders swap in shared or persistent components.

Source

pub fn with_cache(self, cache: Arc<dyn CacheStore>) -> Self

Replace the default in-memory cache, e.g. with a tiered or persistent store shared across sessions.

Source

pub fn with_event_bus(self, bus: Arc<EventBus>) -> Self

Replace the session’s own event bus, e.g. with one a tracker is already subscribed to.

Source

pub fn with_data_store(self, store: Arc<dyn DataStore>) -> Self

Attach the data store batched forward passes read rows from.

Source

pub fn with_transports(self, transports: Vec<Arc<dyn Transport>>) -> Self

Attach one transport per worker, so a TrainingStrategy can run.

Without this, setting a strategy on a graph records it and nothing more — which is what it did for the whole life of the type. fit consults the graph’s strategy and, when it is not Local and transports are present, hands execution to StrategyExecutor.

Source

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

Name the workers behind the transports, in the same order.

Needed only by ModelParallel, whose partitions are pinned to a worker id or tag. Without it that strategy refuses rather than sending a partition to whichever worker happened to be first.

Source

pub fn with_transport(self, transport: Arc<dyn Transport>) -> Self

Attach the transport that carries Remote plan nodes to workers.

Source

pub fn with_driver(self, driver: EffectDriver) -> Self

Attach the effect driver a graph containing steps needs.

The session clones the driver per run and hands it the catalog at that moment, so filters or steps registered through Self::catalog_mut after this call still count. Without a driver, executing a step keeps failing with the executor’s own explanation.

Source

pub fn compile(&self, mode: CompileMode) -> Result<CompileResult>

Compile the graph and return diagnostics without executing.

Source

pub fn run(&mut self, mode: CompileMode) -> Result<HashMap<String, Value>>

Compile and execute the graph, returning all node outputs.

Emits a RunStarted/RunCompleted (or RunFailed) bracket around the node events so readers can compute total duration and group the run.

Source

pub fn fit( &mut self, x: &Value, y: Option<&Value>, ) -> Result<HashMap<String, Value>>

Fit all trainable filters in topological order. Delegates to LocalRunner — same execution path as remote workers.

Emits a RunStarted/RunCompleted (or RunFailed) bracket tagged with the same run id as the node events inside it.

Source

pub fn forward_with( &self, x: &Value, strategy: &dyn ForwardStrategy, ) -> Result<Value>

Forward pass using the given strategy.

Strategies define HOW data flows through the compiled graph:

Source

pub fn forward(&self, x: &Value) -> Result<Value>

Standard forward pass (shortcut for forward_with(x, &Standard)).

Source

pub fn persist_states(&self) -> Result<DataRef>

Persist all trained states to the data store.

Source

pub fn load_states(&mut self, data_ref: &DataRef) -> Result<()>

Load previously persisted states from a data store reference.

Source

pub fn subscribe(&self) -> Receiver<Event>

Subscribe to execution events.

Source

pub fn event_bus(&self) -> &Arc<EventBus>

Access the event bus directly.

Source

pub fn is_fitted(&self) -> bool

Whether the session has been fitted.

Source

pub fn graph(&self) -> &Graph

Access the graph.

Source

pub fn catalog(&self) -> &NodeCatalog

Access the node catalog.

Source

pub fn catalog_mut(&mut self) -> &mut NodeCatalog

Mutable access to the node catalog (for registering nodes after creation).

Auto Trait Implementations§

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
§

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

§

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.

§

impl<T> Instrument for T

§

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

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

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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