Skip to content

feat(npu): Ascend platform, Ulysses SP, long-context attention, and fused DiT ops for v1 - #270

Open
Chitandaaaaa wants to merge 5 commits into
modelscope:v1from
Chitandaaaaa:feat/npu-ulysses4-v1
Open

feat(npu): Ascend platform, Ulysses SP, long-context attention, and fused DiT ops for v1#270
Chitandaaaaa wants to merge 5 commits into
modelscope:v1from
Chitandaaaaa:feat/npu-ulysses4-v1

Conversation

@Chitandaaaaa

@Chitandaaaaa Chitandaaaaa commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Port Ascend NPU support onto the v1 architecture (capability-level migration from fork PR #11 on main; not a cherry-pick). CUDA / NCCL paths stay unchanged.

  1. Platform + MindIE attention — add platforms/ (Ascend capability probes, HCCL, MindIE compile backend), thin utils/platform.py over current_platform, and register a mindie attention backend for Qwen-Image.
  2. Multi-card Ulysses SP — bind Ascend devices before init_process_group (HCCL), align config.device in engine/worker, reject MindIE attention when ring > 1.
  3. Qwen DiT micro-opts — always use addcmul for gated residual/modulate; gate MindIE RoPE / layernorm_scale_shift / fused RMSNorm behind USE_MINDIESD_FUSE=true.
  4. Long-context Ulysses attentionAscendLongContextAttention: SeqAllToAll4D pre/single/after, optional head-chunked all-to-all (FA_ALLTOALL_CUT) or FA/all-to-all overlap on one shared NPU comm stream (FA_ALLTOALL_OVERLAP); falls back to USPAttention when unavailable.
  5. Knobs on the platformop_fusion, fa_alltoall_overlap, fa_alltoall_cut live on AscendPlatform (env: USE_MINDIESD_FUSE, FA_ALLTOALL_OVERLAP, FA_ALLTOALL_CUT).

Commits

  • bf49ef1 feat(npu): add Ascend platform abstraction and MindIE attention
  • 8c1e61c feat(npu): enable Ulysses SP with CFG parallel on Ascend
  • 0cf05b6 feat(npu): fuse Qwen DiT addcmul, MindIE RoPE, and LN modulate
  • 67b93a1 Add AscendLongContextAttention: NPU/MindIE long-context attention under Ulysses SP
  • 0840a68 feat(npu): long-context attention, fused ops, unified platform abstraction

Notes

  • Default inference does not enable compile (use_torch_compile=False); compile kwargs are injected only when compile is on.
  • USE_MINDIESD_FUSE=true gates MindIE RoPE / LN fuse / npu_rms_norm; addcmul is always on.
  • FA_ALLTOALL_CUT / FA_ALLTOALL_OVERLAP: 0/1 = off (single round-trip); >1 = on. CUT takes precedence over OVERLAP.
  • Overlap uses one shared all-to-all comm stream (not per-layer).

Test plan

  • GPU: existing single/multi-card paths still use CUDA/NCCL (no behavior change).
  • NPU single-card smoke with --attn-type mindie (and without).
  • NPU 4-card: ASCEND_RT_VISIBLE_DEVICES=0,1,2,3, Ulysses SP (sp_ulysses_degree=4, sp_ring_degree=1) + CFG parallel.
  • Optional: USE_MINDIESD_FUSE=true for RoPE / LN / RMSNorm fuse.
  • Optional: FA_ALLTOALL_OVERLAP>1 or FA_ALLTOALL_CUT>1 on 4-card Ulysses.
  • Confirm MindIE + ring > 1 is rejected with a clear error.

hammer and others added 3 commits August 13, 2026 12:07
Add platforms registry with Ascend capability probes, extend
utils/platform for npu/hccl/compile kwargs, and register a MindIE
attention backend for Qwen-Image on the v1 layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
Bind Ascend devices before HCCL init_process_group, align/bind
config.device across engine workers, and reject MindIE with ring SP.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use addcmul for gated residual/modulate micro-opts, and gate MindIE
RoPE / layernorm_scale_shift behind USE_MINDIESD_FUSE.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Chitandaaaaa Chitandaaaaa changed the title Feat/npu ulysses4 v1 feat(npu): Ascend platform, MindIE attention, and Ulysses SP for v1 Aug 13, 2026
root and others added 2 commits August 13, 2026 20:28
under Ulysses SP, hiding all-to-all latency behind FA compute
(compute-communication overlap).

- Ulysses flow via all_to_all_4D_pre/single/after (SeqAllToAll4D).
- FA_ALLTOALL_CUT/OVERLAP count semantics (0/1 off, >1 on, CUT
  wins): baseline single round trip; cut = head-chunked round trips;
  overlap = all-to-all on side stream2 overlapped with FA on main
  stream via npu Event/Stream sync.
- current_stream refreshed at forward time.
- Ulysses-only; falls back to USPAttention when not available.
…ction

- Add Ascend long-context attention under Ulysses SP with a single shared all-to-all comm stream
- Add fused RMSNorm and use it in the Qwen-Image transformer
- Unify platform abstraction via current_platform
- Centralize Ascend tuning knobs (op_fusion, fa_alltoall_overlap/cut) as platform attributes
@Chitandaaaaa Chitandaaaaa changed the title feat(npu): Ascend platform, MindIE attention, and Ulysses SP for v1 feat(npu): Ascend platform, Ulysses SP, long-context attention, and fused DiT ops for v1 Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants