已合并
Event supports cross-process and cross-device (IPC event) #28521
liujunzhu创建于 2025年12月23日
Event supports cross-process and cross-device (IPC event) #28521
已合并
liujunzhu创建于 2025年12月23日
liujunzhu
liujunzhu成员
2025年12月23日

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind bug
/kind task

/kind feature

What does this PR do / why do we need it:
event能力对齐cuda,支持跨进程与跨设备使用。

CUDA跨进程共享内存和跨设备拷贝内存时使用Event进行同步,而torch npu使用SynchronizeStream进行同步,希望torch_npu支持在跨设备和跨内存的场景也使用Event进行同步,提升整体性能。另外,需支持通过Python接口在进程间传递Event对象或Event handle并使用该Event进行进程间的同步。

相关场景如下:
1、跨进程使用Event:进程间传递interprocess=True的Event对象、Event的IPC Handle或torch.multiprocessing.reductions.reduce_event(event)的结果。
2、跨进程共享NPU内存:包括进程间通过参数或队列传递Tensor、进程间通过torch.multiprocessing.reductions.reduce_tensor()传递Tensor、进程间通过_share_npu_传递Tensor。
3、跨设备拷贝NPU内存:调用Tensor.to()或Tensor.copy_()接口。
不支持跨设备或跨进程使用interprocess=False的Event。

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewers:

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 liujunzhu 的贡献)
liujunzhuliujunzhu成员
2025年12月23日 创建了 pull request,commit ca18a153
ascend-robot
ascend-robot成员
2025年12月23日 评论:

Thank your for your pull-request.

The full list of commands accepted by me can be found at here.

You can get sig-info at here

likedislike
ascend-robot
ascend-robot成员
2025年12月23日 评论:

以下是根据您提交的修改文件推荐的Reviewer和Committer序列,需各模块评审通过后方可合入

Module List Reviewers Committers
repo-Ascend/pytorch yanpengquan, chenhao_1209, ShaoFeifan, zhanJ, chuboning medivh-x, zqwenn, chenhao_1209, yanpengquan, wangchao430
likedislike
AtlasAccount
AtlasAccount成员
2025年12月23日 评论:
ascend-robotascend-robot成员
2025年12月23日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
2025年12月23日 评论:

CLA Signature Pass

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

likedislike
liujunzhu
liujunzhu成员
2025年12月23日 评论:

add_component

likedislike
ascend-robotascend-robot成员
2025年12月23日 添加了label:MindSpore-Component
liujunzhu
liujunzhu成员
2025年12月23日 评论:

compile

likedislike
ascend-robot
ascend-robot成员
2025年12月23日 评论:

流水线任务触发成功,正在执行,请稍候。 任务链接[6f8865d104ae4cd39a228b9d13cc8e7f]

likedislike
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
2025年12月23日 评论:

get-log

likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-running
AtlasAccount
AtlasAccount成员
2025年12月23日 评论:

/torch_npu/csrc/core/npu/NPUEventManager.cpp
/torch_npu/csrc/npu/Event.cpp

likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-failed
liujunzhu
liujunzhu成员
2025年12月23日 评论:

retry

likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-running
AtlasAccount
AtlasAccount成员
2025年12月23日 评论:

retry 成功,请等待!

likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-failed
liujunzhu
liujunzhu成员
2025年12月23日 评论:

retry

likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-running
AtlasAccount
AtlasAccount成员
2025年12月23日 评论:

retry 成功,请等待!

likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-passed
AtlasAccount
AtlasAccount成员
2025年12月23日 评论:
检查项 状态 日志 产物
code_check >>> N/A
sca >>> N/A
check_error >>> N/A
anti_poison >>> N/A
Build_X86_USE_CXX_ABI_GCC13 >>> >>>
Build_LibTorch_USE_CXX_ABI_GCC13 >>> >>>
Build_ARM_USE_CXX_ABI_GCC13 >>> >>>
Build_ARM_inductor_gcc13 >>> >>>
UT_X86_Part_01 >>> N/A
UT_X86_Part_02 >>> N/A
UT_inductor_arm >>> N/A
openlibing链接 点此跳转
likedislike
ascend-robotascend-robot成员
2025年12月23日 删除了label:ci-pipeline-passed
ascend-robotascend-robot成员
2025年12月23日 添加了label:ci-pipeline-passed
王超成员
2025年12月24日 评论:

/approve

likedislike
ascend-robotascend-robot成员
2025年12月24日 添加了label:lgtm
li_jing_hw成员
2025年12月25日 评论:

/approve

likedislike
ascend-robotascend-robot成员
2025年12月25日 添加了label:approved
ascend-robot
ascend-robot成员
2025年12月25日 评论:

Review Guide

This Pull-Request Passes Review.
Committers who writed a comment of /approve are: wangchao430, li_jing_hw.
Reviewers who writed a comment of /lgtm are: wangchao430, li_jing_hw.

likedislike
ascend-robotascend-robot成员
2025年12月25日 合入了pull request