-
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 missing factor of pi to parameterized Quil gate output #3206
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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.
Thank you for all the fixes @karalekas, this looks good to me.
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
…uantumlib#3206)" This reverts commit b878d06.
…utput (quantumlib#3206)"" This reverts commit 3be9767.
…b#3206) This PR addresses a bug in Quil output. The current code doesn't distinguish between Cirq's `PowGate` exponents and the angle parameters for Quil gates, but they differ by a factor of pi. This is verified by comparing program unitaries before and after conversion to Quil (see below). Adds a test for this change that depends on pyQuil, so `pyquil` is added to `pip-list-dev-tools.txt`, but in the event that pyQuil is not available for import, the test is [skipped](https://docs.pytest.org/en/latest/skipping.html#skipping-on-a-missing-import-dependency). Additionally sneaks in a change to Quil output for `ISwapPowGate` -- uses the native `XY` Quil gate when the exponent of the `ISwapPowGate` does not equal 1. ```python In [1]: import numpy as np ...: from pyquil import Program ...: from pyquil.simulation.tools import program_unitary ...: ...: from cirq import Circuit, LineQubit, QuilOutput, rx ...: ...: q0 = LineQubit(0) ...: ...: # rx(pi/2) creates an XPowGate with exponent 0.5 (and global_shift -0.5) ...: circ = Circuit(rx(np.pi/2)(q0)) ...: print(circ) ...: ...: pyquil_program = Program(str(QuilOutput(circ, (q0,)))) ...: print(pyquil_program) ...: ...: pyquil_unitary = program_unitary(pyquil_program, n_qubits=1) ...: print(pyquil_unitary) ...: ...: cirq_unitary = circ.unitary() ...: print(cirq_unitary) ...: ...: np.allclose(pyquil_unitary, cirq_unitary) ``` on `master`: ``` 0: ───Rx(0.5π)─── RX(0.5) 0 [[0.96891242+0.j 0. -0.24740396j] [0. -0.24740396j 0.96891242+0.j ]] [[0.70710678+0.j 0. -0.70710678j] [0. -0.70710678j 0.70710678+0.j ]] Out[1]: False ``` this PR: ``` 0: ───Rx(0.5π)─── RX(pi/2) 0 [[0.70710678+0.j 0. -0.70710678j] [0. -0.70710678j 0.70710678+0.j ]] [[0.70710678+0.j 0. -0.70710678j] [0. -0.70710678j 0.70710678+0.j ]] Out[1]: True ``` Related to quantumlib#1742, quantumlib#2386, quantumlib#2983
This PR addresses a bug in Quil output.
The current code doesn't distinguish between Cirq's
PowGate
exponents and the angle parameters for Quil gates, but they differ by a factor of pi. This is verified by comparing program unitaries before and after conversion to Quil (see below).Adds a test for this change that depends on pyQuil, so
pyquil
is added topip-list-dev-tools.txt
, but in the event that pyQuil is not available for import, the test is skipped.Additionally sneaks in a change to Quil output for
ISwapPowGate
-- uses the nativeXY
Quil gate when the exponent of theISwapPowGate
does not equal 1.on
master
:this PR:
Related to #1742, #2386, #2983