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: boolThe kept experts’ weights are renormalized to sum to one; false (without renormalizing) weighs each by its
softmax over every expert.
act: MoeActThe experts’ gated activation.
score: MoeScoreHow the experts are scored: the softmax over every logit, or each logit’s own sigmoid.
weigh_inputs: boolA 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
impl MoeSpec
Sourcepub fn weighs_outputs_by_softmax(&self) -> bool
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.
Sourcepub fn sum_can_clamp(&self) -> bool
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§
impl Eq for MoeSpec
impl StructuralPartialEq for MoeSpec
Auto Trait Implementations§
impl Freeze for MoeSpec
impl RefUnwindSafe for MoeSpec
impl Send for MoeSpec
impl Sync for MoeSpec
impl Unpin for MoeSpec
impl UnsafeUnpin for MoeSpec
impl UnwindSafe for MoeSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.