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.

  • 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.


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]


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

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

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)
>>> x = np.array(0.4, requires_grad=True)
>>> mutual_info_circuit(x)
>>> qml.grad(mutual_info_circuit)(np.array(0.4, requires_grad=True))
tensor(1.24300677, requires_grad=True)