qml.enable_tape

enable_tape()[source]

Enable tape mode.

Tape mode is an experimental new mode of PennyLane. QNodes created in tape mode have support for in-QNode classical processing, differentiable quantum decompositions, returning the quantum state, less restrictive QNode signatures, and various other improvements.

For more details on tape mode, see pennylane.tape.

Example

Simply call this function at the beginning of your script or session.

>>> qml.enable_tape()

All subsequent QNodes will be created using tape mode, and can take advantage of the various tape mode features:

>>> dev = qml.device("default.qubit", wires=1)
>>> @qml.qnode(dev)
... def circuit(x, y):
...     qml.RX(np.sin(x) * y, wires=0)
...     return qml.expval(qml.PauliZ(0))
>>> print(circuit(0.5, 0.1))
0.9988509758748578
>>> qml.grad(circuit)(0.5, 0.1)
(array(-0.00420574), array(-0.02297608)))
>>> type(circuit)
pennylane.tape.qnode.QNode

Tape mode can be disabled by calling disable_tape().