@@ -70,7 +70,11 @@ def transform_logic(path: Tuple[str, ...]) -> Optional[mdn]:
7070 """
7171
7272 # 1 Exclude parameters not suitable for Muon (scalar, embeddings, unembedding)
73- if _is_path_contain_any (("scale" , "bias" , "embedding" , "logits_dense" ), path ):
73+ if any (
74+ any (x in segment for x in ("scale" , "embedding" , "logits_dense" , "beta" , "base" , "sinks" , "tid2eid" , "inv_freq" ))
75+ or segment == "bias"
76+ for segment in path
77+ ):
7478 return None
7579
7680 # 2 Special weights
@@ -86,9 +90,12 @@ def transform_logic(path: Tuple[str, ...]) -> Optional[mdn]:
8690 # Attention output projection: [0, L, -2, -1]
8791 if "out" in path :
8892 return mdn ((0 , - 2 ), (- 1 ,))
93+ # Block-diagonal grouped linear layer: [n_groups, L, in_features_per_group, out_features_per_group]
94+ elif "o_a_proj" in path :
95+ return mdn ((- 2 ,), (- 1 ,))
8996 # Attention qkv projection: [0, L, -2, -1]
9097 # MLA, exclude wq_a / wkv_a
91- elif _is_path_contain_any (("query" , "key" , "value" , "wq_b" , "wkv_b" ), path ):
98+ elif _is_path_contain_any (("query" , "key" , "value" , "wq_b" , "wkv_b" , "wkv" ), path ):
9299 return mdn ((0 ,), (- 2 , - 1 ))
93100
94101 # 3 Standard weights, [0, L, -1]
@@ -182,7 +189,16 @@ def get_model_mdn(model_name, scan_layers=True, verbose=False, pure_nnx=False):
182189 f"scan_layers={ scan_layers } " ,
183190 "attention=dot_product" ,
184191 f"pure_nnx={ pure_nnx } " ,
192+ "override_model_config=True" ,
193+ "skip_jax_distributed_system=True" ,
185194 ]
195+ if not pure_nnx :
196+ argv .extend (
197+ [
198+ "enable_nnx=False" ,
199+ "pure_nnx_decoder=False" ,
200+ ]
201+ )
186202 config = pyconfig .initialize (argv )
187203 # Setup model
188204 devices_array = maxtext_utils .create_device_mesh (config )
0 commit comments