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
[WIP] Move utility functions _inverse_pattern and _get_ordered_swap to Rust #12327
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 9109062685Warning: 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:
|
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.