Skip to main content

MoeSpec

Struct MoeSpec 

Source
pub struct MoeSpec {
Show 19 fields pub out: Symbol, pub x: Symbol, pub wr: Symbol, pub wg: Symbol, pub wu: Symbol, pub wd: Symbol, pub d: usize, pub dff: usize, pub ne: usize, pub k: usize, pub router_bias: Option<Symbol>, pub biases: [Option<Symbol>; 3], pub renormalize: bool, pub act: MoeAct, pub score: MoeScore, pub weigh_inputs: bool, pub selection_bias: Option<Symbol>, pub groups: Option<MoeGroups>, pub scale: Option<u64>,
}
Expand description

A recognized Mixture-of-Experts FFN — Let out be moe of x with router wr gate wg up wu down wd choosing K of E. Lifted from the desugared block the SAME way recognize_matmul/recognize_rope lift theirs — purely structural, no markers, no naming conventions: the OPERAND tensors are the indexed reads NOT Let-bound inside the block (the temps are), and the dims fall straight out of the weight index arithmetic (wr[(t-1)·E+e] yields E; wg[((e-1)·dff+(o-1))·d+t] yields d and dff); out is the tensor the weighted accumulation writes.

Fields§

§out: Symbol§x: Symbol§wr: Symbol§wg: Symbol§wu: Symbol§wd: Symbol§d: usize§dff: usize§ne: usize§k: usize§router_bias: Option<Symbol>

The router’s bias, added to each logit before the softmax (router Wr plus Br).

§biases: [Option<Symbol>; 3]

The experts’ gate, up and down biases (gate Wg plus Bg, …), each a row per expert.

§renormalize: bool

The kept experts’ weights are renormalized to sum to one; false (without renormalizing) weighs each by its softmax over every expert.

§act: MoeAct

The experts’ gated activation.

§score: MoeScore

How the experts are scored: the softmax over every logit, or each logit’s own sigmoid.

§weigh_inputs: bool

A kept expert’s weight scales the input it reads, and its output joins the sum unweighted (Llama 4).

§selection_bias: Option<Symbol>

The selection bias (biased by B): each expert chosen by its score plus B[e], weighed by its score alone.

§groups: Option<MoeGroups>

The group limit (within the top G of N groups).

§scale: Option<u64>

The routed scale (scaled by S) as its bits: every kept weight times S, after the renormalization.

Implementations§

Source§

impl MoeSpec

Source

pub fn scale(&self) -> f64

The routed scale, one when the mixture has none.

Source

pub fn weighs_outputs_by_softmax(&self) -> bool

Whether the router is a softmax over every expert weighting the kept experts’ outputs — chosen by their scores alone, among every expert, unscaled: the routing a lowering that knows no other computes.

Source

pub fn sum_can_clamp(&self) -> bool

Whether the renormalizing sum’s clamp at 2⁻¹⁴ can bind: a softmax’s kept weights sum to at least K/E, so only a sigmoid’s — or a softmax over 16,384 experts or more — can fall below it.

Trait Implementations§

Source§

impl Clone for MoeSpec

Source§

fn clone(&self) -> MoeSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MoeSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MoeSpec

Source§

fn eq(&self, other: &MoeSpec) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MoeSpec

Source§

impl StructuralPartialEq for MoeSpec

Auto Trait Implementations§

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<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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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

§

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

§

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