Skip to content

Refactor entropy function to also use spectrum directly#377

Merged
lkdvos merged 4 commits intoQuantumKitHub:mainfrom
AFeuerpfeil:pr-entanglement_spectrum
Feb 23, 2026
Merged

Refactor entropy function to also use spectrum directly#377
lkdvos merged 4 commits intoQuantumKitHub:mainfrom
AFeuerpfeil:pr-entanglement_spectrum

Conversation

@AFeuerpfeil
Copy link
Copy Markdown
Contributor

In this PR, I add the functionality to directly supply the entanglement spectrum obtained from e.g. entanglement_spectrum(psi, loc) to calculate the von Neumann entropy.

Copilot AI review requested due to automatic review settings February 9, 2026 20:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the entanglement entropy computation to allow calling entropy directly on a precomputed entanglement spectrum (e.g. the result of entanglement_spectrum(psi, loc)), instead of always recomputing the spectrum from the MPS.

Changes:

  • Refactor entropy(state, loc) to delegate to a new entropy(spectrum) overload.
  • Add entropy(spectrum::AbstractVector{T}) implementation that computes von Neumann entropy from the provided spectrum.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/algorithms/toolbox.jl Outdated
Comment thread src/algorithms/toolbox.jl
Comment on lines +10 to +13
return entropy(entanglement_spectrum(state, loc))
end
function entropy(spectrum::AbstractVector{T}) where {T}
S = zero(T)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The docstring above still documents only entropy(state, [site::Int]), but this PR introduces a new public overload entropy(spectrum). Please update the docstring/signature section to mention the spectrum form and clarify what spectrum structure is expected (sectorized vs plain vector).

Copilot uses AI. Check for mistakes.
Comment thread src/algorithms/toolbox.jl Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/algorithms/toolbox.jl 96.50% <100.00%> (+1.35%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos
Copy link
Copy Markdown
Member

lkdvos commented Feb 9, 2026

Did you request the copilot review or is this another one of these Microsoft deciding to make all of their bullshit opt-out instead of opt-in all of a sudden again?

@AFeuerpfeil
Copy link
Copy Markdown
Contributor Author

AFeuerpfeil commented Feb 9, 2026

I did not request anything.
Let me check my settings. Maybe I still have this auto-review on.
PS: Indeed, the auto-review setting was on.

@lkdvos
Copy link
Copy Markdown
Member

lkdvos commented Feb 9, 2026

Ok, no worries I'm not against this, I would have just been pretty pissed off if Github all of a sudden would decide to just auto comment on all PRs with copilot.

(also, the suggestions are actually not bad 😉 )

@lkdvos lkdvos force-pushed the pr-entanglement_spectrum branch 2 times, most recently from a0ee44c to abea721 Compare February 23, 2026 15:42
@lkdvos
Copy link
Copy Markdown
Member

lkdvos commented Feb 23, 2026

Will let the tests finish here first, then rebase, update the docstring and merge.

@lkdvos lkdvos force-pushed the pr-entanglement_spectrum branch from abea721 to 244f16b Compare February 23, 2026 18:45
@lkdvos lkdvos merged commit 0b58b84 into QuantumKitHub:main Feb 23, 2026
28 of 33 checks passed
lkdvos added a commit that referenced this pull request Feb 23, 2026
* Refactor entropy function to also use spectrum directly

* specialize to SectorVector and add test

* add infinite test

* update docstring

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>
lkdvos added a commit that referenced this pull request Feb 24, 2026
* Refactor entropy function to also use spectrum directly

* specialize to SectorVector and add test

* add infinite test

* update docstring

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>
lkdvos added a commit that referenced this pull request Feb 24, 2026
* Revert "Adapt extension (#384)"

This reverts commit 2db4cb1.

* Deep copying MPS with copy (#387)

* broadcast copy over arrays

* add basic tests for copying mps

* fix variable naming mismatch

* small fixes

* format

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>

* Refactor entropy function to also use spectrum directly (#377)

* Refactor entropy function to also use spectrum directly

* specialize to SectorVector and add test

* add infinite test

* update docstring

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>

* Deep copying MPS with copy (#387)

* broadcast copy over arrays

* add basic tests for copying mps

* fix variable naming mismatch

* small fixes

* format

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>

* fix wrong testcase

* alter JordanMPOTensor Adapt implementation

* type stability chenanigans

* bump TensorKit minimal version

* more bypassing of type stability issues...

* fix some tests

* lost of git struggles

* more git misery!

* handle storagetype better

* disable lts type stability tests

---------

Co-authored-by: Akshay Shankar <sakshays.2000@gmail.com>
Co-authored-by: Andreas Feuerpfeil <andreas.feuerpfeil@gmail.com>
@lkdvos lkdvos mentioned this pull request Feb 26, 2026
lkdvos referenced this pull request Feb 26, 2026
* update compat to remove broken versions

* update changelog

* update citation file

* update changelog for release
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