In pennylane’s documentation you can find qml.purity
under qml.measurements.purity
, where you can return the purity of a density matrix directly like this:
dev = qml.device("default.mixed", wires=2)
@qml.qnode(dev)
def circuit_purity(p):
qml.Hadamard(wires=0)
qml.CNOT(wires=[0, 1])
qml.BitFlip(p, wires=0)
qml.BitFlip(p, wires=1)
return qml.purity(wires=[0,1])
However, looking at the latest version of pennylane, this function doesn’t seem to be available. Only pennylane.qinfo.transforms.purity()
and pennylane.math.purity()
seem to be available, which require to pass a qnode or a state.
Has it been deprecated?
Thanks.
Hi @diemilio, it’s quite the opposite!
You’re probably looking at the latest version of the documentation, which is the development version. This includes a new feature which is being able to the purity as your measurement .
Please let me know if you find any issues with this!
However you’re probably using the current stable version of PennyLane, v0.28, which doesn’t include this feature.
You could use the latest development version of PennyLane, or you could decide not to use this feature. We will release a new version of PennyLane on Tuesday so if this isn’t urgent you could wait until then too .
Ah! Got it! Thanks so much for the help
No problem @diemilio ! Let us know what you think of this feature. And remember to use v0.29.1