-
Notifications
You must be signed in to change notification settings - Fork 93
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
How to create a custom expert with tutel? #226
Comments
You can follow this example: https://github.com/microsoft/tutel/blob/main/tutel/examples/helloworld_demo.py, which can be executed with: |
thanks a lot! |
What if I want to feed another parameter in "class CustomExpertDemo(torch.nn.Module):", how can I revise the code in tutel? |
e.g., def forward(self, x, ctx, anew_param): |
Is that a static parameter that can be set just in |
nope, it is a learnable parameter initialized out of the class "CustomExpertDem". |
Still need a few API upgrades to meet your requirement. |
Thanks, is there an available way to modify it after installing tutel? (e.g., reivising xx.py after installing tutel) |
You need to feed extra argument data you need here: https://github.com/microsoft/tutel/blob/main/tutel/impls/moe_layer.py#L238, You also need to extend corresponding argument list in the forward function to match data you feed: https://github.com/microsoft/tutel/blob/main/tutel/examples/helloworld_demo.py#L101 If you cannot clone and install tutel from source after changes above applied in the source, you have to get the location of installed file maybe at |
Thanks a lot. |
When I use the Customexpert, it stopped here:
|
What is the value of |
Where can I find the "adaptive_r" ? |
I have not changed the value of adaptive_r. I directly replaced the above-mentioned custom MLP with the default FFN and the program is working fine. |
So looks like |
num_global_experts=2, self.world_size=8 |
Yes. When the execution setting |
thanks a lot! |
Please follow this example in handling |
Code:
self._moe_layer = tutel_moe.moe_layer(
gate_type = {'type': 'top', 'k': top_value, 'fp32_gate': args.fp32_gate},
experts = {'type': 'ffn', 'count_per_node': num_local_experts, 'hidden_size_per_expert': hidden_size, 'activation_fn': lambda x: F.relu(x)},
model_dim = model_dim,
scan_expert_func = lambda name, param: setattr(param, 'skip_allreduce', True),
seeds = (1, dist_rank + 1, 1),
a2a_ffn_overlap_degree = a2a_ffn_overlap_degree,
)
How can I define a custom expert, e.g., only one mlp layer?
The text was updated successfully, but these errors were encountered: