deepspeedai / deepspeedai/DeepSpeed
[REQUEST] Should MoE be parameter groups be partitionable by expert_group_name or expert number?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Is your feature request related to a problem? Please describe.
From what I have noticed when looking at the MoE implementation, the expert_group_name is not configurable:
https://github.com/microsoft/DeepSpeed/blob/6de31de73fdf0a5e0f90c92e10cff4e72e91cf65/deepspeed/moe/layer.py#L58
For one, this means every MoE submodule's parameters gets the same name, something like ep_size_1... which is not very useful from a logging/tracking perspective.
This also means that if there are multiple MoE submodules being split from the same initial parameter optimization group by split_params_into_different_moe_groups_for_optimizer, you can end up with parameters for 2 different MoE submodules intermixed in the same group if you hit the size limit, when they otherwise could have been together if they had each been tracked by a unique expert_group_name.
Additionally, since the expert number is not tracked, you can also have parameters from different experts in the same group, whereas if you kept them separated by expert_number, you could keep parameters from the same expert in the same group.
Based on the answer I received to a question here: What are the benefits to limiting param_group size?, "we split the groups to save memory because only one of these groups will be on the GPU in full precision at a time." Is this right?
My question is: would it benefit us to keep parameter groups more homogenous either to the specific MoE submodule or expert number rather than having them all be intermixed? Would it benefit locality or anything like that to keep the groups more homogenous like I am thinking?
Describe the solution you'd like
class MoE(nn.Module):
"""Initialize an MoE layer.
Arguments:
...
expert_group_name (str, optional): default=None, the name of the expert group.
"""
def __init__(self,
...
expert_group_name: Optional[str] = None) -> None:
self.expert_group_name = expert_group_name or f"ep_size_{self.ep_size}"
class Experts(nn.Module):
def __init__(self, expert: nn.Module, num_local_experts: int = 1, expert_group_name: Optional[str] = None) -> None:
for i, expert in enumerate(self.deepspeed_experts):
for param in expert.parameters():
param.expert_number = i
And then in split_params_into_different_moe_groups_for_optimizer, we can add another layer of dicts for the expert_number so that generated param groups will always contain parameters from the same submodule and expert.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with deepspeed/moe/layer.py and deepspeed/moe/utils.py, especially split_params_into_different_moe_groups_for_optimizer and the linked MoE and Experts definitions. Trace how expert parameters are currently named and partitioned, then determine and document the accepted grouping policy. Done means the project has an agreed behavior for submodule and expert grouping, with validation for the resulting optimizer groups.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100