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

Fill ITensor with zeros if empty after contracting with ProjTTN. #130

Closed
wants to merge 1 commit into from

Conversation

b-kloss
Copy link
Contributor

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

This PR ensures that the result of a ProjTTN to ITensor contraction always results in an ITensor with the same flux and the allowed blocks densely filled.
Lack of this edit leads to instability of KrylovKit.exponentiate when used on product states of fermionic systems with regions where the action of the projected Hamiltonian on the state vanishes. There may be more appropriate fixes to this at the ITensors level, if this PR is not compatible with planned changes to the ITensors storage.

@b-kloss b-kloss changed the title Populate ITensor with zeros if empty after contracting with ProjTTN. Fill ITensor with zeros if empty after contracting with ProjTTN. Jan 25, 2024
@codecov-commenter
Copy link

Codecov Report

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

Comparison is base (56fcb93) 72.90% compared to head (1ef03c5) 72.87%.

Files Patch % Lines
src/treetensornetworks/projttns/abstractprojttn.jl 33.33% 2 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
- Coverage   72.90%   72.87%   -0.03%     
==========================================
  Files          71       71              
  Lines        4097     4100       +3     
==========================================
+ Hits         2987     2988       +1     
- Misses       1110     1112       +2     

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

@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 25, 2024

This also only works for ProjTTN of an operator with vanishing flux. The cleaner way would be to compute the flux of the environment in order to compute the flux of the tensor resulting from the contraction, allocate the resulting tensor filled with zeros, and in-place add the actual result of the contraction into it (all inside the if clause).

@mtfishman
Copy link
Member

mtfishman commented Jan 25, 2024

@b-kloss could you explain this a bit more? Under what situation does isempty(Hv) return true, and when that happens, what is the type, block structure, etc. of the storage of Hv? I think that would help to determine a fix to use.

@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 25, 2024

This happens in the very first call to PH(phi) in from KrylovKit.exponentiate when the action of the projected Hamiltonian on the state vanishes. E.g. in a region of a product state that's inert under the local Hamiltonian, let's say a single domain wall initial condition for a tight-binding model in 1D on an MPS, more than two sites away from the domain-wall. If it's helpful I can include a minimal example of 2-site TDVP for fermionic systems with autofermion sign where this happens.

Hv = ITensor ord=2
Dim 1: (dim=1|id=867|"19,20")' <Out>
 1: QN("Nf",10,-1) => 1
Dim 2: (dim=2|id=441|"Fermion,Site,n=20")' <Out>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
NDTensors.BlockSparse{Float64, Vector{Float64}, 2}
 1×2

storage(Hv) = Float64[]
Hv = ITensor ord=2
nzblocks(Hv) = Block{2}[]

@mtfishman
Copy link
Member

mtfishman commented Jan 26, 2024

Superseded by #1318, so I'll close this.

@mtfishman mtfishman closed this Jan 26, 2024
@b-kloss b-kloss deleted the fix-projttn branch February 2, 2024 19:31
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