Open steven-johnson opened 2 years ago
Update: reading further, there are at least two issues with the current (Mar 2022) version of nanobind:
We rely (heavily) on numpy and buffer protocol; the notes currently say it's "not clear" whether they will be reintroduced.
Looks like they’ve been reintroduced! https://github.com/wjakob/nanobind/blob/master/docs/tensor.md
This does seem worth evaluating now that the buffer protocol is back.
Agreed, but availability could be an issue -- pybind11 is widely available on many systems already, and (more importantly to me personally), nanobind isn't available inside Google yet, so we'd have to get it imported and updated on a regular basis if we adopted it.)
FYI, I took a stab at doing a basic adaptation, but it looks like there are a number of API changes that aren't well-documented yet (eg buffer->tensor) and other things that we use that are (still) missing in nanobind -- see https://github.com/wjakob/nanobind/discussions/77 for a handful of things I noticed. I pushed my (very very very rough) work-in-progress to the srj/nanobind
branch if anyone is interested, but right now it looks like nanobind probably needs more work to be ready for us (and we'd probably have to contribute that work).
(One part of nanobind that is better than pybind11 is that it appears to have support for dlpack built in, which is something we really want/need, not sure if it will be backported to pybind11)
It's been almost two years. Is nanobind ready? It now provides a nb::ndarray
argument type that is supposedly even more powerful than the buffer protocol binding was. They claim support with "NumPy, PyTorch, TensorFlow, JAX, etc."
I am particularly interested in nanobind for its support for the Python 3.12+ Stable ABI, which will dramatically reduce the number of wheels we'll need to publish.
https://nanobind.readthedocs.io/en/latest/porting.html#removed
I talked with a Xoogler who until recently maintained PyBind for Google; he strongly discouraged us from moving to nanobind; he considered it a 'hobby' project, and PyBind 3.x (on the way) will contain most of the improvements we want.
Per https://github.com/wjakob/nanobind: