Repository navigation
[NPU] Fix HunyuanImage3 MoE EP+SP parallel mapping - #4344
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
f4fa3e6 to
10662af
Compare
10662af to
616c695
Compare
|
@hsliuustc0106 PTAL |
Signed-off-by: Celeste-jq <591998922@qq.com>
616c695 to
748f342
Compare
Signed-off-by: Celeste-jq <591998922@qq.com>
Signed-off-by: Celeste-jq <591998922@qq.com>
Signed-off-by: Celeste-jq <591998922@qq.com>
Signed-off-by: Celeste-jq <591998922@qq.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Signed-off-by: Celeste-jq <591998922@qq.com>
| @@ -1633,7 +1575,7 @@ def __init__( | |||
| prefix=f"{prefix}.experts", | |||
| enable_eplb=self.enable_eplb, | |||
| num_redundant_experts=self.n_redundant_experts, | |||
| pcp_size=1, | |||
| pcp_size=None if enable_expert_parallel else 1, | |||
There was a problem hiding this comment.
we need to set pcp_size, dp_size to correct number?
There was a problem hiding this comment.
For EP=true, pcp_size/dp_size are intentionally left as None so vLLM FusedMoE reads them from the already initialized vLLM PCP/DP groups and then computes the MoE EP layout from those sizes.
For EP=false, pcp_size=1 is required to avoid querying an uninitialized PCP group.
Signed-off-by: Celeste-jq <591998922@qq.com>
0e979bc to
32904c9
Compare
Signed-off-by: Celeste-jq <591998922@qq.com>
| @@ -64,6 +68,22 @@ def _init_mc2_group_for_diffusion( | |||
| ) | |||
|
|
|||
|
|
|||
| def _sync_ascend_ep_group_for_diffusion() -> None: | |||
There was a problem hiding this comment.
Here, assigning a value to _EP in vllm_ascend.distributed.parallel_state is meaningless, because Ascend uses _EP from vllm.distributed.parallel_state, and vllm.distributed.parallel_state.EP has already been assigned a value in vllm_omni/diffusion/distributed/parallel_state.py.
There was a problem hiding this comment.
you're right. done.
Signed-off-by: Celeste-jq <591998922@qq.com>
|
@hsliuustc0106 @gcanlin @Isotr0py @princepride @SamitHuang @wtomin @ZJY0516 @RuixiangMa @david6666666 @yenuo26 @jiangmengyu18 @Bounty-hunter |
|
For further assurance, can we add NPU types to the hardware labels of the relevant test cases, or add E2E test cases for the corresponding scenarios, in subsequent PRs? |
Sure, we'll address that in a subsequent PR. This PR is intended to be a general change that works for both GPU and NPU. |
…nto npu-hunyuanimage3-dit-ep-sp-fix
| ) | ||
|
|
||
| _EXPERT_PARALLEL_GROUP_RANKS = None | ||
| if enable_expert_parallel: |
There was a problem hiding this comment.
This dropped the old od_config.is_moe guard. Non-MoE diffusion configs with enable_expert_parallel=True now create vLLM PCP/DP/EP state instead of failing fast, even though this remap should be MoE-only. Please keep the remap gated on both EP and od_config.is_moe, and add a regression test for non-MoE + EP.
Signed-off-by: Celeste-jq <591998922@qq.com>
Signed-off-by: Celeste-jq <591998922@qq.com>
Signed-off-by: Celeste-jq <591998922@qq.com> Signed-off-by: Wojciech Kutak <wkutak@nvidia.com>
Signed-off-by: Celeste-jq <591998922@qq.com>
Summary
Fixes NPU HunyuanImage3 fused MoE runtime failures when expert parallelism is enabled together with diffusion sequence parallelism. #3877. #4438 .
Root cause
HunyuanImage3 is a diffusion MoE model. vllm-omni has its own diffusion parallel dimensions:
vLLM FusedMoE, however, expects MoE expert placement to be expressed through its native dimensions:
Before this patch, the NPU HunyuanImage3 fused MoE path did not consistently map diffusion SP/CFG into vLLM's MoE parallel semantics. This could make local expert placement and token dispatch disagree, causing runtime failures such as:
What this PR changes
This patch keeps the change in vllm-omni and does not modify vLLM or vllm-ascend.
For diffusion MoE models with
enable_expert_parallel=True, vllm-omni maps:So vLLM FusedMoE computes:
The mapping is gated on both:
This avoids changing vLLM PCP/DP semantics for non-MoE models or for MoE models running with expert parallelism disabled.
Implementation details
diffusion_worker.py, set vLLMprefill_context_parallel_sizeand adjusteddata_parallel_sizeonly for MoE + EP.parallel_state.py, expose diffusion_SPas vLLM_PCP, usecfg-dpas vLLM_DPwhen needed, and build vLLM_EPfromtp-sp-cfg-dp.hunyuan_image3_transformer.py, let HunyuanImage3 FusedMoE use vLLM PCP only when EP is enabled; otherwise passpcp_size=1to avoid requiring a PCP group.platforms/npu/models/hunyuan_fused_moe.py, remove the previous effective-TP rewrite and keep only the NPU backend glue needed to sync vllm-ascend EP/MC2 state with vLLM's EP group.Validation
Tested on 8 NPUs with HunyuanImage3 DiT-only offline serving.
TP4 + SP2 + EP enabled
Config highlights:
Expected MoE mapping:
Observed result:
TP4 + SP2 + EP disabled
Config highlights:
Expected behavior:
Observed result:
Scope
The MoE parallel mapping is only enabled for diffusion MoE models when expert parallelism is enabled.
NPU-specific code only synchronizes vllm-ascend's MoE runtime state with the vLLM EP group and MC2 group. It does not redefine a separate NPU-only MoE formula.
GPU/XPU/default paths are not given a separate formula; the goal is to keep MoE TP/PCP/DP/EP semantics aligned across backends.