Select experts
×Keep the top 8 of 384 experts, ranked with a selection bias.
- in
- [B batch, T positions, 384 experts]
- out
- [B batch, T positions, 384 experts]
Parameters384 × 9 layers
384 parameters owned by this component
| Component | Parameters |
|---|---|
| learned vector | 384 |
One in each of the 9 global layers, each with its own weights.
One float32 value per expert, e_score_correction_bias (modeling_mimo_v2.py 149–150).
Explanation
The configuration sets 1 expert group (n_group, topk_group), so the group stage keeps all 384 experts (modeling_mimo_v2.py 165–174).
The bias (384 values) is added only when choosing experts; the weights use the unbiased affinities (modeling_mimo_v2.py 164, 176).
Sources
In codescores_for_choice = scores + self.e_score_correction_bias; torch.topk(…, k=self.top_k) · 164–175
Direct evidence
The router owns a weight of experts × width and, for noaux_tc, a per-expert e_score_correction_bias; the route scale defaults to 1.0.
modeling_mimo_v2.py 135–150 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
class MiMoV2MoEGate(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.top_k = config.num_experts_per_tok
self.n_routed_experts = config.n_routed_experts
self.routed_scaling_factor = config.routed_scaling_factor if config.routed_scaling_factor is not None else 1.0
self.scoring_func = config.scoring_func
self.topk_method = config.topk_method
self.n_group = config.n_group
self.topk_group = config.topk_group
self.norm_topk_prob = config.norm_topk_prob
self.gating_dim = config.hidden_size
self.weight = nn.Parameter(torch.empty((self.n_routed_experts, self.gating_dim)))
if self.topk_method == "noaux_tc":
self.e_score_correction_bias = nn.Parameter(torch.empty((self.n_routed_experts)))
The router scores every expert in float32 and applies the sigmoid; the bias is added for the choice only: groups ranked by their two best biased scores (one group here), the top 8 experts taken, their unbiased scores gathered, divided by their sum plus 10⁻²⁰ and multiplied by the route scale.
modeling_mimo_v2.py 152–184 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
def forward(self, hidden_states):
bsz, seq_len, h = hidden_states.shape
hidden_states = hidden_states.view(-1, h)
logits = F.linear(hidden_states.type(torch.float32), self.weight.type(torch.float32), None)
if self.scoring_func == "sigmoid":
scores = logits.sigmoid()
else:
raise NotImplementedError(f"Unsupported scoring function for MoE gating: {self.scoring_func}")
if self.topk_method == "noaux_tc":
if self.training:
raise ValueError("MiMoV2 noaux_tc routing is only implemented for inference.")
scores_for_choice = scores.view(bsz * seq_len, -1) + self.e_score_correction_bias.unsqueeze(0)
group_scores = scores_for_choice.view(bsz * seq_len, self.n_group, -1).topk(2, dim=-1)[0].sum(dim=-1)
group_idx = torch.topk(group_scores, k=self.topk_group, dim=-1, sorted=False)[1]
group_mask = torch.zeros_like(group_scores)
group_mask.scatter_(1, group_idx, 1)
score_mask = (
group_mask.unsqueeze(-1)
.expand(bsz * seq_len, self.n_group, self.n_routed_experts // self.n_group)
.reshape(bsz * seq_len, -1)
)
tmp_scores = scores_for_choice.masked_fill(~score_mask.bool(), float("-inf"))
_, topk_idx = torch.topk(tmp_scores, k=self.top_k, dim=-1, sorted=False)
topk_weight = scores.gather(1, topk_idx)
else:
raise NotImplementedError(f"Unsupported TopK function for MoE gating: {self.topk_method}")
if self.top_k > 1 and self.norm_topk_prob:
denominator = topk_weight.sum(dim=-1, keepdim=True) + 1e-20
topk_weight = topk_weight / denominator
topk_weight = topk_weight * self.routed_scaling_factor
return topk_idx, topk_weight
The released configuration: 70 layers of width 6,144; hybrid_layer_pattern marks 60 sliding-window layers (1) and 10 global ones (0, at 0-based layers 0, 7, 15, 23, 31, 39, 47, 55, 62 and 69); moe_layer_freq is 0 at layer 0 only; 128 query and 8 key–value heads in both kinds, 192 query–key and 128 value features a head; a sliding window of 128 with a sink bias in the window layers only; attention_value_scale 0.612; partial_rotary_factor 0.334 with θ 10,000,000 (global) and 10,000 (window); 384 experts of 2,048, 8 used, sigmoid scores, noaux_tc with one group, no shared expert; a dense MLP of 16,384; RMSNorm ε 10⁻⁵; vocabulary 152,576; untied head; 1,048,576 positions.
config.json 1–441 ↗ · XiaomiMiMo/MiMo-V2.6-Pro-RL @ b61f21852680
Excerpt
{
"add_full_attention_sink_bias": false,
"add_swa_attention_sink_bias": true,
"architectures": [
"MiMoV2ForCausalLM"
],
"attention_bias": false,
"attention_chunk_size": 128,
"attention_dropout": 0.0,
"attention_projection_layout": "fused_qkv",
"attention_value_scale": 0.612,
"audio_config": {
"add_post_norm": true,
"audio_channels": 20,
"audio_segment_size": 6000,
"group_size": 4,
"input_full_attention": true,
"input_local_attn_heads": 16,
"input_local_dim": 1024,
"input_local_head_dim": 64,
"input_local_hidden_dropout": 0.0,
"input_local_intermediate_size": 4096,
"input_local_layers": 6,
"out_hidden_size": 6144,
"partial_rotary_factor": 1.0,
"projection_layers": 2,
"rope_theta": 640000,
"speech_vocab_size": "1280",
"speech_zeroemb_idx": "1024"
},
"audio_end_token_id": 151674,
"audio_start_token_id": 151673,
"audio_token_id": 151669,
"auto_map": {
"AutoConfig": "configuration_mimo_v2.MiMoV2Config",
"AutoModel": "modeling_mimo_v2.MiMoV2Model",
"AutoModelForCausalLM": "modeling_mimo_v2.MiMoV2ForCausalLM"
},
"moe_router_dtype": "bfloat16",
"bos_token_id": null,
"dtype": "bfloat16",
"eos_token_id": 151645,
"head_dim": 192,
"hidden_act": "silu",
"hidden_size": 6144,
"hybrid_block_size": null,
"hybrid_layer_pattern": [
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0
],
"image_token_id": 151655,
"initializer_range": 0.02,
"intermediate_size": 16384,
"layernorm_epsilon": 1e-05,
"max_position_embeddings": 1048576,
"model_type": "mimo_v2",
"moe_intermediate_size": 2048,
"moe_layer_freq": [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"n_group": 1,
"n_routed_experts": 384,
"n_shared_experts": null,
"norm_topk_prob": true,
"num_attention_heads": 128,
"num_experts_per_tok": 8,
"num_hidden_layers": 70,
"num_key_value_heads": 8,
"pad_token_id": 151643,
"partial_rotary_factor": 0.334,
"processor_config": {
"audio_avg_pooler": 2,
"audio_channels": 20,
"audio_end_token_id": 151674,
"audio_fmax": null,
"audio_fmin": 0,
"audio_group_size": 4,
"audio_hop_length": 240,
"audio_input_id_per_second": 25.0,
"audio_kernel_size": 3,
"audio_n_mels": 128,
"audio_nfft": 960,
"audio_sampling_rate": 24000,
"audio_segment_size": 6000,
"audio_start_token_id": 151673,
"audio_stride_size": 2,
"audio_token_id": 151669,
"audio_window_size": 960,
"audio_zeroemb_idx": [
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024,
1024
],
"fps": 1.0,
"image_max_pixels": 8388608,
"image_min_pixels": 8192,
"image_token_id": 151655,
"max_frames": 3600,
"merge_size": 2,
"min_frames": null,
"num_frames": null,
"pad_token_id": 151643,
"patch_size": 16,
"rope_type": "rope",
"temporal_compression_ratio": 1,
"temporal_patch_size": 2,
"use_per_grid_t_timestamps": false,
"use_video_timestamps": true,
"video_audio_interleave_length": 0.0,
"video_end_token_id": 151671,
"video_max_pixels": 8388608,
"video_min_pixels": 8192,
"video_process_num_threads": 16,
"video_start_token_id": 151670,
"video_token_id": 151656,
"video_tokens_per_second": 2,
"video_total_max_pixels": 268435456,
"vision_end_token_id": 151653,
"vision_start_token_id": 151652
},
"quantization_config": {
"activation_scheme": "dynamic",
"fmt": "e4m3",
"ignored_layers": [
"model.layers.0.self_attn.o_proj",
"model.layers.1.self_attn.o_proj",
"model.layers.10.self_attn.o_proj",
"model.layers.11.self_attn.o_proj",
"model.layers.12.self_attn.o_proj",
"model.layers.13.self_attn.o_proj",
"model.layers.14.self_attn.o_proj",
"model.layers.15.self_attn.o_proj",
"model.layers.16.self_attn.o_proj",
"model.layers.17.self_attn.o_proj",
"model.layers.18.self_attn.o_proj",
"model.layers.19.self_attn.o_proj",
"model.layers.2.self_attn.o_proj",
"model.layers.20.self_attn.o_proj",
"model.layers.21.self_attn.o_proj",
"model.layers.22.self_attn.o_proj",
"model.layers.23.self_attn.o_proj",
"model.layers.24.self_attn.o_proj",
"model.layers.25.self_attn.o_proj",
"model.layers.26.self_attn.o_proj",
"model.layers.27.self_attn.o_proj",
"model.layers.28.self_attn.o_proj",
"model.layers.29.self_attn.o_proj",
"model.layers.3.self_attn.o_proj",
"model.layers.30.self_attn.o_proj",
"model.layers.31.self_attn.o_proj",
"model.layers.32.self_attn.o_proj",
"model.layers.33.self_attn.o_proj",
"model.layers.34.self_attn.o_proj",
"model.layers.35.self_attn.o_proj",
"model.layers.36.self_attn.o_proj",
"model.layers.37.self_attn.o_proj",
"model.layers.38.self_attn.o_proj",
"model.layers.39.self_attn.o_proj",
"model.layers.4.self_attn.o_proj",
"model.layers.40.self_attn.o_proj",
"model.layers.41.self_attn.o_proj",
"model.layers.42.self_attn.o_proj",
"model.layers.43.self_attn.o_proj",
"model.layers.44.self_attn.o_proj",
"model.layers.45.self_attn.o_proj",
"model.layers.46.self_attn.o_proj",
"model.layers.47.self_attn.o_proj",
"model.layers.48.self_attn.o_proj",
"model.layers.49.self_attn.o_proj",
"model.layers.5.self_attn.o_proj",
"model.layers.50.self_attn.o_proj",
"model.layers.51.self_attn.o_proj",
"model.layers.52.self_attn.o_proj",
"model.layers.53.self_attn.o_proj",
"model.layers.54.self_attn.o_proj",
"model.layers.55.self_attn.o_proj",
"model.layers.56.self_attn.o_proj",
"model.layers.57.self_attn.o_proj",
"model.layers.58.self_attn.o_proj",
"model.layers.59.self_attn.o_proj",
"model.layers.6.self_attn.o_proj",
"model.layers.60.self_attn.o_proj",
"model.layers.61.self_attn.o_proj",
"model.layers.62.self_attn.o_proj",
"model.layers.63.self_attn.o_proj",
"model.layers.64.self_attn.o_proj",
"model.layers.65.self_attn.o_proj",
"model.layers.66.self_attn.o_proj",
"model.layers.67.self_attn.o_proj",
"model.layers.68.self_attn.o_proj",
"model.layers.69.self_attn.o_proj",
"model.layers.7.self_attn.o_proj",
"model.layers.8.self_attn.o_proj",
"model.layers.9.self_attn.o_proj",
"model.decoder.self_attn.o_proj"
],
"mxfp4_block_size": 32,
"quant_method": "fp8",
"store_dtype": "mxfp4",
"weight_block_size": [
128,
128
]
},
"rope_parameters": {
"partial_rotary_factor": 0.334,
"rope_theta": 10000000,
"rope_type": "default",
"type": "default"
},
"rope_theta": 10000000,
"routed_scaling_factor": null,
"scoring_func": "sigmoid",
"sliding_window": 128,
"sliding_window_size": 128,
"swa_head_dim": 192,
"swa_num_attention_heads": 128,
"swa_num_key_value_heads": 8,
"swa_rope_theta": 10000,
"swa_v_head_dim": 128,
"tie_word_embeddings": false,
"topk_group": 1,
"topk_method": "noaux_tc",
"transformers_version": "5.3.0",
"use_cache": true,
"v_head_dim": 128,
"video_token_id": 151656,
"vision_config": {
"depth": 28,
"fullatt_block_indexes": [
0,
9,
18,
27
],
"hidden_act": "silu",
"hidden_size": 1280,
"in_chans": 3,
"intermediate_size": 4608,
"num_heads": 32,
"num_key_value_heads": 8,
"num_query_groups": 4,
"out_hidden_size": 6144,
"patch_size": 16,
"spatial_merge_size": 2,
"spatial_patch_size": 16,
"temporal_patch_size": 2,
"tokens_per_second": 2,
"use_sink": true,
"visual_token_window_size": 64,
"vit_window_attn_types": [
-1,
0,
0,
0,
0,
1,
1,
1,
1,
-1,
0,
0,
0,
0,
1,
1,
1,
1,
-1,
0,
0,
0,
0,
1,
1,
1,
1,
-1
],
"window_size": 128
},
"vision_end_token_id": 151653,
"vision_model_type": "mimovl",
"vision_start_token_id": 151652,
"vocab_size": 152576
}