-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
better single-qubit gate optimization workflow #8192
Comments
I agree the single qubit gate chain path should be unified and improved and doing things on an ad-hoc basis just leads to us missing things. For the specific steps:
|
So as discussed with @ajavadia this can be symbolically, or in another way where the 4 needed parameters are stored in lists, but not evaluated. Because the insertion order would determine the order in which the unitaries were composed, one could iterate over the list, binding parameters, and computing the resultant angles as you go via a regular numerical function eval. Some fine tuning of this idea is probably needed, but one can work around the need for matrices and arrays of parameters. |
Maybe we can change in the Quaternion class (qiskit.quantum_info.synthesis.quaternion) to support symbols. In that case, we can convert any gate to u3, and then using Euler angles we can merge gates. The final u3 can be in easy way decomposed into base gates. |
So yeah one could do that, but then you would really need to have a way of symbolically having a function |
What should we add?
There has been some work recently in #7579 and #8178 to enable optimization of chains of single-qubit gates when they contain parameters. Previously qiskit only did this optimization for numeric values.
While useful, the current procedure is still a bit ad-hoc. It enables optimizing:
Instead I suggest the following workflow:
For one, we should not have two passes for this
Optimize1qGates
andOptimize1qGatesDecomposition
. The former should be deprecated.Then, the pass should collect and consolidate any chain of single-qubit gates into a 2x2 unitary matrix. Regardless of what the underlying gates are (rx, ry, rz, u, u2, s, t, ...), the chain should be represented as a single 2x2 matrix. This should be fast to compute even for symbolic math.
Then we build synthesis routines to go from a 2x2 matrix to any of the basis of interest:
quantum_info/synthesis/one_qubit_euler_decomposition
The point is that single qubit gate synthesis is easy and known. It's also small and efficient to compute the full matrix. So instead of lots of ad-hoc rules for combining gates, we should just make a generic U, then go to the desired basis from there.
The text was updated successfully, but these errors were encountered: