Fixing changebonds, some inconsistency remaining#415
Fixing changebonds, some inconsistency remaining#415lkdvos merged 6 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.
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: