-
Notifications
You must be signed in to change notification settings - Fork 0
Nanobind #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the codebase’s Python bindings from pybind11 to nanobind in order to leverage its smaller footprint and improved ABI stability.
- Update project dependencies and build configuration in pyproject.toml
- Replace pybind11 includes, macros, and APIs with their nanobind equivalents in all binding source files
- Adjust tests and submodules to accommodate the nanobind syntax and usage
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
pyproject.toml | Updated dependencies and build-system to use nanobind |
cpp/evalio/types.h | Minor cleanup; removal of a redundant comment |
cpp/evalio/bindings.h | Migrated binding definitions from pybind11 to nanobind with NB macros |
cpp/bindings/types.h | Revised bindings and API calls for types using nanobind syntax |
cpp/bindings/ros_pc2.h | Updated nanobind-based bindings for ROS point cloud conversions |
cpp/bindings/pipelines/bindings.h | Adjusted pipeline bindings to use nanobind macros and functions |
cpp/bindings/main.cpp | Replaced PYBIND11_MODULE with NB_MODULE and updated related includes |
Files not reviewed (2)
- CMakeLists.txt: Language not supported
- cpp/bindings/CMakeLists.txt: Language not supported
Another nicety, nanobind comes with builtin stub generation! |
Finally got stubs added in and working with tests. Also, verified that the wheel made on the github action runner (ubuntu 24.04 gcc) had an identical ABI to my system (ubuntu 20.04 gcc) and worked properly with evalio-example. |
This switches from pybind11 to nanobind, which is a smaller, more modern successor by the same author as pybind11. It should improve compile and runtimes slightly according to their benchmarks.
I've been planning on making this switch eventually, but what prompted it now is how nanobind stabilizes across C++ ABIs. Currently, to use external pybind11 modules (think adding custom gtsam factor python bindings that work with gtsam python bindings, or adding your own evalio pipeline in your own codebase) requires your codebase to be compiled with nearly the exact same compiler and libstdc++ version as the python package. This is obviously hard to do when distributing python wheels.
This PR fixes this, by loosening to only require the same libstdc++ version which should be easier to our users to match when implementing their own custom pipeline. There isn't currently a pybind11 release with this merged PR, but there is a nanobind one!
Migration is pretty easy, with mostly renaming of things required.
I still need to test whether this helps things or not.