-
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
Use PyO3 0.22 and rust-numpy 0.22 #13313
Conversation
This commit migrates to using PyO3 0.22 and rust-numpy and updates all the deprecated and changed interfaces in the libraries to their new syntax. No new or alternative interfaces are used as part of this PR except for where deprecation warnings pointed to do so. One thing to note is that in pyo3 0.22 a new feature py-clone was added to re-enable `Py<T>::clone()`. This was disabled by default in pyo3 0.22 because of a soundness issue around calling that in situations when the GIL was not held. [1] Right now qiskit relies on using `Clone` on `Py` objects because we have container types that own a `PyObject` that we sometimes clone at the top level so this flag needs to be set. In the future we can look at adding interfaces to avoid needing this flag in the future. Another thing to note is that rust-numpy includes support for ndarray 0.16, however this PR doesn't migrate to it because `ndarray_einsum_beta` used in the `qiskit_accelerate::unitary_compose` module still depends on ndarray 0.15 and we can't upgrade until that does. [1] https://pyo3.rs/v0.22.3/migration#pyclone-is-now-gated-behind-the-py-clone-feature
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 11298339065Details
💛 - Coveralls |
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.
Looks good to me!
Thanks for doing this. It's always neat to see how PyO3's interface evolves through these updates 🙂.
@@ -613,6 +613,7 @@ impl CommutationLibrary { | |||
#[pymethods] | |||
impl CommutationLibrary { | |||
#[new] | |||
#[pyo3(signature=(py_any=None))] |
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.
They finally got rid of the automatic optional stuff I see!
Summary
This commit migrates to using PyO3 0.22 and rust-numpy and updates all the deprecated and changed interfaces in the libraries to their new syntax. No new or alternative interfaces are used as part of this PR except for where deprecation warnings pointed to do so.
One thing to note is that in pyo3 0.22 a new feature py-clone was added to re-enable
Py<T>::clone()
. This was disabled by default in pyo3 0.22 because of a soundness issue around calling that in situations when the GIL was not held. [1] Right now qiskit relies on usingClone
onPy
objects because we have container types that own aPyObject
that we sometimes clone at the top level so this flag needs to be set. This only occurs in thecircuit
crate. In the future we can look at adding interfaces to avoid needing this flag in the future.Another thing to note is that rust-numpy includes support for ndarray 0.16, however this PR doesn't migrate to it because
ndarray_einsum_beta
used in theqiskit_accelerate::unitary_compose
module still depends on ndarray 0.15 and we can't upgrade until that does.Details and comments
[1] https://pyo3.rs/v0.22.3/migration#pyclone-is-now-gated-behind-the-py-clone-feature