-
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
Move utility functions _inverse_pattern and _get_ordered_swap to Rust #12327
Conversation
Pull Request Test Coverage Report for Build 9411521330Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Is this still a work in progress? @jpacold if it's not, it would be helpful to remove the [WIP] from the title as it seems to me this has been completed. |
@raynelfss Done, thanks for pointing that out. |
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.
LGTM, just a small correction on the docstrings for your rust functions. Thank you for working on this!
Co-authored-by: Raynel Sanchez <[email protected]>
Co-authored-by: Raynel Sanchez <[email protected]>
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.
Just on comment otherwise LGTM as well 👍🏻
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.
LGTM thanks for the updates! If @ShellyGarion and @raynelfss are good with it I think we can merge 👍🏻
Edit: both are good with the changes 🙂
also port circuit construction to rust and add a reno
* Follow up on #12327 also port circuit construction to rust and add a reno * move _get_ordered_swap to Rust only * drop redundant Ok(expect()) * proper synthesis structure
…Qiskit#12327) * Move utility functions _inverse_pattern and _get_ordered_swap to Rust * fix formatting and pylint issues * Changed input type to `PyArrayLike1<i64, AllowTypeChange>` * Refactor `permutation.rs`, clean up imports, fix coverage error * fix docstring for `_inverse_pattern` Co-authored-by: Raynel Sanchez <[email protected]> * fix docstring for `_get_ordered_swap` Co-authored-by: Raynel Sanchez <[email protected]> * remove pymodule nesting * remove explicit `AllowTypeChange` * Move input validation out of `_inverse_pattern` and `_get_ordered_swap` --------- Co-authored-by: Raynel Sanchez <[email protected]>
* Follow up on Qiskit#12327 also port circuit construction to rust and add a reno * move _get_ordered_swap to Rust only * drop redundant Ok(expect()) * proper synthesis structure
Summary
This PR starts addressing #12225. I moved the implementations of two functions from qiskit/synthesis/permutation/permutation_utils.py to Rust.
Details and comments
Created permutation.rs
_get_ordered_swap
uses the same logic as it did in Python.Added a module
qiskit._accelerate.permutation
and a submoduleqiskit._accelerate.permutation.permutation_utils
(following the structure of the existing Python modules). The wrapped functions are in thepermutation_utils
submodule.Replaced the function bodies in
permutation_utils.py
with calls to the Rust functions.Added tests.
Performance
As expected, this implementation of
_get_ordered_swap
is faster than the Python version. However, the input type is expected to be an array ofint64
and there is a performance cost for converting from any other type. On my machine:int64
)int32
,uint32
, oruint64
)For now, I don't think this matters much, because the bottleneck in
synth_permutation_basic
is constructing the circuit, but it is something that might need to be optimized later on.