Skip to content

Add fermionic support to belief-propagation simple update#155

Merged
mtfishman merged 13 commits into
mainfrom
mf/fermion-bp-sign
Jul 24, 2026
Merged

Add fermionic support to belief-propagation simple update#155
mtfishman merged 13 commits into
mainfrom
mf/fermion-bp-sign

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Adds fermionic support to the belief-propagation simple-update apply-gate (apply_operators). The odd-parity sign on a fermionic bond needs care in the gauge. Each directed message is built as the doubled contraction of the gate factor with its conjugate, which carries the sign, and the gauge roots each message in the bipartition where it is positive semidefinite. The bosonic path is unchanged.

The apply tests cover FermionParity sites alongside the bosonic ranges, carrying the belief-propagation environment through the gate applications rather than rebuilding it from scratch. Convergence of the message passing stays covered by the belief-propagation tests. The test environment requires GradedArrays 0.14, whose graded square-root path is sign-correct for fermions where 0.13 throws.

mtfishman and others added 3 commits July 21, 2026 17:32
Keep belief-propagation messages as operators and normalize them by their trace rather than an entrywise sum, which stays sign correct on fermionic bonds where the entrywise sum can flip the odd-parity block. Gauge the simple-update tensors with the balanced square root and inverse square root of the Hermitian-projected bond messages.

Depends on the operator-form Hermitian factorizations added in the ITensorBase mf/operator-sqrth branch.
The BP simple-update gauge absorbs an operator-valued square root of each incoming message into the state tensor. Contracting it with `*` returns an operator, so the updated state is written back as an operator and rejected by the state network. Take the underlying tensor of each gauge (`ITB.state`) before contracting, so the gauged state stays a plain tensor while the index arrows still carry the fermion sign. Requires the operator `dimnametype` fix from ITensor/ITensorBase.jl#225.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Store both directed messages of a bond uniformly as the bond (ket output) and
an auxiliary leg (bra input), with conj(S)/S into the two endpoints, and build
the initial identity messages on the source-side ket axis so their ket leg is
dual to the destination bond. The gauge projects the message Hermitian and takes
the balanced square-root / inverse-square-root in whichever bipartition is
positive semidefinite, which recovers the odd-parity fermion sign in both
directions. Migrate the message-update path to the ITensorBase 0.13
outputnames/inputnames API and bump to 0.9.10.
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.87097% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.43%. Comparing base (fd57853) to head (8701d0e).

Files with missing lines Patch % Lines
src/apply/apply_operators.jl 81.81% 4 Missing ⚠️
src/beliefpropagation/beliefpropagation.jl 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
- Coverage   84.89%   84.43%   -0.46%     
==========================================
  Files          15       15              
  Lines         662      681      +19     
==========================================
+ Hits          562      575      +13     
- Misses        100      106       +6     
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.

mtfishman and others added 3 commits July 22, 2026 11:01
Replace the try/catch PSD-bipartition selection in `message_gauge` with a
plain transposed gauge. The two directed bond messages are now built from the
PSD singular-value message `conj(S)`. The reverse direction is its arrow flip
via `dualize`, which toggles `isdual` and keeps the odd-parity block, rather
than `conj`, which negates the odd block and breaks PSD. Free-fermion
validation is exact to machine precision on trees with no fallback.

`dualize` is a temporary element-wise hack that pulls in a temporary
`GradedArrays` dependency. Both stand in for a proper backend-agnostic
duality-flip primitive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The reverse directed message is S with its bond orientation reversed,
which is the ribbon twist of S (-1 on the odd-parity sector). Both
directed messages are then positive semidefinite in the transposed
gauge, so the gauge needs no fallback. This replaces the element-wise
dualize helper with a name-keyed twist and twist!.

Also simplify the belief-propagation message unwrap to state.(messages),
relying on state being idempotent.
@mtfishman
mtfishman force-pushed the mf/fermion-bp-sign branch from 03f6abd to 0f0ec76 Compare July 24, 2026 17:36
…n twist

Each directed simple-update message is now the doubled contraction of the gate
factor with its conjugate, rather than being read off the singular-value spectrum
as conj(S) and a ribbon-twisted S. The graded contraction of a factor with its
conjugate carries the odd-parity fermion sign on its own, so the explicit ribbon
twist (and the direct GradedArrays dependency it needed) is gone.
@mtfishman
mtfishman force-pushed the mf/fermion-bp-sign branch from 0f0ec76 to 8d169d4 Compare July 24, 2026 17:38
mtfishman and others added 6 commits July 24, 2026 14:44
Build the message gauge and its inverse explicitly from `eigh_full` as
`v * √d * v'` and `v * √d⁻¹ * v'`, rather than calling `sqrth_invsqrth_safe`,
so the mechanism handling the odd-parity bipartition is visible in place.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`src/` no longer references GradedArrays directly, so remove it from the
package dependencies. It remains available transitively and in the test
project, where it is still used.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the narration of the leg relabeling and the unclear claim about where
the sign lands, keeping only the reason for the transposed bipartition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Record in the comment that `v * √d * v'` is used because it works with
fermions, and that the asymmetric `√d * v'` gauge has an issue still under
investigation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The single-site normalization only needs the message square root, not its
inverse, so `first(message_gauge(...))` built and discarded the inverse root.
Factor the shared eigendecomposition into `message_eigen` and add
`message_root`, which the single-site path now calls. `message_gauge` still
returns the root together with its inverse for the two-site split.
Cover `FermionParity` sites alongside the bosonic ranges. The apply tests now
carry the belief-propagation environment through the gate applications, as real
usage does, instead of rebuilding it from `beliefpropagation` and re-wrapping
the messages with a test helper. Belief-propagation convergence is covered by
`test_beliefpropagation.jl`. This needs GradedArrays 0.14, whose graded
square-root path is sign-correct for fermions where 0.13 throws.
@mtfishman mtfishman changed the title [WIP] Add fermionic support to belief-propagation simple update Add fermionic support to belief-propagation simple update Jul 24, 2026
@mtfishman
mtfishman marked this pull request as ready for review July 24, 2026 21:37
@mtfishman
mtfishman merged commit 839cafb into main Jul 24, 2026
23 of 28 checks passed
@mtfishman
mtfishman deleted the mf/fermion-bp-sign branch July 24, 2026 22:06
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