| Event supports cross-process and cross-device (IPC event)
Co-authored-by: liujunzhu<liujunzhu@huawei.com>
# message auto-generated for no-merge-commit merge:
!28520 merge v2.7.1 into v2.7.1
Event supports cross-process and cross-device (IPC event)
Created-by: liujunzhu
Commit-by: liujunzhu
Merged-by: ascend-robot
Description: <!-- Thanks for sending a pull request!
-->
**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**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: Fixes #<issue number>, or Fixes (paste link of issue).
-->
Fixes #
**Special notes for your reviewers**:
See merge request: Ascend/pytorch!28520 | 5 个月前 |