You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
@mtreinish and @kdk, combining #5468 and this issue, here's what I believe has to be done.
Add U3 to U2 or U1 and similar for U reductions in OneQubitEulerDecomposer.
In Optimize1qGatesDecomposition.run, allow single 1q gate optimization if the gate is U or U3, so that item 1 will go through the optimization.
Change the 'if' in the code above in level1, 2, and 3 to check that all 1q components of the basis are in ['u', 'p', 'u1', 'u2', 'u3'] and if so continue to use Optimize1qGates for this case. No changes to Optimize1qGates are required except change this line in __init__, self.basis = basis if basis else ["u1", "u2", "u3"] to self.basis = basis if basis else ["u", "p", "u1", "u2", "u3"]
Leave all test_optimize_1q_gates tests as is.
Add tests to test_optimize_1q_decomposition to test that the U3 and U reductions work.
@enavarro51 The above plan looks good. (Though for 3, I don't know that it's straightforward to distinguish the 1q from 2q gates in basis gates. It may be better to split out the pass manager changes into a separate PR.) Feel free to reach out with any questions.
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) andOptimize1qGatesDecomposition
which works with any basis. Right now all the default pass managers are using logic to pick between the two passes with:This is less than ideal because for over complete basis that include
u1
,u2
, oru3
the resulting output is not fully optimized. We should be using theOptimize1qGatesDecomposition
by default; except for where the 1q component of a basis set consists solely ofu
,p
,u1
,u2
, oru3
. This is because while after #5468 is fixedOptimize1qGatesDecomposition
will produce the same result asOptimize1qGates
in all cases for that caseOptimize1qGatesDecomposition
it's significantly slower thanOptimize1qGates
so we should use the faster pass in that case.When this is implemented it will also fix #5436
The text was updated successfully, but these errors were encountered: