Skip to content

Bump pybind11 from v2.13.6 to v3.0.4#20555

Open
rascani wants to merge 1 commit into
pytorch:mainfrom
rascani:pybind11-3.0-upgrade
Open

Bump pybind11 from v2.13.6 to v3.0.4#20555
rascani wants to merge 1 commit into
pytorch:mainfrom
rascani:pybind11-3.0-upgrade

Conversation

@rascani

@rascani rascani commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

pybind11 3.0 adds Python 3.14 support, free-threading compatibility, and multi-phase module init (PEP 489).

On Apple, pybind11 3.0's multi-phase init crashes when extension modules are built as SHARED and linked against libpython directly. The duplicate Python runtime causes a GIL state crash at import time. Fix this by replacing pybind11::embed (which links Python::Python → libpython) with pybind11::module (which links Python::Module — headers and ABI only) on all pybind SHARED extension targets, and adding -undefined dynamic_lookup so Python symbols resolve from the embedding interpreter at load time.

Bridge the legacy PYTHON_EXECUTABLE cmake variable to Python_EXECUTABLE so pybind11 3.0's FindPython module picks up the correct interpreter.

Needed for #16750

This PR was authored with Claude.

Test Plan

  • cmake configure succeeds with pybind11 3.0.4 (--preset pybind)
  • Built portable_lib, data_loader, selective_build, _llm_runner
  • Verified zero libpython linkage on all four .so files (otool)
  • All four modules import successfully on Python 3.13/macOS
  • lintrunner passes

pybind11 3.0 adds Python 3.14 support, free-threading
compatibility, and multi-phase module init (PEP 489).

On Apple, pybind11 3.0's multi-phase init crashes when extension
modules are built as SHARED and linked against libpython directly.
The duplicate Python runtime causes a GIL state crash at import
time. Fix this by replacing pybind11::embed (which links
Python::Python → libpython) with pybind11::module (which links
Python::Module — headers and ABI only) on all pybind SHARED
extension targets, and adding -undefined dynamic_lookup so Python
symbols resolve from the embedding interpreter at load time.

Bridge the legacy PYTHON_EXECUTABLE cmake variable to
Python_EXECUTABLE so pybind11 3.0's FindPython module picks up
the correct interpreter.

This PR was authored with Claude.

Test Plan:
- cmake configure succeeds with pybind11 3.0.4 (--preset pybind)
- Built portable_lib, data_loader, selective_build, _llm_runner
- Verified zero libpython linkage on all four .so files (otool)
- All four modules import successfully on Python 3.13/macOS
- lintrunner passes
@pytorch-bot

pytorch-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20555

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit ff5349d with merge base e5f5853 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 26, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@rascani rascani marked this pull request as ready for review June 27, 2026 00:01
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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant