pub struct BackwardPassCoordinator { /* private fields */ }Expand description
Coordinates gradient collection and aggregation across peers.
Implementations§
Source§impl BackwardPassCoordinator
impl BackwardPassCoordinator
pub fn new(expected_peers: usize, timeout_ms: u64) -> Self
Sourcepub fn start_pass(&self, pass_id: BackwardPassId) -> bool
pub fn start_pass(&self, pass_id: BackwardPassId) -> bool
Start a new backward pass round. Returns false if pass_id already exists.
Sourcepub fn submit_contribution(
&self,
contribution: GradientContribution,
) -> Result<CoordinationStatus, CoordinationError>
pub fn submit_contribution( &self, contribution: GradientContribution, ) -> Result<CoordinationStatus, CoordinationError>
Submit a gradient contribution for a pass.
Returns an error if the pass is not found or is already Complete/Failed.
Sourcepub fn is_ready_to_aggregate(&self, pass_id: &BackwardPassId) -> bool
pub fn is_ready_to_aggregate(&self, pass_id: &BackwardPassId) -> bool
Returns true when all expected peers have submitted contributions.
Sourcepub fn mark_complete(
&self,
pass_id: &BackwardPassId,
aggregated_cid: impl Into<String>,
) -> bool
pub fn mark_complete( &self, pass_id: &BackwardPassId, aggregated_cid: impl Into<String>, ) -> bool
Mark aggregation as complete with result CID.
Sourcepub fn mark_failed(
&self,
pass_id: &BackwardPassId,
reason: impl Into<String>,
) -> bool
pub fn mark_failed( &self, pass_id: &BackwardPassId, reason: impl Into<String>, ) -> bool
Mark pass as failed with a reason string.
Sourcepub fn status(&self, pass_id: &BackwardPassId) -> Option<CoordinationStatus>
pub fn status(&self, pass_id: &BackwardPassId) -> Option<CoordinationStatus>
Get current status of a pass.
Sourcepub fn contributions(
&self,
pass_id: &BackwardPassId,
) -> Vec<GradientContribution>
pub fn contributions( &self, pass_id: &BackwardPassId, ) -> Vec<GradientContribution>
Get all contributions for a pass.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Total active (non-complete, non-failed) passes.
Sourcepub fn gc_before_round(&self, round: u64) -> usize
pub fn gc_before_round(&self, round: u64) -> usize
Remove completed/failed passes with pass_id.round < round.
Returns the number of passes removed.
Sourcepub fn timeout_ms(&self) -> u64
pub fn timeout_ms(&self) -> u64
Expose timeout setting (useful for callers).
Auto Trait Implementations§
impl !Freeze for BackwardPassCoordinator
impl !RefUnwindSafe for BackwardPassCoordinator
impl Send for BackwardPassCoordinator
impl Sync for BackwardPassCoordinator
impl Unpin for BackwardPassCoordinator
impl UnsafeUnpin for BackwardPassCoordinator
impl UnwindSafe for BackwardPassCoordinator
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> 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