Any way to draw my quantum circuit?

Hi! I was wondering if there’s any way to print out my circuit so that my circuit is same as what I was meant to design. Since there is no insert strategy for gates (such as the ones in Cirq), I am not sure whether my quantum circuit is designed in the way I was thinking.

Hi @Leeseok_Kim! You can use the QNode.print_applied() method to print out the gates applied by the QNode after each evaluation.

We’re also currently working on adding a circuit drawing feature as well :slightly_smiling_face:

1 Like

For example:

dev = qml.device('default.qubit', wires=2)

@qml.qnode(dev)
def circuit(x):
    qml.RZ(x, wires=0)
    qml.CNOT(wires=[0,1])
    qml.RY(x, wires=1)
    return qml.expval(qml.PauliZ(1))

circuit(0.543)
circuit.print_applied()

will give the output

Operations
----------
RZ(0.543, wires=0)
CNOT(wires=[0,1])
RY(0.543, wires=1)

Observables
-----------
expval(PauliZ(wires=1))
1 Like

Hi- thanks! Also, I have a few questions on designing quantum circuits. Is there any way that I can contact with you in easier/faster way other than this forum? If there’s not, this forum would be fine with me.

This forum would likely be the faster way, since it is checked by various PennyLane developers — so if I don’t see your reply straight away, someone else would be able to reply in the meantime :slight_smile:

In addition, you can also join our Slack channel: the link is https://u.strawberryfields.ai/slack

To follow on from your original question, you can also directly access the Cirq circuit object; it is available via dev.circuit. With this object, you can perform standard Cirq circuit drawing.