Skip to main content

Fp32MasterOptimizer

Struct Fp32MasterOptimizer 

Source
pub struct Fp32MasterOptimizer<O> { /* private fields */ }
Expand description

Opt-in FP32 master parameters for an existing simple optimizer.

The wrapped optimizer receives FP32 parameters and gradients; its algorithm, hyperparameters and per-parameter state are unchanged. Returned parameters retain their incoming storage dtype. Existing optimizers do not opt in.

Implementations§

Source§

impl<O> Fp32MasterOptimizer<O>

Source

pub fn new(optimizer: O) -> Self

Wrap an existing optimizer without modifying its configuration.

Source

pub fn with_grad_clipping(self, clipping: GradientClipping) -> Self

Explicitly apply RUDA’s existing per-parameter clipping after FP32 conversion.

Source

pub fn with_gradient_scale(self, scale: f32) -> Self

Explicitly divide gradients by this loss scale in FP32 before clipping.

The caller scales the loss and uses one scale for the accumulation window. No dynamic scaling, non-finite policy or optimizer-step skipping is enabled.

Source

pub fn init<B, M>(self) -> OptimizerAdaptor<Self, M, B>

Build RUDA’s original module adaptor, preserving parameter IDs and records. Clipping is disabled unless explicitly configured on the wrapper or adaptor.

Trait Implementations§

Source§

impl<O: Clone> Clone for Fp32MasterOptimizer<O>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Backend, O: SimpleOptimizer<B>> SimpleOptimizer<B> for Fp32MasterOptimizer<O>

Source§

type State<const D: usize> = Fp32MasterState<B, D, <O as SimpleOptimizer<B>>::State<D>>

The state of the optimizer. It also implements record, so that it can be saved.
Source§

fn step<const D: usize>( &self, lr: LearningRate, tensor: Tensor<B, D>, grad: Tensor<B, D>, state: Option<Self::State<D>>, ) -> (Tensor<B, D>, Option<Self::State<D>>)

The optimizer step is performed for one tensor at a time with its gradient and state. Read more
Source§

fn to_device<const D: usize>( state: Self::State<D>, device: &B::Device, ) -> Self::State<D>

Change the device of the state. Read more

Auto Trait Implementations§

§

impl<O> Freeze for Fp32MasterOptimizer<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for Fp32MasterOptimizer<O>
where O: RefUnwindSafe,

§

impl<O> Send for Fp32MasterOptimizer<O>
where O: Send,

§

impl<O> Sync for Fp32MasterOptimizer<O>
where O: Sync,

§

impl<O> Unpin for Fp32MasterOptimizer<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for Fp32MasterOptimizer<O>
where O: UnsafeUnpin,

§

impl<O> UnwindSafe for Fp32MasterOptimizer<O>
where O: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.