-
Notifications
You must be signed in to change notification settings - Fork 50
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
Move from Pybind11 to nanobind #345
Conversation
Hi ! This project doesn't usually accept pull requests on the main branch. |
7b780d9
to
62b9ea4
Compare
rebased on devel after #342 |
9c8b57b
to
b81b141
Compare
Seems that on macOS CI, CMake is picking up Python 3.12 from the homebrew instead of the prescribed conda Python 3.10 |
609c415
to
d4b4f6e
Compare
Most tests are good. |
Nice @ManifoldFR good job ! The Julia example shows how you can use the Python package proxsuite in Julia code. and from the failing test I can see here that there is a problem with the get method now ( You said that this is handled differently now in nanobind vs how it was done before in pybind. For windows, we have issues with finding and linking against the |
I'm not sure what's happening there. It's all numpy stuff on this line so it shouldn't change?
I've discussed the issues with the module finding on this issue: jrl-umi3218/jrl-cmakemodules#708 |
Actually I'm getting the Julia error locally, too. The same one. I don't know what's wrong... |
e800699
to
b401bfe
Compare
Okay I looked into the Julia documentation for arrays to see what was going on. In the Julia REPL I typed the following julia> B = ones(2,10)
2×10 Matrix{Float64}:
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
julia> strides(B)
(1, 2) The stride might look strange, but it's not:
What's going on in the failing example here is that, whatever you do, calling, Numpy arrays are converted to Julia (column-major arrays). The behaviour we're getting there is actually the same that made other tests and examples fail:
A workaround is this: the point of the Or we could figure out why nanobind is not copying the data in this specific case. (the version of nanobind we currently use is the 2.0.0 release) |
b401bfe
to
42acd8c
Compare
73eec59
to
d09d5e9
Compare
047b337
to
4e46b18
Compare
Co-authored-by: Fabian Schramm <[email protected]>
Co-authored-by: Fabian Schramm <[email protected]>
Co-authored-by: Fabian Schramm <[email protected]>
0dd27e1
to
d509b5e
Compare
…n updating CHANGELOG.md
I applied your comments @fabinsch. I also excluded the CHANGELOG from CI. |
We can merge @jcarpent, I'll let you do the honors 😃 |
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.
This is not compiling with nanobind v2.1.0:
In file included from /…/proxsuite/bindings/python/src/expose-results.hpp:9,
from /…/proxsuite/bindings/python/src/algorithms.hpp:8,
from /…/proxsuite/bindings/python/src/expose-all.cpp:11:
/…/proxsuite/bindings/python/src/optional-eigen-fix.hpp: At global scope:
/…/proxsuite/bindings/python/src/optional-eigen-fix.hpp:17:20: error: expected template-name before '<' token
17 | : optional_caster<std::optional<Eigen::Ref<const T>>>
| ^
The nanobind submodule is on 8a65e0. On that commit it is working, but is it really necessary to use 3 days old unstable version ?
v2.1.0 is 3 week old, and only 25 commits away from the current master.
Excellent catch, I was using the new |
I just pushed two commits which reverts the submodule to v2.1.0 and replicates the behaviour of my specialization of |
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.
Thanks, now I can confirm that it works for me (with #352):
proxsuite> 100% tests passed, 0 tests failed out of 52
I think @wxmerkt is aware of this issue for the TSID downstream as mentioned here. However, I don't know if there is a plan to fix it (soon). If not, I agree that we could deactivate it for now, like this auto-merge will work again here. |
As discussed in #340, this PR sets us up with nanobind as the bindings support backend, instead of pybind11 (as a submodule, just as we used pybind11).
It does the necessary changes:
pybind11::
tonanobind::
Work left to do
Notes
nanobind::arg_v
is not the same thing as it used to be in pybind11. Firstly, default arguments are specified differently (using an assignment expression, just as in Boost.Python). Secondly, function argument docstrings seem to be gone. This means that a bunch of documentation for class ctor and function arguments is gone. I'm not sure where to recover them?Closes #340