[Diffusion][Feature] Non-Intrusive Sequence Parallelism (SP) Support for Wan2.2 (#966)

Signed-off-by: mxuax <mxuax@connect.ust.hk>
Signed-off-by: XU Mingshi <91017482+mxuax@users.noreply.github.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
XU MingshiandHongsheng Liu authored and GitHub committed 2026-01-27 11:33:38 +08:00
1 parent 5037af1033
commit 1fe8e71433
4 files changed
+97 -4

No files matched your search

+12 -3
View File
@@ -164,7 +164,10 @@ def _apply_sequence_parallel_if_enabled(model, od_config: OmniDiffusionConfig) -
return
# Find transformer model(s) in the pipeline that have _sp_plan
transformer_attrs = ["transformer", "dit", "unet"]
# Include transformer_2 for two-stage models (e.g., Wan MoE)
transformer_attrs = ["transformer", "transformer_2", "dit", "unet"]
applied_count = 0
for attr in transformer_attrs:
if not hasattr(model, attr):
continue
@@ -190,11 +193,17 @@ def _apply_sequence_parallel_if_enabled(model, od_config: OmniDiffusionConfig) -
else ("ulysses" if sp_config.ulysses_degree > 1 else "ring")
)
logger.info(
f"Applying sequence parallelism to {transformer.__class__.__name__} "
f"Applying sequence parallelism to {transformer.__class__.__name__} ({attr}) "
f"(sp_size={sp_size}, mode={mode}, ulysses={sp_config.ulysses_degree}, ring={sp_config.ring_degree})"
)
apply_sequence_parallel(transformer, sp_config, plan)
return # Only apply to first transformer found
applied_count += 1
if applied_count == 0:
logger.warning(
f"Sequence parallelism is enabled (sp_size={sp_size}) but no transformer with _sp_plan found. "
"SP hooks not applied. Consider adding _sp_plan to your transformer model."
)
except Exception as e:
logger.warning(f"Failed to apply sequence parallelism: {e}. Continuing without SP hooks.")