Skip to content

Clean up belief propagation #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Feb 7, 2023
Merged

Conversation

JoeyT1994
Copy link
Contributor

This PR introduces significant improvements to the Belief Propagation code within ITensorNetworks.jl

  1. beliefpropagation.jl is now completely network agnostic and will simply form message tensors, update them etc... independent of the actual network geometry. All partitioning is handled by the recently added partition.jl interface.
  2. beliefpropagation.jl has had the overly specific expectation value functions removed. Instead these have been replaced by get_environment and calculate_contraction -> which are more general and the workhorses of those functions anyway.
  3. The testing and belief propagation example have been updated to reflect these changes.
  4. A catch has been added to subgraph_vertices in partition.jl, which checks if the number of partitions required is 1 (both KaHyPar and Metis error in this case --- although the issue has been raised and is being fixed).
  5. A function unwrap_graph_vertices has been added to partition.jl which recursively goes through a datagraph and fetches all the vertex data within each vertex.
  6. A function split_index has been added to abstractitensornetwork.jl which splits a series of indexes in a given itensornetwork and applies the users choice of mapping to them.

@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2023

Codecov Report

Merging #57 (4096a77) into main (e5213e5) will decrease coverage by 0.22%.
The diff coverage is 93.18%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
- Coverage   77.94%   77.73%   -0.22%     
==========================================
  Files          55       55              
  Lines        2916     2834      -82     
==========================================
- Hits         2273     2203      -70     
+ Misses        643      631      -12     
Impacted Files Coverage Δ
src/partition.jl 84.61% <88.23%> (+0.61%) ⬆️
src/beliefpropagation.jl 93.44% <94.73%> (+3.62%) ⬆️
src/abstractitensornetwork.jl 82.44% <100.00%> (+0.62%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mtfishman
Copy link
Member

mtfishman commented Feb 2, 2023

Still to do:

  • Rename unwrap_graph_vertices to nested_graph_leaf_vertices, implement in terms of hasmethod(vertices, Tuple{...}) to determine the leaf graphs.
  • Improve partition interface to allow for keyword arguments nvertices_per_partition or vertex_groups.
  • Remove assert_correct_environment, plan to just use set functions proposed in Define set operations for external indices of tensor networks #58.

Looking at it more closely, I think a function like calculate_contraction is useful. I would think about tweaking the interface a bit but let's keep as-is for now.

@JoeyT1994
Copy link
Contributor Author

Note I also ran this branch through JuliaFormatter hence why lots of files appear changed (should just be formatting)

@mtfishman
Copy link
Member

@JoeyT1994 I formatted the package in #61. Could you merge those changes? Hopefully then this PR will only show your own changes and not the formatting changes as well.

@JoeyT1994
Copy link
Contributor Author

@JoeyT1994 I formatted the package in #61. Could you merge those changes? Hopefully then this PR will only show your own changes and not the formatting changes as well.

Great, yes I have done that merge.

@mtfishman mtfishman merged commit 3df4c84 into ITensor:main Feb 7, 2023
@mtfishman mtfishman changed the title Belief propagation v2 Clean up belief propagation Feb 7, 2023
@JoeyT1994 JoeyT1994 deleted the BeliefPropagationV2 branch February 7, 2023 21:54
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