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

Add density matrix and entanglement calculations for qubits #203

Merged
merged 9 commits into from
Jul 30, 2024

Conversation

madcpf
Copy link
Collaborator

@madcpf madcpf commented Jul 20, 2024

  • Add a method in quantum world to calculate density matrix of given quantum objects (only qubits are supported now);
  • Based on that method, add another method in quantum world to calculate quantum mutual information of two specified qubits. The calculation is based on https://en.wikipedia.org/wiki/Quantum_mutual_information.

@madcpf madcpf requested a review from dstrain115 July 20, 2024 07:00
@madcpf madcpf marked this pull request as draft July 20, 2024 07:00
@dstrain115
Copy link
Collaborator

I have some concerns about this PR. First, this is explicitly using a different sampler than the one provided the user as part of QuantumWorld. Second, it is using the density matrix, which is non-physical, so this will not work if the user is using a hardware device (or rather, it will use a simulator).

Is it possible to change the partial traces in this entanglement measure to be measurements instead? Then, this would work for both hardware and simulation, and would not rely on the density matrix or a specific simulator.

@cognigami
Copy link
Collaborator

cognigami commented Jul 22, 2024 via email

@dstrain115
Copy link
Collaborator

My poor understanding is that this feature is meant to provide an guesstimate of entanglement, so I'm not sure that your (otherwise spot on) concerns matter to the output.

But we should be able to get a guesstimate of the entanglement from measurements instead of the density matrix, and, if we can do simply, we should.

@cognigami
Copy link
Collaborator

cognigami commented Jul 22, 2024 via email

@madcpf
Copy link
Collaborator Author

madcpf commented Jul 22, 2024

Thanks Doug and cognigami for the input! Please take a look at the updated version, which moves away from DensityMatrixSimulator.

@madcpf madcpf marked this pull request as ready for review July 22, 2024 21:51
def density_matrix(
self, objects: Optional[Sequence[QuantumObject]] = None, count: int = 1000
) -> np.ndarray:
"""Simulates the density matrix of the given objects.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the description here and then add some details about how we are assuming that this is a pure state so the density matrix is |psi><psi|

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

@madcpf madcpf merged commit 122b8e0 into quantumlib:main Jul 30, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants