Fixing changebonds, some inconsistency remaining#415
Fixing changebonds, some inconsistency remaining#415LHerviou wants to merge 5 commits intoQuantumKitHub:mainfrom
Conversation
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
|
As a general comment, I feel like we are not super consistent about the role of |
|
If you want, I can go through the different changebonds functions to systematize it.
At least for infiniteMPS, we can make stuff consistent. |
lkdvos
left a comment
There was a problem hiding this comment.
Left some minor comments, but I definitely like that this is more principled with the inplace vs non-inplace functions.
| [Zauner-Stauber et al. Phys. Rev. B 97 (2018)](@cite zauner-stauber2018), by selecting the | ||
| dominant contributions of a two-site updated MPS tensor, orthogonal to the original ψ. | ||
|
|
||
| changedbonds! is only defined for FiniteMPS, and modify its environment. |
There was a problem hiding this comment.
| changedbonds! is only defined for FiniteMPS, and modify its environment. | |
| !!! note | |
| `changebonds!` is only defined for `FiniteMPS`, and modifies its environment. |
| distributed weights for each state in the two-site space and truncating that. | ||
|
|
||
| The environments are not used here. | ||
| changebonds! modify both the provided state and environments. |
There was a problem hiding this comment.
| changebonds! modify both the provided state and environments. | |
| `changebonds!` modifies both the provided state and environments. |
|
|
||
| newψ = _expand(ψ, AL′, AR′) | ||
| recalculate!(envs, newψ, H) | ||
| envs = environments(newψ, H) |
There was a problem hiding this comment.
I'm not entirely following this change. Is it not possible to overwrite the old environments?
There was a problem hiding this comment.
Ah, I think I see now what you intended: is it that the non-bang (!) functions shouldn't modify their inputs?
I can see that being a good choice, I think it is mostly that the envs are always kind of treated as a special thing that is modified everywhere.
I'm happy either way, I think you have a better feeling of what is convenient/efficient.
|
|
||
| newψ = _expand(ψ, AL′, AR′) | ||
| recalculate!(envs, newψ, H) | ||
| envs = environments(newψ, H) # recalculate!(envs, newψ, H) |
|
|
||
| An algorithm that uses a two-site update step to change the bond dimension of a state. | ||
|
|
||
| changedbonds! is not defined. |
There was a problem hiding this comment.
| changedbonds! is not defined. | |
| !!! note | |
| `changebonds!` is not defined. |
Following discussion with @lkdvos
Here is a small fix for some minor bugs I noticed in changebonds: for RandExpand or SvdCut, the returned environments were not updated after the update of the mps. Schematically, we had
newmps, oldenv = changebonds(oldmps, H, alg = ..., oldenv)
which made any groundstate algorithm failed.
Now the environments are updated such that
newmps, newenv = changebonds(oldmps, H, alg = ..., oldenv)
without touching oldmps or oldenv
Before accepting the update: there are some inconsistencies in the behavior of changebonds.
In particular, for OptimalExpand, env are directly modified in place, which makes oldenv not work with the old mps. Is it intended behavior for memory optimization? If so, I can reproduce a similar behavior for others. It should in any case be advertised.
I modified also slightly the converter between InfiniteMPOHamiltonian and InfiniteMPO which was only used by OptimalExpand. There is some unsafe looking environment update in it, though.
The test pass for FiniteMPS, though I did not investigate it as much. In particular, the environment update in OptimalExpand is hidden in the computation of AC2.
Finally, I added a constructor of the type FiniteMPS(Type, Space, Space) as the syntax works for infiniteMPS and not Finite, which was annoying me.
For reproduction: here is a script that fails before the PR, and pass afterwards: