-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
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:
- a chain of rz
- a chain of rx
- a chain of ry
- a chain of p
- a chain of u1
- a chain of u2 (plus possible u1)
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:
- U1 or RZ/P in case the result is a diagonal
- U2 or RZ-SX-RZ in case the matrix is of a particular shape
- U3 or U in case the matrix is general
- RZ-RX-RY or RX-RZ-RX or RZ-RY-RZ or ...(any combination of two pauli rotations), in case this decomposition is desired. We already have code for this in
quantum_info/synthesis/one_qubit_euler_decomposition
- RZ-SX-RZ-SX-RZ or RZ-SX-RZ in case these gates are in the basis
- Clifford + T in case a fault-tolerant basis is required
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.