Routed expert
×One of 384 independent SwiGLU MLPs of 2,048 hidden features; each position runs only the 8 its router selected.
All 5 steps
- in
- [B batch, 1 position, 6144 d]
- out
- [B batch, 1 position, 6144 d]
Parameters37,748,736 × 3,456 experts
37,748,736 parameters per expert, across its learned components
| Component | Calculation | Parameters |
|---|---|---|
| Gate projection | 6,144 × 2,048 | 12,582,912 |
| Up projection | 6,144 × 2,048 | 12,582,912 |
| Down projection | 2,048 × 6,144 | 12,582,912 |
| Per-instance total | 37,748,736 | |
One of 3,456 independent experts: 384 in each of 9 global layers.
Explanation
The implementation finds the positions routed to each expert, runs the expert on them and adds its weighted output back at those positions (modeling_mimo_v2.py 196–210). The checkpoint stores each expert’s matrices in 4 bits (MXFP4, a scale per 32 values).
Sources
In codeself.experts · MiMoV2MLP
Direct evidence
The MoE block holds 384 SwiGLU experts of moe_intermediate_size and the router; each expert runs on the positions routed to it, its output scaled by the routing weight and added back at those positions; there is no shared expert.
modeling_mimo_v2.py 187–217 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
class MiMoV2MoE(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.experts = nn.ModuleList(
[MiMoV2MLP(config, intermediate_size=config.moe_intermediate_size) for _ in range(config.n_routed_experts)]
)
self.gate = MiMoV2MoEGate(config)
def moe(self, hidden_states: torch.Tensor, topk_indices: torch.Tensor, topk_weights: torch.Tensor):
final_hidden_states = torch.zeros_like(hidden_states, dtype=topk_weights.dtype)
expert_mask = torch.nn.functional.one_hot(topk_indices, num_classes=len(self.experts))
expert_mask = expert_mask.permute(2, 0, 1)
for expert_idx, expert in enumerate(self.experts):
mask = expert_mask[expert_idx]
token_indices, weight_indices = torch.where(mask)
if token_indices.numel() > 0:
expert_weights = topk_weights[token_indices, weight_indices]
expert_input = hidden_states[token_indices]
expert_output = expert(expert_input)
final_hidden_states.index_add_(0, token_indices, expert_output * expert_weights.unsqueeze(-1))
return final_hidden_states.type(hidden_states.dtype)
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
orig_shape = hidden_states.shape
topk_indices, topk_weights = self.gate(hidden_states)
hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
hidden_states = self.moe(hidden_states, topk_indices, topk_weights).view(*orig_shape)
return hidden_states
The MLP and every expert is a SwiGLU: down(act(gate x) · up x), without biases.
modeling_mimo_v2.py 120–132 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
class MiMoV2MLP(nn.Module):
def __init__(self, config, intermediate_size=None):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size if intermediate_size is None else intermediate_size
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
self.act_fn = ACT2FN[config.hidden_act]
def forward(self, hidden_states):
return self.down_proj(self.act_fn(self.gate_proj(hidden_states)) * self.up_proj(hidden_states))