feat(wan): SP communication-computation overlap for Wan2.2 I2V.#1945
Open
nie-linfeng wants to merge 1 commit into
Open
feat(wan): SP communication-computation overlap for Wan2.2 I2V.#1945nie-linfeng wants to merge 1 commit into
nie-linfeng wants to merge 1 commit into
Conversation
Self-attn: Q/K/V async all2all overlapped with norm+RoPE - Q/K all2all overlapped with each other (async) - V all2all overlapped with Q/K norm+RoPE - O all2all async, handler returned for caller to wait Cross-attn: Q all2all overlapped with K/V matmul - Q all2all async, K/V matmul (text+img) computed in parallel - Removed precompute_cross_kv/forward_cross_with_kv (simpler design) Block forward: simplified, no precompute logic
19b5964 to
4c86830
Compare
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.
背景
Wan2.2 I2V 模型在 SP (Sequence Parallel) 模式下,attention 层的 all2all 通信与计算串行执行,导致通信开销无法被掩盖。
优化方案
通过 async all2all 将通信与计算 overlap,分两个层面优化:
1. Self-Attention (forward_async)
基线流程(串行):
CMO 流程(async overlap):
关键点:
2. Cross-Attention (forward_cross)
基线流程(串行):
CMO 流程(async overlap):
关键点:
3. 配置改动
改动文件
性能数据
测试条件: 8 dieNPU, tp1, sp4, vae_size 4 ;40 steps
Profiling
优化后:


self-attn之前qkv的all-to-all
cross-attn之前q的all-to-all