How to use the 'sort_mpo_legs' feature

How do I use this algorithm? What does that parameter do?
Post Reply
kevln
Posts: 18
Joined: 12 May 2022, 07:02

How to use the 'sort_mpo_legs' feature

Post by kevln »

Hi,Johannes

When I was looking for sample code on github, I found https://github.com/ITensor/ITensorBench ... 1d_dmrg.py,which mentions the 'sort_mpo_legs' feature.

By studying the tenpy documentation, I think that 'sort_mpo_legs': True seems to be able to speed up the running speed of the code when computing complex models.

My question and confusion is: Take this example in tenpy documentation, https://tenpy.readthedocs.io/en/latest/ ... e_FCI.html, add 'sort_mpo_legs': True, in model_params
  • Does this approach speed up the code?
  • If code can be accelerated, is the effect significant enough?
  • Will it lead to greater memory overhead?
  • Is it recommended to always turn on 'sort_mpo_legs' in tenpy's calculations: True?
User avatar
Johannes
Site Admin
Posts: 428
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: How to use the 'sort_mpo_legs' feature

Post by Johannes »

The MPO tensors in W are sparse, and without the 'sort_mpo_legs': True, we try to capture that, resulting in fewer small blocks for tensordots involving a H.get_W(i) rather than bigger blocks (as dictated by charge conservation).
For this benchmark comparison, we wanted to compare "apples to apples" and tried to setup everything the same way for iTensor and TeNPy, hence we fixed sort_mpo_legs: True, because iTensor didn't have that sparse-H feater at that time (I'm not sure if they implemented it by now).

Wether it actually speeds things up depends very much on the details of the H you're using, and how much overhead you have from multiplying the multiple small blocks. For large blocks (i.e. high MPS bond dimensions) and sparse W in H, `sort_mpo_legs: False` should in principle be a bit faster than `sort_mpo_legs: True`, - but it really helps, or whether the overhead is more significant for what you want to do, you need to check yourself for your specific use-case. In practice, I don't think it makes a huge difference.

The memory usage should be roughly the same, independent of this option.
Post Reply