pub struct FsdpUnit {
pub unit_id: usize,
pub param_names: Vec<String>,
pub total_params: usize,
pub shard_size: usize,
pub is_offloaded: bool,
}Expand description
One FSDP unit — wraps a group of parameters that are collectively sharded.
Fields§
§unit_id: usizeUnique identifier for this unit
param_names: Vec<String>Names of parameters in this unit
total_params: usizeTotal number of parameters across all ranks
shard_size: usizeNumber of parameters this rank holds (shard_size = ceil(total/world_size))
is_offloaded: boolWhether the shard is currently offloaded to CPU
Implementations§
Source§impl FsdpUnit
impl FsdpUnit
Sourcepub fn new(
unit_id: usize,
param_names: Vec<String>,
total_params: usize,
world_size: usize,
) -> Self
pub fn new( unit_id: usize, param_names: Vec<String>, total_params: usize, world_size: usize, ) -> Self
Create a new FSDP unit.
Sourcepub fn memory_bytes_per_rank(&self) -> usize
pub fn memory_bytes_per_rank(&self) -> usize
Memory in bytes used by this rank’s shard.
Uses 8 bytes per parameter (f64).
Sourcepub fn local_params(&self) -> usize
pub fn local_params(&self) -> usize
Number of parameters held locally by this rank (= shard_size).
Sourcepub fn all_gather_buffer_size(&self) -> usize
pub fn all_gather_buffer_size(&self) -> usize
Size of the AllGather output buffer (= total_params — full reconstruction needed for forward pass).
Sourcepub fn reduce_scatter_buffer_size(&self) -> usize
pub fn reduce_scatter_buffer_size(&self) -> usize
Size of the ReduceScatter input/output buffer (= total_params).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FsdpUnit
impl RefUnwindSafe for FsdpUnit
impl Send for FsdpUnit
impl Sync for FsdpUnit
impl Unpin for FsdpUnit
impl UnsafeUnpin for FsdpUnit
impl UnwindSafe for FsdpUnit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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