Skip to content
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

Fix mutation behavior of position #131

Merged
merged 15 commits into from
Jan 31, 2024
Merged

Conversation

b-kloss
Copy link
Contributor

@b-kloss b-kloss commented Jan 26, 2024

This PR makes position(pos, PH) not mutate PH::AbstractProjTTN. Non-mutating versions of make_environment are also implemented for the concrete subtypes. Additionally, copy is implemented for the concrete types using copy_values_keys on PH.enviroments to provide copy safety (not entirely necessary if only in-place version is kept) and the original implementation renamed to unsafe_copy.
A test example verifying copy safety is provided (the original implementation was not copy-safe due to
andyferris/Dictionaries.jl#98) .

ToDo:

  • bring copy_keys_values into namespace
  • test whether it makes sense to keep out-of-place version for performance?
  • add test for out-place version if kept
  • also modify ProjTTNSum ?

@mtfishman mtfishman changed the title Make position copy safe. Fix mutation behavior of position Jan 26, 2024
@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 26, 2024

Any idea why the test was canceled?
image

@mtfishman
Copy link
Member

Any idea why the test was canceled?

No idea, could just be an issue on Github's side. We can try restarting them.

@mtfishman
Copy link
Member

Seems like we could change all uses of ::TTN to ::AbstractTTN to make it more general.

@mtfishman
Copy link
Member

I think overall the new code is definitely an improvement, but needs a cleanup and style improvements based on my comments.

@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2024

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (56fcb93) 72.90% compared to head (887d913) 72.87%.
Report is 3 commits behind head on main.

Files Patch % Lines
src/treetensornetworks/projttns/abstractprojttn.jl 63.33% 11 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #131      +/-   ##
==========================================
- Coverage   72.90%   72.87%   -0.03%     
==========================================
  Files          71       68       -3     
  Lines        4097     3982     -115     
==========================================
- Hits         2987     2902      -85     
+ Misses       1110     1080      -30     

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

src/ITensorNetworks.jl Outdated Show resolved Hide resolved
src/ITensorNetworks.jl Outdated Show resolved Hide resolved
@mtfishman
Copy link
Member

Looks good, thanks @b-kloss. This kind of cleanup/refactor will help when generalizing to loopy graphs with BP (@JoeyT1994).

@mtfishman mtfishman merged commit cf59738 into ITensor:main Jan 31, 2024
7 of 11 checks passed
@b-kloss b-kloss deleted the oop-position branch February 2, 2024 19:32
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