Skip to content

Commit fbbc6c6

Browse files
committed
Add explanation and warning
1 parent ce41ec8 commit fbbc6c6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torch_xla/csrc/xla_graph_executor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@ std::vector<at::Tensor> XLAGraphExecutor::GetTensorsFused(
641641
// Execution is async in PJRT, so TransferFromServer may block until execution
642642
// completes. Release the GIL so other threads can proceed and unblock any
643643
// collective computations.
644+
// HACK: This method may be called outside of python (mainly in C++ tests) or
645+
// when the GIL is already released, so we must check both cases here. If
646+
// possible, prefer to release the GIL in the python bindings before copying
647+
// this pattern.
644648
PyThreadState* save = nullptr;
645649
if (Py_IsInitialized() && PyGILState_Check()) {
646650
save = PyEval_SaveThread();

0 commit comments

Comments
 (0)