Dispatch belief-propagation message updates on NormNetwork - #157
Merged
Conversation
Dispatches belief-propagation message updates on the factor-graph type so operator-valued messages are preserved end to end. Belief propagation on a `NormNetwork` (the doubled ⟨ψ|ψ⟩ network) produces bond operators pairing a ket leg with a bra leg. The previous `message_update!` recovered that structure by inspecting each message's type inline. Now the generic method contracts into a plain bond vector normalized by its entrywise sum, and a `NormNetwork` method re-wraps the contraction as an operator carrying the network's own ket/bra link names and normalizes by the trace, which is sign-correct on fermionic bonds where the entrywise sum can flip the odd-parity block's sign. `vertex_scalar` and `edge_scalar` unwrap operator messages before contracting, so `bethe_free_energy` works on them too. Adds a belief-propagation test on a norm network over U1 and fermion-parity sites, checking that the converged messages keep their operator structure and that belief propagation stays exact on a tree.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
==========================================
+ Coverage 84.43% 84.79% +0.36%
==========================================
Files 15 15
Lines 681 684 +3
==========================================
+ Hits 575 580 +5
+ Misses 106 104 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`edge_scalar` is a single binary contraction, so it uses `*` directly instead of `contract_network`. Binary `*` dispatches through the operator product, so operator-valued messages contract to a scalar without unwrapping, preserving operators. `vertex_scalar` is N-ary and still routes through `contract_network`, whose lazy path only accepts plain operands, so it keeps the `state` unwrap for now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dispatches belief-propagation message updates on the factor-graph type so operator-valued messages are preserved end to end. Belief propagation on a
NormNetwork(the doubled ⟨ψ|ψ⟩ network) produces bond operators pairing a ket leg with a bra leg. The previousmessage_update!recovered that structure by inspecting each message's type inline. Now the generic method contracts into a plain bond vector normalized by its entrywise sum, and aNormNetworkmethod re-wraps the contraction as an operator carrying the network's own ket/bra link names and normalizes by the trace, which is sign-correct on fermionic bonds while the entrywise sum is basis dependent.vertex_scalarandedge_scalaralso handle operator-valued messages, sobethe_free_energyworks on them too.Adds a belief-propagation test on a norm network over U1 and fermion-parity sites, checking that the converged messages keep their operator structure and that belief propagation stays exact on a tree.