Skip to main content

Cluster

Struct Cluster 

Source
pub struct Cluster {
    pub cfg: ClusterConfig,
    pub caps: Vec<NodeCaps>,
    pub plan: Vec<Assignment>,
    pub chosen_precision: Option<String>,
    /* private fields */
}
Expand description

A configured, probed, planned cluster.

Fields§

§cfg: ClusterConfig§caps: Vec<NodeCaps>

Probed hardware, one per node (same order as cfg.nodes). Empty until Cluster::probe.

§plan: Vec<Assignment>

Layer→node plan. Empty until Cluster::plan. Standby stages follow the active ones and mirror their layer ranges.

§chosen_precision: Option<String>

Set when the precision ladder had to step down from the stored width.

Implementations§

Source§

impl Cluster

Source

pub fn from_config(cfg: ClusterConfig) -> Self

Source

pub fn from_path(p: impl AsRef<Path>) -> Result<Self>

Source

pub fn probe(&mut self, remote_bin: &str) -> Result<&[NodeCaps]>

Probe every node’s hardware. remote_bin is the worker binary path on the remote hosts (its --probe mode self-reports); nodes without ssh are probed locally.

Source

pub fn discover( &mut self, remote_bin: &str, ) -> Result<(usize, Vec<(String, String)>)>

Find machines from the [discover] section and append them to cfg.nodes. Returns (added, failures); a host that will not probe is reported rather than fatal, so one dead machine does not stop the rest.

Idempotent: nodes already present (by addr) are left alone, so hand-pinned entries survive and re-running adds nothing.

Source

pub fn autoplan( &mut self, index: &[TensorEntry], opts: &CostOptions, remote_bin: &str, ) -> Result<&[Assignment]>

Discover → probe → cost → plan, in one call.

The DX this module exists for: point it at a checkpoint’s tensor index and get an assignment back, without hand-writing node blocks or working out per-layer bytes. remote_bin is the worker binary on the remote hosts (its --probe mode self-reports).

Discovery is skipped when [discover] is absent, so an all-manual config still works and this is just probe + plan with the cost derived for you.

Source

pub fn retire(&mut self, addr: &str, model: ModelCost) -> Result<&[Assignment]>

Retire a node, moving its work off without a restart.

Marks it Draining and, if a standby is mirroring it, promotes that standby in place — it already holds the same layers, so this is a pointer swap. With no standby the remaining active nodes are re-planned, which works but reloads weights, so a cluster you intend to drain should carry spares.

Re-plans from the caps already probed; call Cluster::probe first if the hardware may have changed.

Source

pub fn active_nodes(&self) -> Vec<&NodeConfig>

Active nodes remaining after any draining/standby ones are excluded.

Source

pub fn kv_profile(&self) -> KvProfile

The KV profile the last plan used, after the objective’s override and unknown-handling are applied.

Source

pub fn plan_table(&self) -> String

The plan as a table — what each machine ends up holding.

Shows the disk column and the predicted per-stage time, because for an MoE those are what the assignment actually turned on; a plan that looks RAM-balanced can still be badly skewed by one node’s slow disk.

Source

pub fn plan(&mut self, model: ModelCost) -> Result<&[Assignment]>

Plan placement from the model cost model + probed caps (probe first).

Source

pub fn worker_argv(&self, i: usize) -> Vec<String>

The worker command-line for node i from its plan + config — so the model crate’s worker binary honours device / precision / rng / kv / layers.

Source

pub fn launch(&self, remote_bin: &str) -> Result<Vec<Child>>

Spawn a worker process per node (ssh for remote, local otherwise). The caller drives them via Cluster::drive, then reaps the children.

Source

pub fn drive(&self, inputs: Vec<NamedTensor>) -> Result<ClusterRun>

Drive one forward through the planned stages, timing each, and collect the output. inputs seeds the first stage (e.g. input_ids). Boundary tensor name is hidden/hidden_in per the model’s stage I/O convention.

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
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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.