-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Switch jaxlib to use nanobind instead of pybind11. #16100
Conversation
This is a prototype, not ready for submission yet. |
edb03cb
to
f4deb33
Compare
Please ignore if it's too off-topic, but I would be interested in your take on building Specifically, on MacOS, the "official" CMake build uses a linker response file to handle unknown Python symbols via chained fixups and reduce the .so output size, which I have tried but failed to replicate in Bazel. (It might be possible with a genrule running the given symbol collection script in the Is that something that you think would be worth pursuing for Mac builds? (For some additional context, especially point no. 7): python/cpython#97524 (comment) Also, from experiments on Benchmark, I saw that passing |
Thanks for the comment. I wasn't aware of this, but it sounds like the size effects are minor for Python binaries, so perhaps it isn't worth sweating this. I don't think it would be terribly hard to pass a linker response file. JAX uses this macro from TSL to build python extensions: and note that it already passes a similar linker option: the exported symbols list (https://github.com/openxla/xla/blob/586f729fb47af6b8979b86ff141cc73677e4e78c/third_party/tsl/tsl/tsl.bzl#L638). So I'd imagine you could do something very similar here if you wanted? (My personal interest in nanobind here is actually the promise of Python C API stability, although we won't get the benefit of that until Python 3.12+.) |
I should also add: the other issue discussed in that thread relates to targeting Mac OS 12.0. We currently target 10.14 (in general, when shipping wheels, we want to be compatible over a long time period). |
Thanks for that link. JAX is doing exactly what I had in mind, but unfortunately, Would I get in trouble by declaring it a |
JAX actually uses the |
9965dd4
to
e7ab697
Compare
nanobind has a number of advantages (https://nanobind.readthedocs.io/en/latest/why.html), notably speed of compilation and dispatch, but the main reason to do this for these bindings is because nanobind can target the Python Stable ABI starting with Python 3.12. This means that we will not need to ship per-Python version CUDA plugins starting with Python 3.12. PiperOrigin-RevId: 559898790
e7ab697
to
70b7d50
Compare
Switch jaxlib to use nanobind instead of pybind11.
nanobind has a number of advantages (https://nanobind.readthedocs.io/en/latest/why.html), notably speed of compilation and dispatch, but the main reason to do this for these bindings is because nanobind can target the Python Stable ABI starting with Python 3.12. This means that we will not need to ship per-Python version CUDA plugins starting with Python 3.12.