Pull Request已成功合入, 合并人@CANN-robot
(感谢 Davydov_Danil 的贡献)变更摘要
此 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_EXPERIMENTALCMake 选项;reduce_scatter_v_testcase_a3.cc新增多组变长 ReduceScatterV 测试用例,覆盖 4/8/16/64 等不同 rank 规模;v_testcase_common.h增加devType参数以支持 910_93 设备类型仿真。


代码审查
审查总结
本次审查覆盖了全部 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 |
⛔ 需要修改


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Description
将 BIRS 批量不变性扩展至变长 ReduceScatterV(ReduceScatterVBIRS / ReduceScatterVBIRSInter)
Related Issue
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:
Documentation Update
Type Label