oa::ml::training::ItTraining

Exact eager or captured training-step lifecycle. The loop borrows the engine, optimizer, metrics, and callbacks. Call ItTraining::begin_step before authoring each body, then finish it with ItTraining::complete_step or ItTraining::complete_program_step. ItTraining::finish is the explicit fallible terminal boundary.

StRust public API

Declaration

pub struct ItTraining<'engine, 'hooks> { /* private fields */ }
Public Rust declaration.

Public Methods

pub fn add_metric(&mut self, metric: &'hooks mut dyn TrainingMetric)
pub fn add_callback(&mut self, callback: &'hooks mut dyn TrainingCallback)
pub fn attach_session( &mut self, session: &TrainingSession, handlers: TrainingSessionHandlers<'hooks>, ) -> Result<()>
pub fn register_session_parameter( &mut self, desc: TrainingParameterDesc<'hooks>, ) -> Result<()>
pub fn zero_grad(&self)
pub fn request_stop(&mut self)
pub const fn stop_requested(&self) -> bool
pub fn begin_step(&mut self) -> Result<bool>
pub fn wait_begin_step(&mut self) -> Result<bool>
pub fn complete_step(&mut self, loss: &Matrix) -> Result<()>
pub fn step<P>( &mut self, prepare: impl FnOnce() -> Result<P>, record: impl FnOnce(P) -> Result<Matrix>, ) -> Result<bool>
pub const fn training_program(&self) -> Option<&TrainingProgram>
pub const fn program_capture_fallback_count(&self) -> u64
pub fn last_program_capture_fallback(&self) -> Option<&str>
pub fn request_program_recapture(&mut self) -> Result<()>
pub fn seal_replay_inputs(&mut self) -> Result<()>
pub fn complete_program_step( &mut self, program: &mut TrainingProgram, ) -> Result<()>
pub fn record_source_units(&mut self, units: u64)
pub fn exclude_wall_time(&mut self, duration: Duration)
pub fn snapshot(&self) -> TrainingSnapshot
pub fn gpu_timing_stats(&self) -> GpuTimingStats
pub fn finish(self) -> Result<TrainingSnapshot>
fn drop(&mut self)

Associated Functions

pub fn new( engine: &'engine Engine, optimizer: &'engine mut AdamW, config: ItTrainingConfig, ) -> Result<Self>
pub fn new_eager( engine: &'engine Engine, optimizer: &'engine mut dyn Optimizer, config: ItTrainingConfig, ) -> Result<Self>
pub fn new_eager_checkpointable( engine: &'engine Engine, optimizer: &'engine mut dyn CheckpointOptimizer, config: ItTrainingConfig, ) -> Result<Self>

Public Method Documentation

pub fn add_metric( &mut self, metric: &'hooks mut dyn TrainingMetric )
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub fn add_callback( &mut self, callback: &'hooks mut dyn TrainingCallback )
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub fn attach_session( &mut self, session: &TrainingSession, handlers: TrainingSessionHandlers<'hooks>, ) -> Result<()>
No public source comment is attached to this declaration.
pub fn register_session_parameter( &mut self, desc: TrainingParameterDesc<'hooks>, ) -> Result<()>
No public source comment is attached to this declaration.
pub fn zero_grad( &self )
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub fn request_stop( &mut self )
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub const fn stop_requested( &self ) -> bool
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub fn begin_step( &mut self ) -> Result<bool>
No public source comment is attached to this declaration.
pub fn wait_begin_step( &mut self ) -> Result<bool>
No public source comment is attached to this declaration.
pub fn complete_step(&mut self, loss: &Matrix) -> Result<()>
No public source comment is attached to this declaration.
pub fn step<P>( &mut self, prepare: impl FnOnce() -> Result<P>, record: impl FnOnce(P) -> Result<Matrix> ) -> Result<bool>
No public source comment is attached to this declaration.
pub const fn training_program( &self ) -> Option<&TrainingProgram>
No public source comment is attached to this declaration.
pub const fn program_capture_fallback_count( &self ) -> u64
No public source comment is attached to this declaration.
pub fn last_program_capture_fallback( &self ) -> Option<&str>
No public source comment is attached to this declaration.
pub fn request_program_recapture(&mut self) -> Result<()>
No public source comment is attached to this declaration.
pub fn seal_replay_inputs(&mut self) -> Result<()>
No public source comment is attached to this declaration.
pub fn complete_program_step( &mut self, program: &mut TrainingProgram, ) -> Result<()>
No public source comment is attached to this declaration.
pub fn record_source_units( &mut self, units: u64 )
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub fn exclude_wall_time( &mut self, duration: Duration )
No public source comment is attached to this declaration.
pub fn snapshot( &self ) -> TrainingSnapshot
Construct a training lifecycle around one engine and optimizer. Errors Returns an error when source-unit accounting is non-finite or overflows, or the variable epoch schedule overflows.
pub fn gpu_timing_stats( &self ) -> GpuTimingStats
No public source comment is attached to this declaration.
pub fn finish( self ) -> Result<TrainingSnapshot>
No public source comment is attached to this declaration.
fn drop( &mut self )
No public source comment is attached to this declaration.
pub fn new( engine: &'engine Engine, optimizer: &'engine mut AdamW, config: ItTrainingConfig ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn new_eager( engine: &'engine Engine, optimizer: &'engine mut dyn Optimizer, config: ItTrainingConfig ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn new_eager_checkpointable( engine: &'engine Engine, optimizer: &'engine mut dyn CheckpointOptimizer, config: ItTrainingConfig ) -> Result<Self>
No public source comment is attached to this declaration.