Skip to content

Fix pybind11 3.0 call_guard on def_property family (#2038)#2038

Closed
itamaro wants to merge 1 commit intometa-pytorch:mainfrom
itamaro:export-D100445567
Closed

Fix pybind11 3.0 call_guard on def_property family (#2038)#2038
itamaro wants to merge 1 commit intometa-pytorch:mainfrom
itamaro:export-D100445567

Conversation

@itamaro
Copy link
Copy Markdown
Contributor

@itamaro itamaro commented Apr 11, 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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 11, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 11, 2026

@itamaro has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100445567.

@meta-codesync meta-codesync bot changed the title Fix pybind11 3.0 call_guard on def_property family Fix pybind11 3.0 call_guard on def_property family (#2038) Apr 13, 2026
@itamaro itamaro force-pushed the export-D100445567 branch from 9f53119 to 0ece095 Compare April 13, 2026 18:03
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
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 14, 2026

This pull request has been merged in 0bf1b91.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant