qml.qinfo.transforms.mutual_info

mutual_info(tape, wires0, wires1, base=None, **kwargs)[source]

Compute the mutual information from a QuantumTape returning a state():

\[I(A, B) = S(\rho^A) + S(\rho^B) - S(\rho^{AB})\]

where \(S\) is the von Neumann entropy.

The mutual information is a measure of correlation between two subsystems. More specifically, it quantifies the amount of information obtained about one system by measuring the other system.

Warning

The qml.qinfo.mutual_info transform is deprecated and will be removed in v0.40. Instead, include the pennylane.mutual_info() measurement process in the return line of your QNode.

Parameters
  • qnode (QNode or QuantumTape or Callable) – A quantum circuit returning a state().

  • wires0 (Sequence(int)) – List of wires in the first subsystem.

  • wires1 (Sequence(int)) – List of wires in the second subsystem.

  • base (float) – Base for the logarithm. If None, the natural logarithm is used.

Returns

The transformed circuit as described in qml.transform. Executing this circuit will provide the mutual information in the form of a tensor.

Return type

qnode (QNode) or quantum function (Callable) or tuple[List[QuantumTape], function]

Example

It is possible to obtain the mutual information of two subsystems from a QNode returning a state().

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

@qml.qnode(dev)
def circuit(x):
    qml.IsingXX(x, wires=[0, 1])
    return qml.state()
>>> mutual_info_circuit = qinfo.mutual_info(circuit, wires0=[0], wires1=[1])
>>> mutual_info_circuit(np.pi/2)
1.3862943611198906
>>> x = np.array(0.4, requires_grad=True)
>>> mutual_info_circuit(x)
0.3325090393262875
>>> qml.grad(mutual_info_circuit)(np.array(0.4, requires_grad=True))
tensor(1.24300677, requires_grad=True)