Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QIM-5] Add mutual information function #2631

Merged
merged 269 commits into from
Jun 10, 2022
Merged

[QIM-5] Add mutual information function #2631

merged 269 commits into from
Jun 10, 2022

Conversation

eddddddy
Copy link
Contributor

@eddddddy eddddddy commented May 27, 2022

Context:
Part of the ongoing effort to support quantum information computations in PennyLane.

Description of the Change:
Add support for mutual information. Three separate functions are implemented. One is in qml.math and takes as input a state vector or a density matrix:

>>> state = np.array([1, 0, 0, 1])
>>> qml.math.to_mutual_info(state, indices0=[0], indices1=[1])
1.3862943611198906

The second is in qml.qinfo and is a QNode transform:

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

@qml.qnode(dev)
def circuit(x):
    qml.RY(x, wires=[0])
    qml.CNOT(wires=[0, 1])
    return qml.state()
>>> x = np.array(0.5)
>>> mutual_info_qnode = qml.qinfo.mutual_info_transform(circuit, [0], [1])
>>> mutual_info_qnode(x)
0.46056096825956955

The last is a measurement process that returns the mutual information of a circuit:

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

@qml.qnode(dev)
def circuit(x):
    qml.RY(x, wires=[0])
    qml.CNOT(wires=[0, 1])
    return qml.mutual_info(wires0=[0], wires1=[1])
>>> x = np.array(0.5)
>>> circuit(x)
tensor(0.46056097, requires_grad=True)

Benefits:

PennyLane now supports computation of mutual information

Possible Drawbacks:

Related GitHub Issues:

Base automatically changed from entropy to master June 10, 2022 06:37
@rmoyard rmoyard merged commit 8435c2c into master Jun 10, 2022
@rmoyard rmoyard deleted the mutual_information branch June 10, 2022 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants