-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Bump PyO3 and rust-numpy to 0.23.x #13577
base: main
Are you sure you want to change the base?
Conversation
This commit bumps the version of pyo3 and rust-numpy used by qiskit to the latest release 0.23. The largest change by volume of code is the deprecation of all the `*_bound()` methods. These are just warnings but they would be fatal to our CI so it needs to be updated. THe larger functional change that required updating the code is the change in the traits around converting to Python objects. This actually found a bug in the target where we were not returning a proper instruction type for standard gates. This also opens up the opportunity to update our hashbrown version to 0.15.x, but we can't do that until the next rustworkx-core release.
One or more of the following people are relevant to this code:
|
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 for doing this! I've done just one quick pass for now, and will unassign myself since I'm unlikely to have another look before I'm out on vacation.
.get_bound(py) | ||
.call1((array.to_object(py), py.None(), false))?; | ||
let unitary_gate = UNITARY_GATE.get_bound(py).call1(( | ||
<pyo3::Bound<'_, PyArray<Complex<f64>, ndarray::Dim<[usize; 2]>>> as Clone>::clone(&array).into_pyobject(py)?, |
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.
👀
In pyo3 0.23 the behavior of the default conversion for a `SmallVec<u8>` and similar arrays of u8 default to bytes objects when converted to python. This was documented as an api change in the release, however it was cauing the unitary synthesis test to fail because when we were evaluating whether the synthesis was in terms of the natural direction of the 2q gate on the backend it was evaluating `[0, 1] == b"\x00\x11"` which evaluates to `False` and the pass flipped the direction of the 2q gate. This was causing the test failure because all the 2q gates which were correctly directed were getting incorrectly flipped. This commit fixes this by manually creating a pylist so the comparisons work as expected.
Summary
This commit bumps the version of pyo3 and rust-numpy used by qiskit to the latest release 0.23. The largest change by volume of code is the deprecation of all the
*_bound()
methods. These are just warnings but they would be fatal to our CI so it needs to be updated. The larger functional change that required updating the code is the change in the traits around converting to Python objects. This actually found a bug in the target where we were not returning a proper instruction type for standard gates. This also opens up the opportunity to update our hashbrown version to 0.15.x, but we can't do that until the next rustworkx-core release.Details and comments