add Mutual Information I(a, b)#338
Conversation
entanglement.jlentanglement.jl
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #338 +/- ##
==========================================
- Coverage 83.48% 83.47% -0.02%
==========================================
Files 72 72
Lines 4802 4834 +32
==========================================
+ Hits 4009 4035 +26
- Misses 793 799 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Krastanov
left a comment
There was a problem hiding this comment.
thanks, this is an interesting addition. I left a few comments in.
86d5c0a to
f88334b
Compare
Krastanov
left a comment
There was a problem hiding this comment.
This looks pretty good.
Apologies for not prioritizing this style of PRs -- you have a lot and I have tried to address the higher value ones first, whenever I have time.
I left a few comments in, mainly motivated by the needs of some other parts of the ecosystem that we try to coordinate with.
| # Group theory tools | ||
| groupify, minimal_generating_set, pauligroup, normalizer, centralizer, contractor, delete_columns, | ||
| # Clipped Gauge | ||
| canonicalize_clip!, bigram, entanglement_entropy, |
There was a problem hiding this comment.
let's not export it as this is something we would want to synchronize with QuantumInterface
Could you post an issue at https://github.com/qojulia/QuantumInterface.jl/ describing the need for a new generic function and referencing this PR. The goal would be to pick a name that can be reused by other packages.
In the meantime, keeping this unexported will let us merge this PR without waiting for that coordination.
src/entanglement.jl
Outdated
| `B(𝒢) ≡ {(𝓁(g₁),𝓇(g₁)),…,(𝓁(gₙ),𝓇(gₙ))}` | ||
|
|
||
| The clipped gauge `𝒢` is a specific choice of stabilizer state where exactly two stabilizer endpoints exist at each site, | ||
| ensuring `ρₗ(x) + ρᵣ(x) = 2` for all sites `x` where `ρ` represents the reduced density matrix for the subsystem under |
There was a problem hiding this comment.
That sentence is unclear to me. How can two density matrices sum up to be the scalar 2?
There was a problem hiding this comment.
Thank you for helpful comment! I will correct this documentation mistake.
test/test_entanglement.jl
Outdated
| @test entanglement_entropy(copy(s), subsystem, Val(:rref))==2 | ||
| end | ||
|
|
||
| @testset "Mutual information for Clifford circuits" begin |
There was a problem hiding this comment.
additional tests that use QuantumOptics to double check the results independently would be very valuable
There was a problem hiding this comment.
Thank you for this very cool suggestion! I will use stuff from QuantumOpticsBase to complete this suggestion!
entanglement.jlentanglement.jl
entanglement.jl|
Please help review this PR, thank you! My apologies for the delay in adding code review suggestions. I had initially planned to work on the generalized code paper for some time, but I got caught up in them as they seemed quite exciting to read. Thank you so much for your helpful suggestions! I especially found the suggestion to add There is now warning that |
Krastanov
left a comment
There was a problem hiding this comment.
- the addition to docs are great
- the new capability is definitely very useful
- the tests for it are great
Couple of notes to double check:
- the suggested commit simplifies things a bit, but now we need to see what type of error it raises if we try to use
:clip - making a default does not need kwargs... You can just do
mutual_information(state::..., rangea::..., rangeb::...) = mutual_information(state, rangea, rangeb, Val{:rref}()) - why did the test fail to catch the mistake with union of ranges with a large gap between them? Is something missing from the tests
Last thing, let's add mutual_information to QuantumInterface.jl and import it here (just make a very small PR to QuantumInterface, bump the version number, add changelog, and it will get merged pretty quickly)
…on-contiguous ranges in with by throwing error as clip has unitrange, so valid only for contiguous regions that don't wrap around
Thank you so much for your insights! I’ve fixed an issue where the tests weren’t properly checking for large gaps in the system. The clipped gauge now ensures stabilizers have well-defined left/right endpoints, and the entanglement entropy calculation now correctly errors when non-contiguous regions (e.g., subsystem_rangeA = 1:2, subsystem_rangeB = 5:6) are provided. Additionally, I addressed the out-of-memory errors by using more moderate system sizes, as ket{} becomes computationally expensive for larger systems. The previous implementation was faulty. My bad 🙏🏼 |
|
I have not had a chance to look into this one for a while. Could you let me know whether there is any bitrot and whether we can restart the attempt to merge it. That would require you to re-review your old work before we can proceed. Marking it as a draft for now, but feel free to convert to non-draft when ready for review. |
This PR aims to introduce Mutual Information
I(A,B)along with improving the doctests and documentation in theentanglement.jl.In the future, if you like, it would be better to have a entanglement introduced in the manual of either "algebra" or upcoming "circuit simulation" manual.
In the papers, there were many graphs, I think based on entanglement entropy that could be reproduced in a tutorial fashion. Hopefully, this sounds interesting.
....
If you want to submit an unfinished piece of work in order to get comments and discuss, please mark the pull request as a draft and ping the repository maintainer.
Please address only one topic or issue per pull request! Many small PRs are much easier to review and merge than one large PR.
Before merging, all changes and new functionality should be marked in the CHANGELOG file, but feel free to just leave your CHANGELOG notes in the PR description, to avoid merge conflicts with other requests modifying that file. The maintainer will add these CHANGELOG notes for you if you do so.
Before considering your pull request ready for review and merging make sure that all of the following are completed (please keep the clecklist as part of your PR):
If possible, keep your git history not too wild (rebase and squash commits, keep commits small and semantically separated) so that review is easier.