Skip to content

Dispatch belief-propagation message updates on NormNetwork - #157

Merged
mtfishman merged 8 commits into
mainfrom
mf/normnetwork-message-dispatch
Jul 28, 2026
Merged

Dispatch belief-propagation message updates on NormNetwork#157
mtfishman merged 8 commits into
mainfrom
mf/normnetwork-message-dispatch

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 28, 2026

Copy link
Copy Markdown
Member

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 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 while the entrywise sum is basis dependent.

vertex_scalar and edge_scalar also handle operator-valued messages, 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.

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

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.79%. Comparing base (839cafb) to head (3ecad66).

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     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

`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.
@mtfishman
mtfishman merged commit 4b43b57 into main Jul 28, 2026
18 checks passed
@mtfishman
mtfishman deleted the mf/normnetwork-message-dispatch branch July 28, 2026 15:30
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.

1 participant