@@ -467,13 +467,18 @@ def load_experts_weight(
467467 """
468468 logical_expert_ids = [
469469 i
470+ % (
471+ self .fd_config .model_config .moe_num_experts [0 ]
472+ if isinstance (self .fd_config .model_config .moe_num_experts , list )
473+ else self .fd_config .model_config .moe_num_experts
474+ )
470475 for i in range (
471476 self .expert_id_offset ,
472477 self .expert_id_offset + self .num_local_experts ,
473478 )
474479 ]
475480 ep_rank_to_expert_id_list = [i for i in range (self .num_experts )]
476- if self .redundant_table_manger is not None and is_rearrange is True :
481+ if self .redundant_table_manger is not None :
477482 (
478483 ep_rank_to_expert_id_list ,
479484 expert_id_to_ep_rank_array ,
@@ -487,18 +492,15 @@ def load_experts_weight(
487492 down_proj_weights = []
488493 if isinstance (state_dict , list ):
489494 state_dict = dict (state_dict )
490- is_ffn_merged = (
491- up_gate_proj_expert_weight_key .format (logical_expert_ids [0 ] if is_rearrange else self .expert_id_offset )
492- in state_dict
493- )
495+ is_ffn_merged = up_gate_proj_expert_weight_key .format (logical_expert_ids [0 ]) in state_dict
494496 if is_ffn_merged :
495497 for expert_idx in logical_expert_ids :
496498 down_proj_expert_weight_key_name = down_proj_expert_weight_key .format (expert_idx )
497499 up_gate_proj_expert_weight_key_name = up_gate_proj_expert_weight_key .format (expert_idx )
498500 up_gate_proj_weights .append (
499501 get_tensor (
500502 (
501- state_dict . pop ( up_gate_proj_expert_weight_key_name )
503+ state_dict [ up_gate_proj_expert_weight_key_name ]
502504 if up_gate_proj_expert_weight_key_name in state_dict
503505 else up_gate_proj_expert_weight_key_name
504506 ),
@@ -508,7 +510,7 @@ def load_experts_weight(
508510 down_proj_weights .append (
509511 get_tensor (
510512 (
511- state_dict . pop ( down_proj_expert_weight_key_name )
513+ state_dict [ down_proj_expert_weight_key_name ]
512514 if down_proj_expert_weight_key_name in state_dict
513515 else down_proj_expert_weight_key_name
514516 ),
0 commit comments