已合并
Add ProcessGroupHCCL::getCollNpuStreamId() to get or create NPU stream by device #34700
Add ProcessGroupHCCL::getCollNpuStreamId() to get or create NPU stream by device #34700
已合并
limuan创建于 4月29日
limuan
limuan成员
4月29日

【合入来源】

https://gitcode.com/Ascend/pytorch/issues/1884

【修改方案】

序号 功能点名称 功能点描述
1 新增 C++ 方法 getCollNpuStreamId ProcessGroupHCCL 类中新增 getCollNpuStreamId(at::Device device) 方法。根据 device 参数生成 key,从 hcclStreams_ map 中查询对应的 NPU stream ID,如果不存在则创建新的 stream。
2 Stream 存在时返回已有 ID hcclStreams_ 中存在对应 key 且 stream 列表不为空时,直接返回已有的 stream ID,确保幂等性。
3 Stream 不存在时创建新 Stream hcclStreams_ 中不存在对应 key 或 stream 列表为空时,从 stream pool 中创建新的 NPU stream,存入 hcclStreams_,并返回新创建的 stream ID。
4 支持高优先级 Stream 创建 创建新 stream 时,根据 options_->is_high_priority_stream 或环境变量 TORCH_HCCL_HIGH_PRIORITY 决定是否创建高优先级 stream。
5 Python 绑定暴露接口 Init.cpp 中通过 pybind11 将 getCollNpuStreamId 暴露为 Python 接口 get_coll_npu_stream_id,参数包括 device(torch.device),返回值为 int(stream ID)。

image.png

【资料变更】

不涉及

【接口变更】

新增Python 用户侧接口:ProcessGroupHCCL.get_p2p_stream_id

  • *接口描述:通过 pybind11 将 getCollNpuStreamId 暴露至 Python 层,供用户在分布式训练脚本中直接调用,获取指定设备的集合通信 stream ID 用于 stream 级别的同步与管理。

  • *接口原型:

    int64_t get_coll_npu_stream_id(at::Device device);
    
  • 输入参数:

参数名称 类型 描述
device at::Device at::DeviceNPU 设备对象,用于生成 key 和创建 stream
  • 返回参数:
参数名称 类型 描述
hcclStream.id int64_t 对应集合通信 stream 的 stream ID

【功能验证】

image.png

【CheckList】

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

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 limuan 的贡献)
limuanlimuan成员
4月29日 创建了 pull request,commit 4b80d364
ascend-robot
ascend-robot成员
4月29日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
test renyujin, wjlflyer (2/2) renyujin (1/1)
torch_npu/csrc/distributed renyujin, wjlflyer (2/2) renyujin (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

limuan, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robotascend-robot成员
4月29日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
4月29日 评论:

当前仓库存在以下 保护分支

Protected Branch Version Release
master
v2.11.0
v2.10.0
v2.9.0
v2.7.1
v2.8.0

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
此处折叠了45条消息 查看更多
wjlflyer成员
5月13日 评论:

/lgtm

likedislike
renyujin成员
5月13日 评论:

/lgtm
/approve

likedislike
ascend-robotascend-robot成员
5月13日 添加了label:approvedlgtm
ascend-robot
ascend-robot成员
5月13日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: renyujin.
Reviewers who wrote a comment of /lgtm are: renyujin, wjlflyer.

likedislike
ascend-robotascend-robot成员
5月13日 合入了pull request