pub struct PhaseCallback<'hook> { /* private fields */ }Expand description
Consecutive phase policy over one super::super::Training lifecycle.
The phase schedule does not own another iterator. Its epoch/step totals must exactly match the iterator configuration, and its optional transition hook receives restricted mutable access to the iterator’s existing optimizer.
Implementations§
Source§impl<'hook> PhaseCallback<'hook>
impl<'hook> PhaseCallback<'hook>
Sourcepub fn add_phase(
&mut self,
id: impl Into<String>,
epochs: u64,
steps: u64,
) -> Result<()>
pub fn add_phase( &mut self, id: impl Into<String>, epochs: u64, steps: u64, ) -> Result<()>
Append a consecutive phase.
§Errors
Returns an error for invalid phase fields or aggregate count overflow.
Sourcepub fn set_on_phase_begin(
&mut self,
hook: impl FnMut(usize, &TrainingPhase, &mut dyn Optimizer) -> Result<()> + 'hook,
)
pub fn set_on_phase_begin( &mut self, hook: impl FnMut(usize, &TrainingPhase, &mut dyn Optimizer) -> Result<()> + 'hook, )
Install the hook invoked exactly once when each phase begins.
Sourcepub fn phases(&self) -> &[TrainingPhase]
pub fn phases(&self) -> &[TrainingPhase]
Return all configured phases in execution order.
Sourcepub const fn current_phase(&self) -> Option<usize>
pub const fn current_phase(&self) -> Option<usize>
Return the currently entered phase index.
Sourcepub fn total_epochs(&self) -> u64
pub fn total_epochs(&self) -> u64
Return the aggregate epoch count.
Sourcepub fn total_steps(&self) -> u64
pub fn total_steps(&self) -> u64
Return the aggregate step count.
Sourcepub fn phase_for_epoch(&self, epoch: u64) -> Result<(usize, u64)>
pub fn phase_for_epoch(&self, epoch: u64) -> Result<(usize, u64)>
Resolve a one-based global epoch to its phase index and one-based local epoch.
This query does not enter a phase or invoke its hook. Workloads that retain their own checkpoint boundaries can resolve restored progress without restarting callback accounting.
§Errors
Returns an error for zero or an epoch outside the configured schedule.