Skip to content

Revised Belief Propagation #26

Open
jack-dunham wants to merge 68 commits intoITensor:mainfrom
jack-dunham:bp
Open

Revised Belief Propagation #26
jack-dunham wants to merge 68 commits intoITensor:mainfrom
jack-dunham:bp

Conversation

@jack-dunham
Copy link
Copy Markdown
Contributor

@jack-dunham jack-dunham commented Nov 25, 2025

This PR express belief propagation in terms of the new interface based on AlgorithmsInterface.jl and the included AlgorithmsInterfaceExtensions.jl library.

JoeyT1994 and others added 29 commits January 6, 2026 09:55
Introduce `BeliefPropagationProblem` wrapper to hold the cache and the
error `diff` field.

Also simplifies some kwargs wrangling.
Also includes some fixes to the way `TensorNetwork` types are
constructed based on index structure.
…instead of trying to operate on existing graphs

The reason for this is:
- One only cares about the edges of the input graph
- A simple graph cannot be used as it "forgets" its edge names resulting
in recursion
- As shown with `TensorNetwork`, removing edges may not always be
defined.
This was caused by the change to the `cache` being backed by a directed
graph.
Comment thread src/LazyNamedDimsArrays/symbolicnameddimsarray.jl Outdated
Comment thread src/beliefpropagation/abstractbeliefpropagationcache.jl Outdated
Comment thread src/beliefpropagation/abstractbeliefpropagationcache.jl Outdated
Comment thread src/AlgorithmsInterfaceExtensions/AlgorithmsInterfaceExtensions.jl
@mtfishman
Copy link
Copy Markdown
Member

@jack-dunham can you resolve comments that you've addressed so it is easier to track what remains? Also can you rebase on main and format to get tests running cleanly?

An `AbstractTensorNetwork` has edge type `Nothing`, which can be
obtained from the `AbstractDataGraph` method.
@mtfishman mtfishman dismissed JoeyT1994’s stale review April 28, 2026 14:52

Joey's requests mostly complete as far as I know.


abstract type AbstractBeliefPropagationCache{V, VD, ED} <: AbstractDataGraph{V, VD, ED} end

factor_type(bpc::AbstractBeliefPropagationCache) = typeof(bpc)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
factor_type(bpc::AbstractBeliefPropagationCache) = typeof(bpc)
factor_type(bpc::AbstractBeliefPropagationCache) = factor_type(typeof(bpc))

Can you add a regression test for that (and related functions that don't have tests)?

bpc = new{V, VD, ED, E, typeof(digraph)}(digraph, factors, messages)

for edge in edges(bpc)
get!(() -> default_message(bpc, edge), messages, edge)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems bad, doesn't this modify the input messages in-place?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess our plan is to get rid of default_message anyway so this constructor will change accordingly, hopefully we can just remove this entirely. Probably then we can then just use the default constructor and not define an inner constructor.

Comment on lines +14 to +15
factors::Dictionary{V, VD}
messages::Dictionary{E, ED}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe for simplicity we could use Dict here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine either way, it should mostly be an implementation detail. Just curious to hear your thoughts on that.

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