Draft
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>
Collaborator
Author
|
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 |
Collaborator
Author
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.