Quantum tapes are a datastructure that can represent quantum circuits and measurement statistics in PennyLane. They are queuing contexts that can record and process quantum operations and measurements.

In addition to being created internally by QNodes, quantum tapes can also be created, nested, expanded (via expand()), and executed manually.

Finally, quantum tapes are fully compatible with autodifferentiating via NumPy/Autograd, TensorFlow, and PyTorch.


Unless you are a PennyLane or plugin developer, you likely do not need to use these classes directly.

See the quantum circuits page for more details on creating QNodes, as well as the qnode() decorator and QNode() constructor.

pennylane.tape Package


expand_tape_state_prep(tape[, skip_first])

Expand all instances of StatePrepBase operations in the tape.

make_qscript(fn[, shots])

Returns a function that generates a qscript from a quantum function without any operation queuing taking place.


OperationRecorder([ops, measurements, …])

A template and quantum function inspector, allowing easy introspection of operators that have been applied without requiring a QNode.

QuantumScript([ops, measurements, shots, …])

The operations and measurements that represent instructions for execution on a quantum device.

QuantumTape([ops, measurements, shots, …])

A quantum tape recorder, that records and stores variational quantum programs.


An error raised with a quantum tape.

Class Inheritance Diagram

Inheritance diagram of pennylane.tape.operation_recorder.OperationRecorder, pennylane.tape.qscript.QuantumScript, pennylane.tape.tape.QuantumTape, pennylane.tape.tape.TapeError