-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
What is the expected enhancement?
We have 2 passes that do 1q gate optimization Optimize1qGates
which only works on u1, u2, u3 (and u and p which are identical to u3 and u) and Optimize1qGatesDecomposition
which works with any basis. Right now all the default pass managers are using logic to pick between the two passes with:
if basis_gates and ('u1' in basis_gates or 'u2' in basis_gates or
'u3' in basis_gates):
_opt = [Optimize1qGates(basis_gates), CXCancellation()]
else:
_opt = [Optimize1qGatesDecomposition(basis_gates), CXCancellation()]
This is less than ideal because for over complete basis that include u1
, u2
, or u3
the resulting output is not fully optimized. We should be using the Optimize1qGatesDecomposition
by default; except for where the 1q component of a basis set consists solely of u
, p
, u1
, u2
, or u3
. This is because while after #5468 is fixed Optimize1qGatesDecomposition
will produce the same result as Optimize1qGates
in all cases for that case Optimize1qGatesDecomposition
it's significantly slower than Optimize1qGates
so we should use the faster pass in that case.
When this is implemented it will also fix #5436