-
Notifications
You must be signed in to change notification settings - Fork 52
Qrisp to Cirq converter #307
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
base: main
Are you sure you want to change the base?
Conversation
…partial unit tests
d49a239 to
79df62b
Compare
|
For global phase, what is the issue exactly? |
Cirq's global phase gate's parameter is incompatible with the input parameter of Qrisp's global phase gate. For now, we are temporarily ignoring this gate in the conversion function until I figure out a generic mapping between the two. |
|
Cirq takes |
|
Not exactly that straightforward. Thanks for the offer. I have a couple of local implementations already but they are not completely generic. |
Could be that I'm misunderstanding what you're looking for then? In any case, I wrote this for you so you can try it out and see if this is what you wanted :) . from qrisp import *
import cirq
from numpy.testing import assert_almost_equal
def main():
qv = QuantumBool()
h(qv)
gphase(0.1, qv)
return qv.qs.statevector("array")
qc = cirq.Circuit()
q = cirq.LineQubit.range(1)
qc.append(cirq.ops.H(q[0]))
qc.append(cirq.ops.GlobalPhaseGate(np.exp(1j * 0.1))())
target = cirq.final_state_vector(qc)
current = main()
assert_almost_equal(target, current) |
80f505e to
7811cf5
Compare
| ) | ||
|
|
||
| if op_i in ["gphase"]: | ||
| print( |
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 exactly is the issue here? Why doesn't the global phase gate work? I know we discussed this but I still didn't fully understand.
a6f9f1e to
e1c7fe6
Compare
|
|
||
| if (op_i not in cirq_gates_filter) and instr.op.definition: | ||
| new_circ = instr.op.definition | ||
| cirq_circuit.append(convert_to_cirq(new_circ)) |
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 there is still an issue here. I'd expect that you somehow have to specify the relevant cirq qubits. This bugged example confirms my suspicion:
from qrisp import *
qc = QuantumCircuit(4)
qc.rxx(0.3, 0, 1)
qc.rxx(0.3, 2, 3)
print(qc.to_cirq())
# 0: ───H───@─────────────@───H───H───@─────────────@───H───
# │ │ │ │
# 1: ───H───X───Z^0.095───X───H───H───X───Z^0.095───X───H───
|
Apart from the mentioned issue, I think it's done - thank you :) |
No description provided.