Revert "[cpp_wrapper] Swap to new PyBind11 simple GIL header (#161063)"

This reverts commit 74c4c758afa8c28162f00a456c185552e1159fd3.

Reverted https://github.com/pytorch/pytorch/pull/161063 on behalf of https://github.com/atalman due to sorry broke vllm tests please see https://github.com/pytorch/pytorch/pull/160754#issuecomment-3226051449 ([comment](https://github.com/pytorch/pytorch/pull/161063#issuecomment-3226065212))
This commit is contained in:
PyTorch MergeBot
2025-08-26 23:31:23 +00:00
parent 4e630f0629
commit 1ce423274d
5 changed files with 7 additions and 6 deletions

View File

@ -583,7 +583,7 @@ exclude_patterns = [
command = [
'python3',
'tools/linter/adapters/grep_linter.py',
'--pattern=#include <pybind11\/(^|[^(gil_simple\.h)])',
'--pattern=#include <pybind11\/(^|[^(gil\.h)])',
'--allowlist-pattern=#include <torch\/csrc\/utils\/pybind.h>',
'--linter-name=PYBIND11_INCLUDE',
'--match-first-only',

View File

@ -268,7 +268,7 @@ if RUN_CPU:
"test_multi_threading",
condition=not IS_WINDOWS,
# Two threads compile, so we expect the output code to be printed twice.
code_string_count={"py::gil_scoped_release_simple release;": 2},
code_string_count={"py::gil_scoped_release release;": 2},
),
BaseTest("test_profiler_mark_wrapper_call"),
BaseTest(

View File

@ -584,7 +584,7 @@ class CppWrapperCpu(PythonWrapperCodegen):
# Weights are promoted in the JIT mode
num_args = len(V.graph.graph_inputs) + len(V.graph.constants)
# release GIL to support multiple instances inference (in different threads of the same process)
self.prefix.splice("py::gil_scoped_release_simple release;")
self.prefix.splice("py::gil_scoped_release release;")
self.prefix.splice(
f"""
@ -2255,7 +2255,7 @@ class CppWrapperCpu(PythonWrapperCodegen):
scoped_lines.writeline("{")
with scoped_lines.indent():
scoped_lines.writeline("py::gil_scoped_acquire_simple acquire;")
scoped_lines.writeline("py::gil_scoped_acquire acquire;")
scoped_lines.writelines(lines_in_scope.split("\n"))
scoped_lines.writelines("}")
return scoped_lines._lines

View File

@ -297,7 +297,7 @@ class CppWrapperCpuArrayRef(CppWrapperCpu):
# Weights are promoted in the JIT mode
num_args = len(V.graph.graph_inputs) + len(V.graph.constants)
# release GIL to support multiple instances inference (in different threads of the same process)
self.prefix.splice("py::gil_scoped_release_simple release;")
self.prefix.splice("py::gil_scoped_release release;")
self.prefix.splice(
f"""

View File

@ -6,7 +6,8 @@
#include <utility>
#include <Python.h>
#include <pybind11/gil_simple.h>
#define PYBIND11_SIMPLE_GIL_MANAGEMENT
#include <pybind11/gil.h>
// Include some often-used cpp_wrapper headers, for precompiling.
#include <c10/util/BFloat16.h>