-
Notifications
You must be signed in to change notification settings - Fork 990
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 initial support for converting Quil programs into Cirq circuits #3211
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vtomole
approved these changes
Aug 13, 2020
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.
@karalekas Please add some docs to https://github.com/quantumlib/Cirq/blob/master/docs/interop.ipynb |
exAClior
added a commit
to exAClior/Cirq
that referenced
this pull request
Aug 13, 2020
…rcuits (quantumlib#3211)" This reverts commit 1aabcb7.
exAClior
added a commit
to exAClior/Cirq
that referenced
this pull request
Aug 13, 2020
… Cirq circuits (quantumlib#3211)"" This reverts commit 2630271.
tonybruguier
pushed a commit
to tonybruguier/Cirq
that referenced
this pull request
Aug 23, 2020
…uantumlib#3211) This PR adds Quil import support in a way analogous to the existing QASM import functionality, by leveraging the Quil parser that already exists in pyQuil. By using `circuit_from_quil` from the `cirq.contrib.quil_import` module, all Quil standard gates, measurements, and simple (non-parameterized) DEFGATEs can be converted to Cirq operations (see below). Additionally adds Quil output for special cases of `TwoQubitDiagonalGate`, and fixes a bug in the way DEFGATE blocks were being generated by the Quil outputter. ```python In [1]: from cirq.contrib.quil_import import circuit_from_quil In [2]: circuit_from_quil(""" ...: DECLARE ro BIT[3] ...: I 0 ...: I 1 ...: I 2 ...: X 0 ...: Y 1 ...: Z 2 ...: H 0 ...: S 1 ...: T 2 ...: PHASE(pi/8) 0 ...: PHASE(pi/8) 1 ...: PHASE(pi/8) 2 ...: RX(pi/2) 0 ...: RY(pi/2) 1 ...: RZ(pi/2) 2 ...: CZ 0 1 ...: CNOT 1 2 ...: CPHASE(pi/2) 0 1 ...: SWAP 1 2 ...: ISWAP 0 1 ...: XY(pi/2) 1 2 ...: CCNOT 0 1 2 ...: CSWAP 0 1 2 ...: MEASURE 0 ro[0] ...: MEASURE 1 ro[1] ...: MEASURE 2 ro[2] ...: """) Out[2]: 0: ───I───X───H───Z^(1/8)───Rx(0.5π)───@───────@───────────iSwap───────────────@───@───M('ro[0]')─── │ │ │ │ │ 1: ───I───Y───S───Z^(1/8)───Ry(0.5π)───@───@───@^0.5───×───iSwap───iSwap───────@───×───M('ro[1]')─── │ │ │ │ │ 2: ───I───Z───T───Z^(1/8)───Rz(0.5π)───────X───────────×───────────iSwap^0.5───X───×───M('ro[2]')─── In [3]: circuit_from_quil(""" ...: DEFGATE MYZ: ...: 1,0 ...: 0,-1 ...: ...: MYZ 0 ...: """) Out[3]: ┌ ┐ 0: ───│ 1 0│─── │ 0 -1│ └ ┘ ``` Related to quantumlib#1742, quantumlib#2386, quantumlib#2983
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds Quil import support in a way analogous to the existing QASM import functionality, by leveraging the Quil parser that already exists in pyQuil.
By using
circuit_from_quil
from thecirq.contrib.quil_import
module, all Quil standard gates, measurements, and simple (non-parameterized) DEFGATEs can be converted to Cirq operations (see below).Additionally adds Quil output for special cases of
TwoQubitDiagonalGate
, and fixes a bug in the way DEFGATE blocks were being generated by the Quil outputter.Related to #1742, #2386, #2983