Skip to main content

DeviceMesh

Struct DeviceMesh 

Source
pub struct DeviceMesh {
    pub world_size: usize,
    pub rank: usize,
    pub topology: MeshTopology,
    pub comm: Option<Arc<dyn MeshComm + Send + Sync>>,
    /* private fields */
}
Expand description

Device Mesh for distributed ML inference

Manages a set of devices arranged in a logical mesh topology for data/tensor/pipeline parallelism. Optimized for memory efficiency.

Fields§

§world_size: usize

Total number of devices in the mesh

§rank: usize

This process’s global rank

§topology: MeshTopology

Mesh topology configuration

§comm: Option<Arc<dyn MeshComm + Send + Sync>>

Communication backend handle

Implementations§

Source§

impl DeviceMesh

Source

pub fn new(devices: Vec<Device>) -> Self

Create a new device mesh from a list of devices

Source

pub fn new_with_mock_comm(devices: Vec<Device>, rank: usize) -> Self

Create a new device mesh with a mock communication backend for testing

Source

pub fn with_topology( devices: Vec<Device>, topology: MeshTopology, ) -> Result<Self, String>

Create a mesh with specific topology

Source

pub fn set_rank(&mut self, rank: usize) -> Result<(), String>

Set the rank for this process

Source

pub fn get_device(&self, rank: usize) -> Option<Arc<Device>>

Get device by rank (memory efficient - returns Arc clone)

Source

pub fn local_device(&self) -> Option<Arc<Device>>

Get the local device for this process

Source

pub fn all_devices(&self) -> Arc<Vec<Arc<Device>>>

Get all devices (returns Arc to avoid cloning the entire Vec)

Source

pub fn devices_by_backend(&self, backend: DeviceBackend) -> Vec<Arc<Device>>

Get devices for a specific backend type (memory efficient)

Source

pub fn devices_in_group( &self, group_name: &str, ) -> Result<Vec<Arc<Device>>, String>

Get devices in a specific process group

Source

pub fn add_group( &mut self, name: String, ranks: Vec<usize>, backend: GroupBackend, ) -> Result<(), String>

Add a custom process group

Source

pub fn get_group(&self, name: &str) -> Option<&ProcessGroup>

Get a process group by name

Source

pub fn group_names(&self) -> Vec<String>

List all group names

Source

pub fn in_group(&self, group_name: &str) -> bool

Check if this rank is in a specific group

Source

pub fn group_rank(&self, group_name: &str) -> Option<usize>

Get rank within a group (local rank)

Source

pub fn set_comm(&mut self, comm: Arc<dyn MeshComm + Send + Sync>)

Set the communication backend

Source

pub fn total_memory_mb(&self) -> u64

Get total memory across all devices

Source

pub fn total_compute_units(&self) -> u32

Get total compute units across all devices

Source

pub fn reshape(&mut self, new_topology: MeshTopology) -> Result<(), String>

Reshape the mesh to a different topology

Source

pub fn stats(&self) -> MeshStats

Get mesh statistics

Trait Implementations§

Source§

impl Clone for DeviceMesh

Source§

fn clone(&self) -> DeviceMesh

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceMesh

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.