-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 tolerances for gate decompositions #5827
Conversation
This commit adds a new basis ZSXX to the 1q euler decomposer. This basis is identical to the ZSX basis except it does an additional simplification pass so that instead of having 2 sx gates in the synthesized output a single X gate is used instead. Fixes Qiskit#5722
This is ready to review
Possible direction for the future: |
@levbishop this pr is really needed it fixes the global phase I notice for being outside 2pi much more. What is the status of getting this merged. |
I'd also like to get it merged soon. Because it ended up expanding into something quite extensive when I fixed all the tests and chased all the edge cases, Ali and Matthew were not comfortable including it in 0.17. I think the current .plan is to get 0.17.1 out in a week or so and then merge this into master ready for 0.18. Personally, since it does fix a few known bugs, and almost certainly a bunch that we didn't know about, and I have more confidence that it's generally doing the right thing, I'd be happy backporting to 0.17 but I'm in the minority here. |
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.
Looks good to me, I would like to revisit the hardcoded basis after this and come up with a strategy that does not lead to a mission creep of adding ever-so-slightly different basis over time.
Some tests were failing in TestSingleControlledRotationGates due to different global phase tracking causing an extra P() gate in some circumstances. Since the CCRZ gates are not minimal in single-qubit rotations anyway, and should be single-qubit optimized afterwards I fixed this by changing the test to pass for the slightly longer result circuit.
one_qubit_decompose
so that simplifications happen with the expected toleranceTwoQubitBasisDecomposer
test the global phase more effectively.TwoQubitBasisDecomposer.__call__()
to force a given number of basis uses, to make testing easiertest_two_qubit_weyl_decomposition_abc()
simplify=False
TwoQubitWeylDecomposition
is now a factory that knows how to specialize itself up to a fidelity for special pathological cases where the decomposition would otherwise be unstable (the 2-qubit analog of Euler angle gimbal lock at the north pole of the Bloch sphere that leads us to having the simplify option on theOneQubitBasisDecomposer
TwoQubitWeylDecomposition
remove the ad-hoc roundings from Round M2 dot product in Weyl decomposition #4835 Revert "Pin numpy version < 1.19.0 to unblock CI (#4599)" #4656 Restore approx 0 rounding to decomp0 method #4862 as hopefully the non-deterministic, non-repeatability is killed completely by the specializationsnp.isclose()
was becoming a bottleneck as @mtreinish has proposed fixing in Tune performance of OneQubitEulerDecomposer #5915 so this gives some of the speedup from that PR. The other ideas for performance (using_append
and working directly on theDAGCircuit
are also worth doing, and now merged into this PR