已合并
将 BIRS 批量不变性扩展至变长 ReduceScatterV(ReduceScatterVBIRS / ReduceScatterVBIRSInter) #2338
Davydov_Danil创建于 7月28日
将 BIRS 批量不变性扩展至变长 ReduceScatterV(ReduceScatterVBIRS / ReduceScatterVBIRSInter) #2338
已合并
Davydov_Danil创建于 7月28日
Davydov_Danil
7月28日

Description

将 BIRS 批量不变性扩展至变长 ReduceScatterV(ReduceScatterVBIRS / ReduceScatterVBIRSInter)

https://gitcode.com/cann/hccl/issues/528

Testing

Testing with the hccl-checker tool via ST tests "/test/st/algorithm/testcase/reduce_scatter_v_testcase_a3.cc"
Single-node: ReduceScatterVBirs was deployed on one Atlas A3 node with RankSize set between 4 and 16.
Example of ReduceScatterVBirs output from hccl_test for RankSize 16:
image.png

Documentation Update

Type Label

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Davydov_Danil 的贡献)
DDavydov_Danil
7月28日 创建了 pull request,commit ddb724b9
DDavydov_Danil
7月28日 关联了issue:[Requirement] 将 BIRS 批量不变性扩展至变长 ReduceScatterV(ReduceScatterVBIRS / ReduceScatterVBIRSInter)
atomgit-bot
atomgit-bot
7月28日 评论:

变更摘要

此 PR 将 BIRS(Bulk Invariance Reduce Scatter)算法从固定长度 ReduceScatter 扩展至变长 ReduceScatterV,新增了 ReduceScatterVBIRS 和 ReduceScatterVBIRSInter 两个算法变体,支持各 rank 发送/接收不同数据量的场景。同时引入 ENABLE_EXPERIMENTAL 编译开关控制实验性功能,并通过多线程流水线(主线程 + 2 个子线程)实现 HCCS 链路、SIO 链路与本地拷贝的并发执行。该功能通过环境变量 HCCL_BIRS_ENABLE=TRUE 启用,在 Atlas A3 设备上生效。

主要改动

  • 新增 ReduceScatterVBIRSExecutor 执行器:在 experimental/ops/reduce_scatter_v/birs/ 下实现 BIRS 算法的算子执行器,负责资源计算(CalcResRequest)和 Level0 内核运行(KernelRunLevel0),通过 PrepareDataSliceV 将变长的 sendCounts/sendDispls 转换为切片向量传递给模板层。

  • 新增 ReduceScatterVBIRS / ReduceScatterVBIRSInter 算法模板:单服务器模板按目标 rank 对应的变长切片大小执行 HCCS 写入、SIO 归约写入和本地拷贝;跨服务器模板在此基础上增加 LocalCopyPreproc 批量数据搬运和 InterServer 跨节点阶段,scratch 内存步长取各 rank 切片最大值以保证对齐。

  • 扩展操作分发与参数准备:在 op_common_experimental.cc 中新增 SelectAlgReduceScatterV 算法选择、在 ThreadResources 中增加 vDataDesDevPtr 字段支持变长数据描述的设备端传输,并在 ExecOpBirs 和 ProcessA3 中增加了 HCCL_CMD_REDUCE_SCATTER_V 的分支处理。

  • 新增实验性操作入口 ReduceScatterVExperimental:通过 MatchBIRSV() 检测环境变量 HCCL_BIRS_ENABLE,在使能时走新的 BIRS 路径;在 reduce_scatter_v_op.cc 中通过 ENABLE_EXPERIMENTAL 宏条件编译引入该入口,并在 PrepareReduceScatterVParam 中补充了 displs 字段的赋值。

  • 构建系统与测试基础设施:build.sh 新增 ENABLE_EXPERIMENTAL CMake 选项;reduce_scatter_v_testcase_a3.cc 新增多组变长 ReduceScatterV 测试用例,覆盖 4/8/16/64 等不同 rank 规模;v_testcase_common.h 增加 devType 参数以支持 910_93 设备类型仿真。

likedislike
不准确?
atomgit-bot
atomgit-bot
7月28日 评论:

代码审查

审查总结

本次审查覆盖了全部 24 个变更文件,共发现 6 个独立问题(无 P0/P1 问题):

优先级 数量 说明
P2 4 未检查返回值(错误被静默吞掉)、测试中未检查分配返回值
P3 2 测试内存泄漏、aclrtFree 桩函数不安全的通用性问题

各文件审查结果

文件 结论
CMakeLists.txt 无问题
build.sh 无问题
cmake/device/CMakeLists.txt 无问题
experimental/ops/CMakeLists.txt 无问题
experimental/ops/op_common/op_common_experimental.cc 无问题(ProcessA3 profiling 逻辑正确,PrepareThreadResources 设备指针管理正确)
experimental/ops/op_common/template/alg_template_base_experimental.h 无问题
experimental/ops/reduce_scatter_v/CMakeLists.txt 无问题
experimental/ops/reduce_scatter_v/birs/CMakeLists.txt 无问题
experimental/ops/reduce_scatter_v/birs/reduce_scatter_v_birs_executor.cc 无问题(算法选择、资源计算、模板调度逻辑正确)
experimental/ops/reduce_scatter_v/birs/reduce_scatter_v_birs_executor.h 无问题
experimental/ops/reduce_scatter_v/birs/reduce_scatter_v_executor_base.cc 无问题
experimental/ops/reduce_scatter_v/birs/reduce_scatter_v_executor_base.h 无问题
experimental/ops/reduce_scatter_v/birs/template/CMakeLists.txt 无问题
experimental/ops/reduce_scatter_v/birs/template/reduce_scatter_v_birs.cc P2:RunAsync 未检查 Preprocess 返回值
experimental/ops/reduce_scatter_v/birs/template/reduce_scatter_v_birs.h 无问题
experimental/ops/reduce_scatter_v/birs/template/reduce_scatter_v_birs_inter.cc P2:RunAsync 未检查 Preprocess 返回值;P2:未检查 LocalCopyPreproc 返回值
experimental/ops/reduce_scatter_v/birs/template/reduce_scatter_v_birs_inter.h 无问题
experimental/ops/reduce_scatter_v/reduce_scatter_v_op_experimental.cc 无问题(入口逻辑、MatchBIRSV、参数准备正确)
experimental/ops/reduce_scatter_v/reduce_scatter_v_op_experimental.h 无问题
src/ops/reduce_scatter_v/reduce_scatter_v_op.cc 无问题(displs 字段的补充设置是正确修复)
src/ops/reduce_scatter_v/reduce_scatter_v_op.h 无问题
test/st/algorithm/testcase/reduce_scatter_v_testcase_a3.cc P2:aclrtMalloc 返回值未检查;P3:内存泄漏
test/st/algorithm/testcase/v_testcase_common.h 无问题
test/st/algorithm/utils/src/hccl_proxy/aclrt_stub.cc P3:aclrtFree 桩对非 malloc 内存不安全

整体风险判断

中低风险。核心算法逻辑(变长切片处理、BIRS 模板调度、AICPU/CPU 双路径)审查通过,未发现逻辑错误或安全漏洞。主要问题集中在模板代码中 3 处未检查返回值 的调用——会在异常路径(channel 不足、unitSize 为零)下导致继续执行而非报错退出,需要修复。测试和桩代码中的问题是辅助性的,不影响生产行为。

类型 数量
🔴 阻塞 3
🟡 建议 4

⛔ 需要修改

likedislike
不准确?
CANN-robotCANN-robot成员
7月28日 添加了label:cann-cla/yes
此处折叠了684条消息 查看更多
CANN-robot
CANN-robot成员
23 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
23 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
23 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
23 天前 添加了label:ci-pipeline-passed
CANN-robotCANN-robot成员
23 天前 合入了pull request