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: u32Total number of routed experts in the model (e.g., 8 for Mixtral 8x7B, 64 for Qwen2-MoE).
experts_per_token: u8Number of experts activated per token (top-k routing). Typical values: 2 for Mixtral, 6 for DeepSeek-V2, 8 for Qwen2-MoE.
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: MoeRoutingStrategyRouting 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
impl MoeMetadata
Sourcepub fn new(
num_experts: u32,
experts_per_token: u8,
routing_strategy: MoeRoutingStrategy,
) -> Self
pub fn new( num_experts: u32, experts_per_token: u8, routing_strategy: MoeRoutingStrategy, ) -> Self
Construct a minimal MoE metadata block from the required fields.
Declare shared (“always-on”) experts.
Sourcepub fn with_params_per_expert_x10(self, params_x10: u32) -> Self
pub fn with_params_per_expert_x10(self, params_x10: u32) -> Self
Declare parameters-per-expert in billions (scaled x10).
Sourcepub fn with_attention_type(self, attn: impl Into<String>) -> Self
pub fn with_attention_type(self, attn: impl Into<String>) -> Self
Declare the attention variant (e.g., “mla”, “gqa”).
Sourcepub fn with_expert_specialization(self, labels: Vec<String>) -> Self
pub fn with_expert_specialization(self, labels: Vec<String>) -> Self
Attach a per-expert specialization label list.
Sourcepub fn with_capacity_factor_x100(self, cf_x100: u32) -> Self
pub fn with_capacity_factor_x100(self, cf_x100: u32) -> Self
Declare the expert capacity factor as a x100 fixed-point value.
Sourcepub fn active_experts_per_token(&self) -> u32
pub fn active_experts_per_token(&self) -> u32
Total activated experts per token (routed top-k + shared).
Sourcepub fn total_routed_params_x10(&self) -> Option<u64>
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.
Sourcepub fn active_params_per_token_x10(&self) -> Option<u64>
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
impl Clone for MoeMetadata
Source§fn clone(&self) -> MoeMetadata
fn clone(&self) -> MoeMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MoeMetadata
impl Debug for MoeMetadata
Source§impl<'de> Deserialize<'de> for MoeMetadata
impl<'de> Deserialize<'de> for MoeMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MoeMetadata
Source§impl PartialEq for MoeMetadata
impl PartialEq for MoeMetadata
Source§fn eq(&self, other: &MoeMetadata) -> bool
fn eq(&self, other: &MoeMetadata) -> bool
self and other values to be equal, and is used by ==.