Skip to main content

Muon

Struct Muon 

Source
pub struct Muon { /* private fields */ }
Expand description

Muon optimizer with Nesterov momentum and rank-two NS5 orthogonalization.

Rank-two parameters use the donor Muon matrix pipeline. Other ranks use its fused momentum update; OA never silently delegates them to AdamW.

Implementations§

Source§

impl Muon

Source

pub fn new( parameters: impl IntoIterator<Item = Parameter>, learning_rate: f32, ) -> Result<Self>

Bind Muon to a nonempty FP32 parameter set using OA defaults.

§Errors

Returns an error for invalid ownership, duplicate parameters, or momentum allocation failure.

Source

pub fn new_with_hyperparameters( parameters: impl IntoIterator<Item = Parameter>, learning_rate: f32, beta: f32, weight_decay: f32, epsilon: f32, ns5_iterations: u32, ) -> Result<Self>

Bind Muon with explicit donor scalar policy.

Zero NS5 iterations selects the fused vector update for every parameter.

§Errors

Returns an error for invalid scalars, an empty or duplicate parameter set, non-F32 parameters, mixed-runtime ownership, or momentum allocation failure.

Source

pub fn zero_grad(&self)

Discard all accumulated gradients.

Source

pub fn step(&mut self) -> Result<()>

Record one Muon update for each parameter carrying a gradient.

§Errors

Returns an error when the step counter is exhausted, a parameter contract changed, or runtime recording/allocation fails.

Source

pub const fn learning_rate(&self) -> f32

Return the learning rate used by the next step.

Source

pub fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>

Set the learning rate used by subsequent steps.

§Errors

Returns an error unless the value is finite and non-negative.

Source

pub const fn step_count(&self) -> u64

Return the number of completed logical steps.

Trait Implementations§

Source§

impl Optimizer for Muon

Source§

fn zero_grad(&self)

Discard every currently accumulated parameter gradient.
Source§

fn step(&mut self) -> Result<()>

Record one logical parameter update. Read more
Source§

fn learning_rate(&self) -> f32

Return the learning rate used by the next optimizer step.
Source§

fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>

Set the learning rate used by subsequent optimizer steps. Read more
Source§

fn step_count(&self) -> u64

Return the number of completed logical optimizer steps.
Source§

fn belongs_to(&self, runtime: &Runtime) -> bool

Return whether this optimizer can participate in work owned by runtime.
Source§

fn set_finite_gate(&mut self, flag: &Matrix) -> Result<()>

Bind a device-resident finite flag gating captured updates. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Muon

§

impl !Send for Muon

§

impl !Sync for Muon

§

impl !UnwindSafe for Muon

§

impl Forget for Muon

§

impl Freeze for Muon
where *const u8 is !null: Freeze, PhantomData<MuonParameterState>: Freeze,

§

impl Move for Muon

§

impl Unpin for Muon
where *const u8 is !null: Unpin, Rc<RefCell<ParameterState>>: Unpin, Rc<RefCell<RuntimeState>>: Unpin, Rc<StorageInner>: Unpin, Rc<MatrixSemantic>: Unpin, Rc<()>: Unpin,

§

impl UnsafeUnpin for Muon
where *const u8 is !null: UnsafeUnpin, PhantomData<MuonParameterState>: UnsafeUnpin,

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> CheckpointOptimizer for T
where T: Optimizer + Persistence,

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.