Fix pybind11 3.0 call_guard on def_property family (#2038)#2038
Closed
itamaro wants to merge 1 commit intometa-pytorch:mainfrom
Closed
Fix pybind11 3.0 call_guard on def_property family (#2038)#2038itamaro wants to merge 1 commit intometa-pytorch:mainfrom
itamaro wants to merge 1 commit intometa-pytorch:mainfrom
Conversation
Contributor
|
@itamaro has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100445567. |
9f53119 to
0ece095
Compare
itamaro
added a commit
to itamaro/torchcomms
that referenced
this pull request
Apr 13, 2026
Summary:
pybind11 3.0 added a static_assert preventing call_guard from being passed directly to def_property family functions (def_property_readonly, def_readwrite, etc.).
For def_property_readonly("options"), wrap the getter in py::cpp_function with call_guard passed there.
For def_readwrite("ops"), simply remove the call_guard — it has no effect on member variable accessors (they don't release the GIL since they're trivial pointer dereferences).
Both fixes are compatible with pybind11 2.13 and 3.0.
Differential Revision: D100445567
Summary: Pull Request resolved: meta-pytorch#2038 pybind11 3.0 added a static_assert preventing call_guard from being passed directly to def_property family functions (def_property_readonly, def_readwrite, etc.). For def_property_readonly("options"), wrap the getter in py::cpp_function with call_guard passed there. For def_readwrite("ops"), simply remove the call_guard — it has no effect on member variable accessors (they don't release the GIL since they're trivial pointer dereferences). Both fixes are compatible with pybind11 2.13 and 3.0. Differential Revision: D100445567
0ece095 to
8517805
Compare
Contributor
|
This pull request has been merged in 0bf1b91. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
pybind11 3.0 added a static_assert preventing call_guard from being passed directly to def_property family functions (def_property_readonly, def_readwrite, etc.).
For def_property_readonly("options"), wrap the getter in py::cpp_function with call_guard passed there.
For def_readwrite("ops"), simply remove the call_guard — it has no effect on member variable accessors (they don't release the GIL since they're trivial pointer dereferences).
Both fixes are compatible with pybind11 2.13 and 3.0.
Differential Revision: D100445567