已开启
CCU使用demo 需要补充内容,quick start不了 #809
gcw_M26Zeh65创建于  16 天前
gcw_M26Zeh65
16 天前 创建

Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.

Backgroud(背景信息)

https://gitcode.com/cann/hcomm/blob/master/docs/zh/comm_op_dev_guide/ccu_quick_start.md

几个建议疑问:
1、ccu使用的约束、或适合场景,这个地方要加一下。应该不是所有产品、所有场景都可以ccu展开
2、怎么设置这一段代码,跑在哪个rank上。root如果是rank0,没看到哪里设置root。
3、数据从rank1、2、3 拷贝到rank0是哪里实现的
4、demo code注释量是不够的,非常不利于用户学习、理解,难道demo不是这个目的?

Origin(信息来源)

https://gitcode.com/cann/hcomm/blob/master/docs/zh/comm_op_dev_guide/ccu_quick_start.md

Benefit / Necessity (价值/作用)

Design(设计方案)

likedislike
Leewis成员
16 天前 评论:

感谢对于社区的关注与反馈,当前所提问题已经收到,后续待分析明确后给出答复;

likedislike
Leewis成员
15 天前 评论:

感谢反馈,问题已确认。经核对 docs/zh/comm_op_dev_guide/ccu_quick_start.md、示例代码(examples/05_custom_ops_allgather)及 CCU 概念文档,逐点回复如下:

1、CCU 约束/适用场景
ccu_quick_start.md 全文未说明 CCU 的产品支持与约束。实际 CCU 仅支持 Ascend 950PR/Ascend 950DT(见 comm_engine.md 通信引擎对比表),且 CCU_models_concepts.md 的"约束与限制"章节也未在 quick start 中体现。将在 quick start 开头补充适用产品与约束说明。

2、代码跑在哪个 rank / root 如何设置
实际 root 为 rank0,在示例 examples/05_custom_ops_allgather/testcase/main.cc 中:

int32_t rootRank = 0;
aclrtSetDevice(rootRank);
HcclRootInfo* rootInfo = ...;
HcclGetRootInfo(rootInfo);                          // root(rank0) 生成 rootInfo

for (uint32_t i = 0; i < rankSize; i++) {
    args[i].rootInfo = rootInfo;                    // 各 rank 线程复用同一份 rootInfo
    args[i].rank = i;
    threads[i] = std::thread(Sample, &args[i]);
}

各 rank 线程进入 Sample 后,基于同一份 rootInfo 初始化通信域:

HcclCommInitRootInfo(rankSize, ctx->rootInfo, device, &hcclComm);

3、数据从 rank1/2/3 拷贝到 rank0 在哪实现
在 quick start"关键代码解析"第 10 步"将本端数据写入到远端通信内存",每个 rank 通过 ccu::Write 循环把本端数据写到所有其他 rank 的远端通信内存:

for (uint64_t rankIdx = 0; rankIdx < ctx.arg->rankSize; rankIdx++) {
    if (rankIdx != ctx.arg->rankId) {
        ccu::Write(channels[channelId], dst[rankIdx], src, sliceSize, event, mask);
        channelId++;
    }
}

所有 rank 并发执行此写操作后,各 rank 的 recvBuf 即得到按 rank id 顺序拼接的全量结果,即 AllGather 语义。

4、demo 注释不足
确认。quick start"关键代码解析"各步骤代码注释偏少(如前同步/后同步、Token 生成、Kernel 下发等均缺解释)。后续将补充相关注释,便于用户学习理解。

后续修改将同步给代码责任田进行修改。

likedislike
LLeewis成员
14 天前 关联了看板:HCCL
LLeewis成员
14 天前 关联了看板:HCOMM
LLeewis成员
5 天前 添加了label:wait-feedback
CANN-robot
CANN-robot成员
5 天前 评论:

您好,为了更准确地定位和解决问题,我们需要您提供上述提到的相关信息。如果 14 天内没有进一步更新,我们将暂时关闭此 Issue。感谢您的理解与配合。

likedislike