Skip to main content

MoeMetadata

Struct MoeMetadata 

Source
pub struct MoeMetadata {
    pub num_experts: u32,
    pub experts_per_token: u8,
    pub shared_experts: u32,
    pub params_per_expert_x10: Option<u32>,
    pub routing_strategy: MoeRoutingStrategy,
    pub load_balance_coef_x10000: Option<u32>,
    pub attention_type: Option<String>,
    pub expert_specialization: Option<Vec<String>>,
    pub capacity_factor_x100: Option<u32>,
}
Expand description

Mixture-of-Experts routing metadata for MoE architectures.

Captures the parameters an inference router needs to reason about per-token cost, expert utilization, and specialization-aware dispatch. Designed to cover Mixtral 8x7B / 8x22B, DeepSeek-V2 / V3 (shared + routed experts), Qwen2-MoE, and recurrent-depth MoE stacks such as OpenMythos.

Fields§

§num_experts: u32

Total number of routed experts in the model (e.g., 8 for Mixtral 8x7B, 64 for Qwen2-MoE).

§experts_per_token: u8

Number of experts activated per token (top-k routing). Typical values: 2 for Mixtral, 6 for DeepSeek-V2, 8 for Qwen2-MoE.

§shared_experts: u32

Shared (“always-on”) experts that process every token alongside the routed experts. Used by DeepSeekMoE-style architectures; zero for Mixtral-style models.

§params_per_expert_x10: Option<u32>

Parameters per expert (in billions, scaled x10 for fixed-point — e.g., 70 = 7.0B). None when unknown.

§routing_strategy: MoeRoutingStrategy

Routing strategy used by the gating network.

§load_balance_coef_x10000: Option<u32>

Auxiliary load-balancing loss coefficient (x10000 fixed point). Helps schedulers estimate how evenly load spreads across experts. None when unknown.

§attention_type: Option<String>

Attention mechanism variant (e.g., “mla” for Multi-head Latent Attention, “mha”, “mqa”, “gqa”).

§expert_specialization: Option<Vec<String>>

Optional per-expert specialization labels (ordered by expert index). E.g., ["math", "code", "reasoning", ...]. Routers can use these to bias toward specialized experts for known task categories.

§capacity_factor_x100: Option<u32>

Expert capacity factor (x100 fixed point — e.g., 125 = 1.25). Drives per-expert token budget: capacity = ceil(tokens * top_k * capacity_factor / num_experts). None defaults to 1.0.

Implementations§

Source§

impl MoeMetadata

Source

pub fn new( num_experts: u32, experts_per_token: u8, routing_strategy: MoeRoutingStrategy, ) -> Self

Construct a minimal MoE metadata block from the required fields.

Source

pub fn with_shared_experts(self, shared: u32) -> Self

Declare shared (“always-on”) experts.

Source

pub fn with_params_per_expert_x10(self, params_x10: u32) -> Self

Declare parameters-per-expert in billions (scaled x10).

Source

pub fn with_attention_type(self, attn: impl Into<String>) -> Self

Declare the attention variant (e.g., “mla”, “gqa”).

Source

pub fn with_expert_specialization(self, labels: Vec<String>) -> Self

Attach a per-expert specialization label list.

Source

pub fn with_capacity_factor_x100(self, cf_x100: u32) -> Self

Declare the expert capacity factor as a x100 fixed-point value.

Source

pub fn active_experts_per_token(&self) -> u32

Total activated experts per token (routed top-k + shared).

Source

pub fn total_routed_params_x10(&self) -> Option<u64>

Total parameters across all routed experts, in billions scaled x10. Returns None if params_per_expert_x10 is unset.

Source

pub fn active_params_per_token_x10(&self) -> Option<u64>

Active parameters per token, in billions scaled x10. Useful for cost/latency estimation since MoE inference only pays for activated experts, not the total parameter count.

Trait Implementations§

Source§

impl Clone for MoeMetadata

Source§

fn clone(&self) -> MoeMetadata

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 Debug for MoeMetadata

Source§

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

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

impl<'de> Deserialize<'de> for MoeMetadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for MoeMetadata

Source§

impl PartialEq for MoeMetadata

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for MoeMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MoeMetadata

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.