1717
1818import torch
1919import torch .nn .functional as F
20+ from huggingface_hub .dataclasses import strict
2021from torch import nn
2122
2223from ... import initialization as init
5152from ..qwen2_moe .modeling_qwen2_moe import Qwen2MoeMLP
5253
5354
55+ @auto_docstring (checkpoint = "mistralai/Mistral-Large-4-1T-A52B" )
56+ @strict
5457class MistralLarge4TextConfig (GlmMoeDsaConfig ):
5558 r"""
5659 n_group (`int`, *optional*, defaults to 1):
@@ -73,9 +76,6 @@ class MistralLarge4TextConfig(GlmMoeDsaConfig):
7376 List with at least the same length as the number of layers in the model.
7477 A `1` at an index position indicates that the corresponding layer will use RoPE,
7578 while a `0` indicates that it's a NoPE layer.
76- no_rope_layer_interval (`int`, *optional*, defaults to 4):
77- Every `no_rope_layer_interval`-th layer is a NoPE layer (no rotary embedding in the attention nor in the
78- indexer). The other layers use RoPE.
7979 kv_source_layers (`list[int]`, *optional*):
8080 For each layer, the index of the layer whose latent KV cache it attends to. A layer whose entry is its own
8181 index computes and caches its own latent KV; a layer pointing at an earlier layer has no `kv_a_proj_with_mqa`
@@ -134,7 +134,6 @@ class MistralLarge4TextConfig(GlmMoeDsaConfig):
134134 index_n_heads : int = 32
135135 first_k_dense_replace : int = 1
136136 no_rope_layers : list [int ] | None = None
137- no_rope_layer_interval : int = 4
138137 kv_source_layers : list [int ] | None = None
139138 final_logit_softcapping : float = 30.0
140139
@@ -156,8 +155,9 @@ def __post_init__(self, **kwargs):
156155 }
157156 # NoPE every `no_rope_layer_interval`-th layer (smollm3 convention: 1 == uses RoPE)
158157 if self .no_rope_layers is None :
158+ no_rope_layer_interval = kwargs .pop ("no_rope_layer_interval" , 4 )
159159 self .no_rope_layers = [
160- int ((layer_idx + 1 ) % self . no_rope_layer_interval != 0 ) for layer_idx in range (self .num_hidden_layers )
160+ int ((layer_idx + 1 ) % no_rope_layer_interval != 0 ) for layer_idx in range (self .num_hidden_layers )
161161 ]
162162 # KV sharing: by default every layer owns its latent KV cache
163163 if self .kv_source_layers is None :
@@ -194,6 +194,8 @@ def kv_sharing_modes(self) -> list[str | None]:
194194 return kv_sharing_modes
195195
196196
197+ @auto_docstring (checkpoint = "mistralai/Mistral-Large-4-1T-A52B" )
198+ @strict
197199class MistralLarge4Config (Mistral3Config ):
198200 model_type = "mistral_large4"
199201 sub_configs_defaults = {
0 commit comments