Skip to main content

TrainingRecord

Struct TrainingRecord 

Source
pub struct TrainingRecord<B, M, O, S, U>
where B: AutodiffBackend, M: AutodiffModule<B>, O: Optimizer<M, B>, S: LrScheduler, U: Record<B>,
{ /* private fields */ }
Available on crate feature std only.
Expand description

One record containing the trainable state and a caller-defined continuation record.

Capture at a training boundary with no concurrent updates. The caller’s state carries its counters and any available input/RNG records; this type does not infer them or snapshot a DataLoader. Recorder precision settings apply to all component records and must preserve their values for exact continuation.

Implementations§

Source§

impl<B, M, O, S, U> TrainingRecord<B, M, O, S, U>
where B: AutodiffBackend, M: AutodiffModule<B>, O: Optimizer<M, B>, S: LrScheduler, U: Record<B>,

Source

pub fn capture( model: &M, optimizer: &O, scheduler: &S, accumulator: &GradientsAccumulator<M>, state: U, ) -> Result<Self, RecorderError>

Capture the components without consuming the model or clearing gradients.

Source

pub async fn capture_async( model: &M, optimizer: &O, scheduler: &S, accumulator: &GradientsAccumulator<M>, state: U, ) -> Result<Self, RecorderError>

Capture with asynchronous gradient readback; no recorder I/O is performed.

Source

pub fn save<R: Recorder<B>>( self, recorder: &R, args: R::RecordArgs, ) -> Result<R::RecordOutput, RecorderError>

Save all components in one recorder payload.

Source

pub fn load<R: Recorder<B>>( recorder: &R, args: R::LoadArgs, device: &B::Device, ) -> Result<Self, RecorderError>

Read a combined record using the selected recorder and device.

Source

pub fn restore( self, model: M, optimizer: O, scheduler: S, device: &B::Device, ) -> Result<RestoredTraining<M, O, S, U>, RecorderError>

Restore onto compatible model, optimizer and scheduler configurations.

No scheduler step, optimizer step or gradient reset is performed. Apply the returned caller state before consuming the next training batch.

Trait Implementations§

Source§

impl<B, M, O, S, U> Record<B> for TrainingRecord<B, M, O, S, U>
where B: AutodiffBackend, M: AutodiffModule<B>, O: Optimizer<M, B>, S: LrScheduler, U: Record<B>,

Source§

type Item<P: PrecisionSettings> = (<<M as Module<B>>::Record as Record<B>>::Item<P>, <<O as Optimizer<M, B>>::Record as Record<B>>::Item<P>, <<S as LrScheduler>::Record<B> as Record<B>>::Item<P>, <GradientsParamsRecord as Record<B>>::Item<P>, <U as Record<B>>::Item<P>)

Type of the item that can be serialized and deserialized.
Source§

fn into_item<P: PrecisionSettings>(self) -> Self::Item<P>

Convert the current record into the corresponding item that follows the given settings.
Source§

fn from_item<P: PrecisionSettings>( item: Self::Item<P>, device: &B::Device, ) -> Self

Convert the given item into a record.

Auto Trait Implementations§

§

impl<B, M, O, S, U> !RefUnwindSafe for TrainingRecord<B, M, O, S, U>

§

impl<B, M, O, S, U> !UnwindSafe for TrainingRecord<B, M, O, S, U>

§

impl<B, M, O, S, U> Freeze for TrainingRecord<B, M, O, S, U>
where <M as Module<B>>::Record: Freeze, <O as Optimizer<M, B>>::Record: Freeze, <S as LrScheduler>::Record<B>: Freeze, U: Freeze, PhantomData<fn() -> (B, M, O, S)>: Freeze,

§

impl<B, M, O, S, U> Send for TrainingRecord<B, M, O, S, U>
where <M as Module<B>>::Record: Send, <O as Optimizer<M, B>>::Record: Send, <S as LrScheduler>::Record<B>: Send, PhantomData<fn() -> (B, M, O, S)>: Send,

§

impl<B, M, O, S, U> Sync for TrainingRecord<B, M, O, S, U>
where <M as Module<B>>::Record: Sync, <O as Optimizer<M, B>>::Record: Sync, <S as LrScheduler>::Record<B>: Sync, U: Sync, PhantomData<fn() -> (B, M, O, S)>: Sync,

§

impl<B, M, O, S, U> Unpin for TrainingRecord<B, M, O, S, U>
where <M as Module<B>>::Record: Unpin, <O as Optimizer<M, B>>::Record: Unpin, <S as LrScheduler>::Record<B>: Unpin, U: Unpin, PhantomData<fn() -> (B, M, O, S)>: Unpin,

§

impl<B, M, O, S, U> UnsafeUnpin for TrainingRecord<B, M, O, S, U>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.