Conversation
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
|
This feature is still experimental. The next steps are:
We welcome help testing and validating this on large-scale models. |
|
@tohtana I wish I could be of help, but I haven't written code on this level; if you could clarify on what you mean by a preset for gpt-oss, or if there are other first-issues kind of work I could help with, I would gladly look into it |
|
Hi @jiosephlee, |
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
|
Hi @tohtana, I noticed this PR is in draft now. |
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com> (cherry picked from commit cc45af3)
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
|
Hi @nathon-lee,
I've been using Mixtral for verification but haven't checked other models enough. If you can try and share the feedback, it would be super helpful. Reducing the number of layers would be fine. |
|
ok, @tohtana
|
This PR adds AutoEP (Automatic Expert Parallelism) to DeepSpeed training for HuggingFace MoE models.
AutoEP detects MoE blocks during
deepspeed.initialize(), builds the required EP/EDP process groups, and replaces supported MoE blocks with an EP-enabled execution path, so expert parallelism can be enabled with DeepSpeed config only and without model code changes.Current scope in this PR is the base AutoEP feature:
ZeRO-3 extensions are intentionally left as follow-up work (#7928 should be merged for this work)
Supported presets in this PR:
For end-to-end benchmarking and testing, an AutoEP example is available in DeepSpeedExamples:
Attribution
This implementation substantially builds on TorchTitan's MoE / expert-parallel implementation, and we want to explicitly acknowledge that prior work.
The TorchTitan-derived pieces in this PR are primarily:
deepspeed/moe/ep_router.py: adapted from TorchTitan'sTokenChoiceTopKRouterdeepspeed/moe/ep_experts.py: adapted from TorchTitan'sGroupedExpertsand grouped-GEMM expert execution pathdeepspeed/moe/ep_kernels.py: adapted from TorchTitan'sTokenReorderer,generate_permute_indices, Triton fill-indices kernel, and token-group alignment / padding helpersdeepspeed/module_inject/auto_ep_layer.py: adapts the same router -> reorder -> dispatch -> local expert compute -> combine structure used in TorchTitan's MoE / EP flowRelevant TorchTitan sources:
The DeepSpeed-specific work in this PR is the AutoEP integration layer around those building blocks:
Design
The implementation is split into a few layers:
deepspeed/module_inject/auto_ep_config.pydeepspeed/module_inject/auto_ep.pyMoELayerSpecfor each supported MoE layerAutoEPMoELayerdeepspeed/module_inject/auto_ep_layer.pydeepspeed/moe/ep_router.py,deepspeed/moe/ep_experts.py,deepspeed/moe/ep_kernels.pydeepspeed/moe/ep_repack.pydeepspeed/runtime/engine.pyand checkpoint conversion codedeepspeed.initialize()At runtime, the execution path is:
autoep_size > 1Adding new model support
There are two supported ways to extend AutoEP to a new MoE model family.
PRESET_MODELS.This is the preferred path for a model family we want to support out of the box. A preset defines:
num_expertsandtop_kconfig attributesFor models that are not yet built into DeepSpeed, AutoEP can be driven from config with:
moe_layer_patternrouter_patternexpert_patternexpert_w1,expert_w2,expert_w3num_experts_attrtop_k_attrOnce detection can produce a valid
MoELayerSpec, the replacement, execution, and checkpoint paths are shared.