Skip to main content

TrainingFitOptions

Struct TrainingFitOptions 

Source
pub struct TrainingFitOptions<'fit, 'runtime> {
    pub categorical_accuracy: bool,
    pub validation: Option<&'fit mut dyn FnMut() -> Result<EvaluationReport>>,
    pub checkpoint: Option<(&'fit mut CheckpointManager<'runtime>, &'fit dyn Module)>,
    pub accumulation_steps: u64,
    pub resume: Option<RunState>,
    pub precision: Option<PrecisionPolicy>,
    pub scaler: Option<&'fit mut GradScaler>,
}
Expand description

Optional classification metrics, validation, and checkpointing for a fit.

Fields§

§categorical_accuracy: bool

Accumulate categorical accuracy without per-batch host observation.

§validation: Option<&'fit mut dyn FnMut() -> Result<EvaluationReport>>

Evaluate the held-out split after each complete epoch.

§checkpoint: Option<(&'fit mut CheckpointManager<'runtime>, &'fit dyn Module)>

Save and restore the best validation loss with the native checkpoint manager.

§accumulation_steps: u64

Microbatches per optimizer update. One preserves the per-batch update contract exactly. Above one, the loop owns the accumulation window: each microbatch objective is scaled to a per-sample sum before backward, parameter gradients accumulate across the window, the exact window denominator corrects them before the update — so incomplete tail windows remain exact rather than mean-of-means — and lifecycle update counters, completion hooks, and schedules observe one step per applied update while sample accounting counts every microbatch. Managed fits derive the parameter set from the model; caller-driven batch sources must leave this at one.

§resume: Option<RunState>

Exact-resume position loaded beside an incremental checkpoint. The run continues at resume.epoch — epochs remains the total epoch budget of the run, so a resumed fit executes resume.epoch..epochs. A nonzero loader cursor continues a partial first epoch; commits the managed fit writes itself always land on epoch boundaries, but manual loops may commit mid-epoch. Registered per-module RNG streams and checkpoint best-selection criteria carried in resume are restored before the resumed loop runs. When scaler is also provided, resume.scaler is restored onto it before the resumed loop runs.

§precision: Option<PrecisionPolicy>

Optional runtime-scoped precision policy entered for the duration of this fit and restored automatically when the fit returns.

§scaler: Option<&'fit mut GradScaler>

Optional dynamic gradient scaler for mixed-precision managed fits. Required whenever the effective precision policy requires scaling (such as PrecisionPolicy::f16_storage).

Implementations§

Source§

impl TrainingFitOptions<'_, '_>

Source

pub fn new() -> Self

Construct default fit options.

Trait Implementations§

Source§

impl<'fit, 'runtime> Default for TrainingFitOptions<'fit, 'runtime>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'fit, 'runtime> !RefUnwindSafe for TrainingFitOptions<'fit, 'runtime>

§

impl<'fit, 'runtime> !Send for TrainingFitOptions<'fit, 'runtime>

§

impl<'fit, 'runtime> !Sync for TrainingFitOptions<'fit, 'runtime>

§

impl<'fit, 'runtime> !UnwindSafe for TrainingFitOptions<'fit, 'runtime>

§

impl<'fit, 'runtime> Forget for TrainingFitOptions<'fit, 'runtime>

§

impl<'fit, 'runtime> Freeze for TrainingFitOptions<'fit, 'runtime>
where &'fit mut dyn FnMut() -> Result<EvaluationReport, Error>: Freeze, &'fit mut CheckpointManager<'runtime>: Freeze, &'fit dyn Module: Freeze, *const u8 is !null: Freeze, PhantomData<RngStreamPosition>: Freeze, &'fit mut GradScaler: Freeze,

§

impl<'fit, 'runtime> Move for TrainingFitOptions<'fit, 'runtime>

§

impl<'fit, 'runtime> Unpin for TrainingFitOptions<'fit, 'runtime>
where &'fit mut dyn FnMut() -> Result<EvaluationReport, Error>: Unpin, &'fit mut CheckpointManager<'runtime>: Unpin, &'fit dyn Module: Unpin, *const u8 is !null: Unpin, &'fit mut GradScaler: Unpin,

§

impl<'fit, 'runtime> UnsafeUnpin for TrainingFitOptions<'fit, 'runtime>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.