已合并
A5 dtype: make checkSupportedDataType accept uint64/fp64 on Ascend950+ #44705
A5 dtype: make checkSupportedDataType accept uint64/fp64 on Ascend950+ #44705
已合并
limuan创建于 3 天前
limuan
limuan成员
3 天前

【合入来源】

【修改方案】

PTA reduce相关算子在processgrouphccl.cpp中有数据类型的校验,暂时未包含hccl A5新支持的数据类型uint64和fp64:
修改processgrouphccl.cpp中的数据校验函数,针对A5添加支持的数据类型uint64和fp64:

【资料变更】

不涉及

【接口变更】

不涉及

【功能验证】

image.png
image.png
image.png
image.png
image.png

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 limuan 的贡献)
limuanlimuan成员
3 天前 创建了 pull request,commit d9bb8284
atomgit-bot
atomgit-bot
3 天前 评论:

变更摘要

本 PR 主要扩展了分布式集合通信对数据类型的支持:在 ProcessGroupHCCL.cppcheckSupportedDataType 中,当设备为 Ascend950(Atlas A5)及以上时,额外放行 uint64HCCL_DATA_TYPE_UINT64)与 fp64HCCL_DATA_TYPE_FP64)两种数据类型;同时在多个分布式测试文件中新增对应测试用例,并调整断言逻辑以兼容 uint64

主要改动

  • 扩展 checkSupportedDataType 的类型检查逻辑: 在 torch_npu/csrc/distributed/ProcessGroupHCCL.cpp 中新增 a5ExtraDataTypes 集合,并通过 c10_npu::GetSocVersion() >= c10_npu::SocVersion::Ascend950 判断设备版本,使 Ascend950 及以上设备支持 HCCL_DATA_TYPE_UINT64HCCL_DATA_TYPE_FP64
  • 调整测试断言方式以兼容 uint64: 在 test_allreduce.pytest_reduce.pytest_reduce_scatter.py_test_multiprocess 中新增 use_equal 参数,对 uint64 使用 torch.equal 替代 assertEqual,避免因 torch 缺少 UInt64 加减法算子导致的校验失败。
  • 新增 uint64/fp64 集合通信测试用例: 在 test_allreduce.pytest_reduce.pytest_reduce_scatter.pytest_reduce_scatter_base.pytest_reduce_scatter_tensor.py 中新增由 @SupportedDevices(["Ascend950"]) 限定的测试,覆盖 all_reducereducereduce_scatterreduce_scatter_basereduce_scatter_tensor
  • uint64 期望结果改用 numpy 计算: 各测试对 uint64 使用非负输入区间,并通过 numpy 计算归约期望值后再 torch.from_numpy 转回张量,规避 torch 对 UInt64 算术支持不足的问题。
likedislike
atomgit-bot
atomgit-bot
3 天前 评论:

代码审查

已完成对全部 6 个变更文件的逐一审查。

审查结论汇总

各变更文件审查结果:

  1. test/distributed/test_allreduce.py — 无问题(uint64 用例通过 exp_input.numpy()expected += inputs 路径,正确)。
  2. test/distributed/test_reduce.py — 无问题(同上,uint64 用例正确)。
  3. test/distributed/test_reduce_scatter.py — 发现 1 处问题(P2)。
  4. test/distributed/test_reduce_scatter_base.py — 发现 1 处问题(P2)。
  5. test/distributed/test_reduce_scatter_tensor.py — 发现 1 处问题(P2)。
  6. torch_npu/csrc/distributed/ProcessGroupHCCL.cpp — 无问题(>= SocVersion::Ascend950 与仓库既有模式一致,getHcclDataType 已映射 UInt64→HCCL_DATA_TYPE_UINT64kDouble→HCCL_DATA_TYPE_FP64,逻辑正确)。

问题数量按优先级:

  • P0:0
  • P1:0
  • P2:3
  • P3:0

整体风险判断: 变更的 C++ 核心逻辑正确、与既有 SocVersion 判定模式一致;但三个 reduce_scatter 系列新增的 uint64 用例存在相同的确定性缺陷——把 numpy 数组传给了面向 torch 张量的 _construct_excepted_result(内部调用 .cpu()),在 Ascend950 上执行时会抛 AttributeError 而必然失败。该问题只影响测试代码、会在目标硬件上「响亮地失败」而非静默误判,因此定为 P2;修复方式统一为直接用 numpy 计算 inp * world_size 的期望值。

类型 数量
🔴 阻塞 0
🟡 建议 6

💬 仅评论

likedislike
ascend-robotascend-robot成员
3 天前 添加了label:ascend-cla/yes
此处折叠了50条消息 查看更多
renyujin成员
2 天前 评论:

/lgtm
/approve

likedislike
ascend-robotascend-robot成员
2 天前 添加了label:approvedlgtm
ascend-robotascend-robot成员
2 天前 合入了pull request
ascend-robot
ascend-robot成员
2 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
ascend-robot
ascend-robot成员
2 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#14179 [ commitID:886fd97b ] 已完成
likedislike