qml.debug_tape¶
- debug_tape()[source]¶
Access the tape of the quantum circuit.
The tape can then be used to access all properties stored in
QuantumTape
. This can be used to visualize the gates that have been applied from the quantum circuit so far or otherwise process the operations.- Returns
the quantum tape representing the circuit
- Return type
Example
While in a “debugging context”, we can access the
QuantumTape
representing the operations we have applied so far:dev = qml.device("default.qubit", wires=2) @qml.qnode(dev) def circuit(x): qml.RX(x, wires=0) qml.Hadamard(wires=1) qml.CNOT(wires=[0, 1]) qml.breakpoint() return qml.expval(qml.Z(0)) circuit(1.23)
Running the above python script opens up the interactive
[pldb]
prompt in the terminal. We can access the tape and draw it as follows:[pldb] t = qml.debug_tape() [pldb] print(t.draw()) 0: ──RX─╭●─┤ 1: ──H──╰X─┤
code/api/pennylane.debug_tape
Download Python script
Download Notebook
View on GitHub