-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Clifford unitary synthesis plugin #14429
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
Clifford unitary synthesis plugin #14429
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 15296217263Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
I think it's a nice PR. I had a few comments about unifying tests, but other than that it looks good.
qiskit/transpiler/passes/synthesis/clifford_unitary_synth_plugin.py
Outdated
Show resolved
Hide resolved
Thanks Shelly, I have improved the tests based on your suggestions: indeed, there was too much code duplication previously. |
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.
LGTM. thanks!
* adding unitary synthesis clifford plugin * updating Clifford+T transpiler pipeline and improving tests * typo * pass over tests as suggested by review notes * another typo
Summary
This PR implements a new unitary synthesis plugin that checks whether a given unitary gate secretly happens to be a Clifford (such as, for example, an Rx-rotation by$\pi/2$ ). If so, a circuit implementing this unitary and consisting of only Clifford gates is returned. Otherwise, the unitary gate remains unchanged.
The new plugin is also integrated into the translation stage of the Clifford+T pipeline (see #14225): after collecting runs of single-qubit gates into single-qubit unitaries, we now first run the plugin (attempting to find a sequence of Clifford gates that exactly implement this unitary) and only then run the Solovay-Kitaev approximation algorithm.
Details and comments
In particular, this avoids running the Solovay-Kitaev algorithm on "secretly Clifford" gates (which, for example, includes both S and RX($\pi/2$ )). This also allows to strengthen the Clifford tests from #14225: each "secretly Clifford" gate should be synthesized to only Clifford basic gates, which BasisTranslator should then translate to the target basis set. (Note that when the target basis set includes both H and S, the rules in our equivalence library enable to do the translation without introducing T-gates).
In principle we already have a somewhat related
CollectCliffords
pass in Qiskit, which could replace unitary gates by Clifford objects, which we could then synthesize using HighLevelSynthesis. However, this approach has a fundamental problem: replacing unitary gates byClifford
s discards global phase, thus changing the circuit. The current approach avoids this because the plugin returns an actual circuit (consisting of clifford gates) and explicitly takes care of the global phase to make sure the unitary operator does not change.