Skip to content

feat(npu): Ascend multi-card Ulysses SP with CFG/FSDP support - #265

Open
Chitandaaaaa wants to merge 2 commits into
modelscope:mainfrom
Chitandaaaaa:feat/npu-ulysses4-main
Open

feat(npu): Ascend multi-card Ulysses SP with CFG/FSDP support#265
Chitandaaaaa wants to merge 2 commits into
modelscope:mainfrom
Chitandaaaaa:feat/npu-ulysses4-main

Conversation

@Chitandaaaaa

@Chitandaaaaa Chitandaaaaa commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Add Ascend platform abstraction and enable multi-card ParallelWrapper on NPU (HCCL).
  • Implement Ulysses sequence parallel via SeqAllToAll + MindIE attention (attn_impl=mindie / auto on NPU).
  • Fix CFG/SP process group creation so every rank calls dist.new_group (required by HCCL).
  • Keep CUDA/NCCL path unchanged; ring_degree > 1 is still unsupported on NPU.

1. Add NPU 950 platform abstraction layer with device registry and auto_detect_device
2. Support mindiesd_attention and mindiesd_compile with capability detection and compile_backend
3. Adapt Qwen-Image model to use platform compile kwargs and NPU attention backend
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@Chitandaaaaa
Chitandaaaaa force-pushed the feat/npu-ulysses4-main branch from ff5e2d5 to c3e278d Compare July 30, 2026 09:35
@Chitandaaaaa Chitandaaaaa changed the title Feat/npu ulysses4 main feat(npu): Ascend multi-card Ulysses SP with CFG/FSDP support Jul 30, 2026
@Chitandaaaaa
Chitandaaaaa force-pushed the feat/npu-ulysses4-main branch 2 times, most recently from e5a0f9e to 4a9cd33 Compare July 30, 2026 12:38
Adapt ParallelWrapper for multi-card Ascend (HCCL/FSDP), route long-context
attention through SeqAllToAll + MindIE, and align config.device at parallel
load entry while workers bind rank-local devices.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Chitandaaaaa
Chitandaaaaa force-pushed the feat/npu-ulysses4-main branch from 4a9cd33 to ef35998 Compare July 31, 2026 01:50
for cfg_ranks in cfg_groups:
group = dist.new_group(cfg_ranks)
if rank in cfg_ranks:
PROCESS_GROUP.CFG_GROUP = dist.new_group(cfg_ranks)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些是不是无意义的改动?是否可以保持原样?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每个 rank 都按相同顺序 new_group,再决定是否赋值给 PROCESS_GROUP。这是 PyTorch 官方对 torch.distributed.new_group 的硬性约定,不是 HCCL 单独发明的规则。

出处:torch.distributed.new_group

原文:

This function requires that all processes in the main group (i.e. all processes that are part of the distributed job) enter this function, even if they are not going to be members of the group. Additionally, groups should be created in the same order in all processes.

HCCL 对此更严格。

device_mesh: DeviceMesh,
parallelize_plan: Optional[Union[ParallelStyle, Dict[str, ParallelStyle]]] = None,
):
# TP relies on a private torch API removed in PyTorch >= 2.9; adapt separately later.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个更好的做法是不是找到类似的功能,将下面的调用也一起替换掉?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

高版本目前没有可以替代的方法,目前只是校验,高版本把该私有方法合并了,暂时没有暴露类似的api,暂时规避,后续是否可以考虑删除。

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