-
Notifications
You must be signed in to change notification settings - Fork 689
[Feature] Support redundant expert for eplb #5918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
17b06bf
b47e7e9
40a336a
947c38d
0dc3858
7617338
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -473,7 +473,7 @@ def load_experts_weight( | |||||||||||||||
| ) | ||||||||||||||||
| ] | ||||||||||||||||
| ep_rank_to_expert_id_list = [i for i in range(self.num_experts)] | ||||||||||||||||
| if self.redundant_table_manger is not None and is_rearrange is True: | ||||||||||||||||
| if self.redundant_table_manger is not None: | ||||||||||||||||
xiaoxiaohehe001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
| ( | ||||||||||||||||
| ep_rank_to_expert_id_list, | ||||||||||||||||
| expert_id_to_ep_rank_array, | ||||||||||||||||
|
|
@@ -487,18 +487,15 @@ def load_experts_weight( | |||||||||||||||
| down_proj_weights = [] | ||||||||||||||||
| if isinstance(state_dict, list): | ||||||||||||||||
| state_dict = dict(state_dict) | ||||||||||||||||
| is_ffn_merged = ( | ||||||||||||||||
| up_gate_proj_expert_weight_key.format(logical_expert_ids[0] if is_rearrange else self.expert_id_offset) | ||||||||||||||||
| in state_dict | ||||||||||||||||
| ) | ||||||||||||||||
| is_ffn_merged = up_gate_proj_expert_weight_key.format(logical_expert_ids[0]) in state_dict | ||||||||||||||||
xiaoxiaohehe001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
| is_ffn_merged = up_gate_proj_expert_weight_key.format(logical_expert_ids[0]) in state_dict | |
| if logical_expert_ids: | |
| first_expert_key = up_gate_proj_expert_weight_key.format(logical_expert_ids[0]) | |
| is_ffn_merged = first_expert_key in state_dict | |
| else: | |
| # No local experts found, fall back to non-merged FFN loading path | |
| is_ffn_merged = False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -249,6 +249,11 @@ def get_expert_ranges(fd_config): | |
|
|
||
| for i in range(fd_config.model_config.moe_layer_start_index, fd_config.model_config.num_hidden_layers): | ||
| for j in get_expert_ranges(fd_config): | ||
xiaoxiaohehe001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Map redundant expert IDs back to actual expert IDs for weight loading | ||
| moe_num_experts = fd_config.model_config.moe_num_experts | ||
| if isinstance(moe_num_experts, list): | ||
| moe_num_experts = moe_num_experts[0] | ||
| j = j % moe_num_experts | ||
xiaoxiaohehe001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| up_gate_proj_key = f"ernie.{prefix_layer_name}.{i}.mlp.experts.{j}.up_gate_proj.weight" | ||
| down_proj_key = f"ernie.{prefix_layer_name}.{i}.mlp.experts.{j}.down_proj.weight" | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.