-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Unitary simulator in Rust #14746
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
Unitary simulator in Rust #14746
Conversation
Consructs a unitary matrix from a CircuitData with only unitary operations, exactly as what Operator(quantum_circuit).data does. The code is a simple wrapper on top of unitary_compose.
One or more of the following people are relevant to this code:
|
That's a great contribution to qiskit! How much is it faster and more scalable compared to the current |
Pull Request Test Coverage Report for Build 16313893357Details
💛 - Coveralls |
Unfortunately, as I have written in the description, this is slower, not faster than the Operator code in Python, and suffers from the same einsum "index out of bounds"/"too many subcripts" problems. Maybe @sbrandhsn or @mtreinish can suggest how to speed up the underlying |
Right now the einsum is all based around https://github.com/mtreinish/ndarray-einsum (which is just a fork I made of the original library to update dependencies). The code there hasn't really been updated in many years so we would have to either find a different library, spend the time to look into improving |
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 function is mainly used for rust synthesis tests, although it's not optimal, let's merge it and rebase #14666 after it's merged.
Summary
This PR adds a Rust-space method
sim_unitary_circuit
that constructs a unitary matrix (represented asArray2<Complex64>
) from aCircuitData
with only unitary operations (or barriers). Functionality-wise, this is equivalent toOperator(circuit)
in Python-space.This is needed to enable better in-Rust testing of Rust-space synthesis methods, for example as requested in #14666.
Details and comments
This is a simple wrapper on top of the existing
unitary_compose
. One caveat, that while both Python and Rust implementations ofunitary_compose
useeinsum
tricks for composing smaller-sized matrices onto larger-sized matrices as subsystems, the Python's implementation works for more qubits and is quite a bit faster. On circuits with 13 or more qubits, the Rust implementation throws the "index out of bounds" error, while the Python implementation works up to at least 16 qubits. (Personally, I don't think this is such a huge restriction, since at this point the Python code is quite slow and we will not likely use it in practice.) In the future, we should possibly revisit our implementation ofunitary_compose
to see if we can speed it up a bit.I have not added release notes since this is not planned to be user-facing.