qml.disable_return

disable_return()[source]

Function that turns off the new return type system.

Example

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

def circuit(x):
      qml.Hadamard(wires=[0])
      qml.CRX(x, wires=[0, 1])
      return qml.probs(wires=[0]), qml.vn_entropy(wires=[0]), qml.probs(wires=1), qml.expval(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
>>> qml.enable_return()
>>> res = qnode(0.5)
>>> res
(tensor([0.5, 0.5], requires_grad=True), tensor(0.08014815, requires_grad=True), tensor([0.96939564, 0.03060436], requires_grad=True), tensor(0.93879128, requires_grad=True))
>>> qml.disable_return()
>>> res = qnode(0.5)
>>> res
tensor([0.5       , 0.5       , 0.08014815, 0.96939564, 0.03060436, 0.93879128], requires_grad=True)

Contents

Using PennyLane

Development

API