-
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
First iteration of the outputting to Quil. #2903
Conversation
Pull request fixes.
See #2386. |
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.
@hanusaj Make sure all the Travis builds pass.
cirq/ops/swap_gates.py
Outdated
@@ -126,6 +127,17 @@ def _qasm_(self, args: 'cirq.QasmArgs', | |||
args.validate_version('2.0') | |||
return args.format('swap {0},{1};\n', qubits[0], qubits[1]) | |||
|
|||
|
|||
# SwapPowGate in QUIL is equivalent to the PSWAP Gate in QUIL |
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.
What's this for?
output_func(protocols.quil(decomposed_op, formatter=self.formatter)) | ||
|
||
def rename_defgates(output: str): | ||
result = output |
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.
Add docstring
|
||
@value.value_equality(approximate=True) | ||
class QuilOneQubitGate(ops.SingleQubitGate): | ||
|
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.
Add docstring
cirq/circuits/quil_output.py
Outdated
import numpy as np | ||
|
||
def to_quil_complex_format(num): | ||
cnum = complex(str(num)) |
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.
Add docstring
cirq/ops/common_gates.py
Outdated
@@ -666,6 +685,11 @@ def _circuit_diagram_info_(self, args: 'cirq.CircuitDiagramInfoArgs' | |||
wire_symbols=('H',), | |||
exponent=self._diagram_exponent(args)) | |||
|
|||
def _has_stabilizer_effect_(self) -> Optional[bool]: |
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.
Remove this.
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 noticed that it only said we added this because of the addition of the quil function. I tried moving this below the _quil_
function to see if that will remove the change.
cirq/ops/common_gates.py
Outdated
@@ -807,17 +833,24 @@ def _circuit_diagram_info_(self, args: 'cirq.CircuitDiagramInfoArgs' | |||
wire_symbols=('@', '@'), | |||
exponent=self._diagram_exponent(args)) | |||
|
|||
def _has_stabilizer_effect_(self) -> Optional[bool]: |
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.
Remove this.
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.
Same as above.
cirq/ops/common_gates.py
Outdated
@@ -972,17 +1005,23 @@ def controlled(self, | |||
result.control_qid_shape[:-1]) | |||
return result | |||
|
|||
def _has_stabilizer_effect_(self) -> Optional[bool]: |
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.
Remove this.
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.
Same as above.
|
||
@value.value_equality | ||
class QuilTwoQubitGate(ops.TwoQubitGate): | ||
|
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.
Add docstring
|
||
if len(op.qubits) == 1: | ||
return QuilOneQubitGate(mat).on(*op.qubits) | ||
return QuilTwoQubitGate(mat).on(*op.qubits) |
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've been trying to find a way to cover the above three lines. It seems like all of the gates decompose into gates that we have defined _quil_
functions for. My thoughts are to make a basic custom one and two qubit gate that wouldn't decompose but I haven't been able to figure out a good way to do that. @vtomole Do you know of anywhere in the repository I could find an example that may have done something similar?
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.
qasm_output_test.py
doesn't help?
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.
Correct. qasm_output_test.py
doesn't help because QASM had basic gates that were not implemented. Whereas with QUIL, all gates I have found decompose into QUIL standard gates which do not require the fallback
function from protocols.decompose
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'm going to merge and file an issue for this.
Fixes: #2386.