Skip to content
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

Export to Cirq - classical control is not implemented #25

Open
perak opened this issue Jun 11, 2019 · 0 comments
Open

Export to Cirq - classical control is not implemented #25

perak opened this issue Jun 11, 2019 · 0 comments

Comments

@perak
Copy link
Collaborator

perak commented Jun 11, 2019

Good example is teleportation circuit:

QASM:

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c0[1];
creg c1[1];
rx (pi/4) q[0];
h q[1];
cx q[1], q[2];
cx q[0], q[1];
h q[0];
measure q[1] -> c1[0];
if(c1==1) x q[2];
measure q[0] -> c0[0];
if(c0==1) z q[2];

When exported to Cirq, code currently looks like this:

import cirq
import numpy as np

q = [cirq.NamedQubit('q' + str(i)) for i in range(3)]

circuit = cirq.Circuit.from_ops(
    cirq.Rx(np.pi / 4)(q[0]),
    cirq.H(q[1]),
    cirq.CNOT(q[1], q[2]),
    cirq.CNOT(q[0], q[1]),
    cirq.H(q[0]),
    cirq.measure(q[1], key='c10'),

    # Export to cirq WARNING: classical control not implemented yet.
    cirq.X(q[2]),

    cirq.measure(q[0], key='c00'),

    # Export to cirq WARNING: classical control not implemented yet.
    cirq.Z(q[2])
)

simulator = cirq.Simulator()
result = simulator.run(circuit)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant