@@ -87,9 +87,9 @@ def test_rmsnorm_weight_conversion(self) -> None:
8787 hf_state_dict [f"model.layers.{ i } .input_layernorm.weight" ] = torch .zeros (
8888 config .model_dim
8989 )
90- hf_state_dict [
91- f"model.layers. { i } .post_attention_layernorm.weight"
92- ] = torch . zeros ( config . model_dim )
90+ hf_state_dict [f"model.layers. { i } .post_attention_layernorm.weight" ] = (
91+ torch . zeros ( config . model_dim )
92+ )
9393 hf_state_dict ["model.norm.weight" ] = torch .zeros (config .model_dim )
9494 hf_state_dict ["model.embed_tokens.weight" ] = torch .zeros (
9595 config .vocab_size , config .model_dim
@@ -112,9 +112,7 @@ def test_gdn_norm_weight_not_converted(self) -> None:
112112 config = self ._make_small_config ()
113113
114114 # Simulate HF state dict with GDN norm weight
115- hf_state_dict : dict [str , object ] = {
116- "model.embed_tokens.weight" : torch .zeros (1 )
117- }
115+ hf_state_dict : dict [str , object ] = {"model.embed_tokens.weight" : torch .zeros (1 )}
118116 hf_state_dict ["model.layers.0.linear_attn.norm.weight" ] = (
119117 torch .ones (config .linear_value_head_dim ) * 0.5
120118 )
@@ -264,7 +262,13 @@ def test_rmsnorm_weight_reversed(self) -> None:
264262
265263 # HF weights should be 0.0 (1.0 - 1.0)
266264 for key in hg_state_dict :
267- if key .endswith (("input_layernorm.weight" , "post_attention_layernorm.weight" , "model.norm.weight" )):
265+ if key .endswith (
266+ (
267+ "input_layernorm.weight" ,
268+ "post_attention_layernorm.weight" ,
269+ "model.norm.weight" ,
270+ )
271+ ):
268272 weight = hg_state_dict [key ]
269273 assert isinstance (weight , torch .Tensor )
270274 assert_close (weight , torch .zeros_like (weight ))
@@ -341,7 +345,10 @@ def test_to_hg_config(self) -> None:
341345 assert data ["num_experts" ] == config .num_experts
342346 assert data ["num_experts_per_tok" ] == config .num_experts_per_tok
343347 assert data ["moe_intermediate_size" ] == config .moe_intermediate_size
344- assert data ["shared_expert_intermediate_size" ] == config .shared_expert_intermediate_size
348+ assert (
349+ data ["shared_expert_intermediate_size" ]
350+ == config .shared_expert_intermediate_size
351+ )
345352 assert data ["router_aux_loss_coef" ] == config .router_aux_loss_coef
346353
347354 def test_state_dict_round_trip (self ) -> None :
@@ -441,9 +448,9 @@ def test_visual_and_mtp_keys_filtered(self) -> None:
441448 }
442449 result = convert_qwen35_state_dict (dict (state_dict ), config )
443450 for key in result :
444- assert not key .startswith (( "model.visual." , "mtp." )), (
445- f"Unexpected key not filtered: { key } "
446- )
451+ assert not key .startswith (
452+ ( "model.visual." , "mtp." )
453+ ), f"Unexpected key not filtered: { key } "
447454
448455 def test_text_only_format_still_works (self ) -> None :
449456 """model.layers.* (text-only format) is still handled correctly."""
@@ -475,7 +482,7 @@ def test_end_to_end_vl_checkpoint(self) -> None:
475482 vl_state_dict : dict [str , object ] = {}
476483 for k , v in hg_state_dict .items ():
477484 if k .startswith ("model." ):
478- vl_state_dict ["model.language_model." + k [len ("model." ):]] = v
485+ vl_state_dict ["model.language_model." + k [len ("model." ) :]] = v
479486 else :
480487 vl_state_dict [k ] = v
481488 # Add visual/mtp keys
0 commit comments