MoE RMSNorm
×Rescale each position’s features using their root mean square, then apply learned gain.
- in
- [B batch, 1 position, 6144 d]
- out
- [B batch, 1 position, 6144 d]
Computed in float32; the weight multiplies after the cast back (modeling_mimo_v2.py 112–117).
Parameters6,144 × 9 layers
6,144 parameters per instance.
| Component | Parameters |
|---|---|
| Learned gain | 6,144 |
One in each of the 9 global layers, each with its own weights.
Sources
In codeself.post_attention_layernorm(hidden_states) · 439
Direct evidence
The model’s RMSNorm: a weight initialised to ones, the input normalised by its root mean square plus ε in float32, then multiplied by the weight.
modeling_mimo_v2.py 106–117 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
class MiMoV2RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
def forward(self, hidden_states):
input_dtype = hidden_states.dtype
hidden_states = hidden_states.to(torch.float32)
variance = hidden_states.pow(2).mean(-1, keepdim=True)
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
return self.weight * hidden_states.to(input_dtype)
A layer is pre-norm: attention reads the normalised input and its output is added to the residual; the feed-forward reads the normalised sum and its output is added again.
modeling_mimo_v2.py 413–442 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[Cache] = None,
use_cache: Optional[bool] = False,
cache_position: Optional[torch.LongTensor] = None,
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None,
**kwargs: Unpack[TransformersKwargs],
) -> torch.Tensor:
residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
hidden_states, _ = self.self_attn(
hidden_states=hidden_states,
attention_mask=attention_mask,
position_ids=position_ids,
past_key_values=past_key_values,
use_cache=use_cache,
cache_position=cache_position,
position_embeddings=position_embeddings,
**kwargs,
)
hidden_states = residual + hidden_states
residual = hidden_states
hidden_states = self.post_attention_layernorm(hidden_states)
hidden_states = self.mlp(hidden_states)
hidden_states = residual + hidden_states
return hidden_states