-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add a generic Optimizer that makes use of GateTabulation #4059
Comments
Thanks for opening @wjhuggins! I'm trying to gauge the size/complexity of this do you mind sharing your not-so-pretty code in a gist as a prototype and what specific concerns you have regarding analytical compilation? That would help contributors / ourselves get started. If I understand correctly the task would be to write an optimizer that approximates any two-qubit gates to single-qubit gates using GateTabulation, which currently only produces single qubit unitaries but not actual gates. We would have to convert these single qubit unitaries to PhasedXZPow gates? Or something else? |
I'd be happy to. I'll spend a bit of time on it next week. The main thing is that the existing infrastructure around the GateTabulation code is only useful for compiling to a Sycamore gate + single-qubit gates. But the same building blocks could be used to write an optimizer that compiles to an arbitrary two-qubit gate + single-qubit gates. |
Discussed in cirq cync: possible connection to gatesets cc @tanujkhattar A generic interface for compiling to various gates should exist. It should go to analytic compilation routines if we have them, but can fall back to tabulation as well. Marking "accepted" |
Here's a gist that has the diff of the changes I made: https://gist.github.com/wjhuggins/05e54da80a9e02b96c700569273f6c92 |
I basically did two things.
A real version of the code should definitely be organized differently. I wasn't sure how to do this so I just left it alone in its hack-y state. I'm open to working on this later after I wrap up the experiment that I've been using it for and move on to producing some tutorials about it for public consumption. |
Marked pre-1.0 as a component of Transformers. |
@tanujkhattar Do we really need this before 1.0? |
Nope, this should be marked after 1.0. Changed the label. |
We should write an Optimizer that can use the GateTabulation code to recompile a circuit for an arbitrary two-qubit gate.
Is your feature request related to a use case or problem? Please describe.
Yes. This would make it easy to compile a circuit to a specific device using a two-qubit gate which we don't have a full set of analytical tools for.
In the future, we could also use this kind of functionality to do better refitting based on calibration data (at the expense of generating many GateTabulation objects).
Describe the solution you'd like
We should adapt the existing infrastructure we have to provide an optimizer which uses the GateTabulation code to compile a circuit with a user specific base_gate.
[optional] Describe alternatives/workarounds you've considered
I've hacked this in to the code myself, but it isn't pretty. Analytical compilation isn't always possible and it definitely isn't always straightforward to implement, even for gates we support well.
P1 or P2 depending maybe.
The text was updated successfully, but these errors were encountered: