pytorch/test/cpp_extensions
Zhenbin Lin e0d97e936a OpenReg: Fix releasing tensor issue when exiting process (#140936)
When executing the following code:

```
import pytorch_openreg

import torch

if __name__ == "__main__":
    a = torch.tensor(1, device="openreg")

```
Sometimes releases tensor a failed after the process finishes executing `main` function. The trace of releasing `a` is `~Tensor()` -> ... -> `OpenRegMem.cpp` -> `OpenRegHooks.cpp` -> `_aten_impl.py`.

There are two failed scenarios I've found:

1. Segmentation fault: Before executing `~Tensor()`, the process has released global variables in `_aten_impl.py`, which causes the issue.
2. Waiting indefinitely: The main process passes the `free ptr` command  to deamon process, however daemon processes have shutdown.

The way to fix this issue is when the process is shutting down, we ignore the del ptr operation.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/140936
Approved by: https://github.com/ezyang
2024-11-22 13:50:35 +00:00
..
no_python_abi_suffix_test
open_registration_extension OpenReg: Fix releasing tensor issue when exiting process (#140936) 2024-11-22 13:50:35 +00:00
self_compiler_include_dirs_test
torch_test_cpp_extension
cpp_c10d_extension.cpp
cpp_c10d_extension.hpp
cpp_frontend_extension.cpp
cublas_extension.cpp
cuda_dlink_extension.cpp
cuda_dlink_extension_add.cu
cuda_dlink_extension_add.cuh
cuda_dlink_extension_kernel.cu
cuda_extension.cpp
cuda_extension.cu
cuda_extension_kernel.cu
cuda_extension_kernel2.cu
cudnn_extension.cpp
cusolver_extension.cpp
dangling_impl_extension.cpp
doubler.h
extension.cpp
identity.cpp
jit_extension.cpp
jit_extension2.cpp
maia_extension.cpp
mps_extension.mm
mtia_extension.cpp
open_registration_extension.cpp
rng_extension.cpp
setup.py
torch_library.cu