Skip to content

[New] Finite temperature utilities + docs example#262

Merged
lkdvos merged 19 commits intomasterfrom
densitymatrices
Mar 18, 2025
Merged

[New] Finite temperature utilities + docs example#262
lkdvos merged 19 commits intomasterfrom
densitymatrices

Conversation

@lkdvos
Copy link
Copy Markdown
Member

@lkdvos lkdvos commented Mar 14, 2025

Here, I added some additional support for working with DMRG and TDVP for density matrices. I added a rudimentary example to show off the abilities, which could do with a lot of cleanup but I am running out of reasonable time to spend on this.

I'd be okay with merging this as is and finishing it up later, unless someone wants to go for it now.

@lkdvos lkdvos requested a review from leburgel March 14, 2025 20:11
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
src/algorithms/derivatives.jl 81.96% <100.00%> (+0.61%) ⬆️
src/algorithms/toolbox.jl 95.04% <100.00%> (+0.11%) ⬆️
src/operators/mpo.jl 90.72% <100.00%> (+0.72%) ⬆️
src/transfermatrix/transfer.jl 77.77% <100.00%> (+1.77%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos
Copy link
Copy Markdown
Member Author

lkdvos commented Mar 14, 2025

Copy link
Copy Markdown
Member

@leburgel leburgel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just merging this as-is without much cleanup is definitely fine by me. It's a strict addition and the example is extremely nice!

However, I'm not super enthusiastic about merging in the actual implementation into the main package without tests or explanation. The general utilities like the MPO trace and the infinite temperature density matrix are great, but it would be nice if we had a test (quickly adapted from the example?). For the implementation of the derivatives and the transfer functions, a test would be nice, but also some clarification of the implementation itself would be good I think. It's implicitly assumed that given an MPO tensor $O$ we apply $O \otimes \mathbb{1}$. Also the fact that the second physical index corresponds to the bra-side of a density matrix and the fact that the physical indices are traced shut is implicit, while this is really a choice that was made. I'm totally fine with the choices, I just think they should be briefly but.explicitly stated somewhere.

Comment thread examples/quantum1d/7.xy-finiteT/main.jl Outdated
Comment thread docs/src/examples/classic2d/1.hard-hexagon/index.md
Comment thread examples/quantum1d/6.hubbard/main.jl
Comment thread examples/quantum1d/7.xy-finiteT/main.jl Outdated
Comment thread examples/quantum1d/7.xy-finiteT/main.jl
Comment thread examples/quantum1d/7.xy-finiteT/main.jl
Comment thread examples/quantum1d/7.xy-finiteT/main.jl Outdated
Comment thread examples/quantum1d/7.xy-finiteT/main.jl Outdated
Comment thread examples/quantum1d/7.xy-finiteT/main.jl
Comment thread examples/quantum1d/7.xy-finiteT/main.jl Outdated
@lkdvos
Copy link
Copy Markdown
Member Author

lkdvos commented Mar 17, 2025

If tests turn green, this should be good to go.

@lkdvos lkdvos requested a review from leburgel March 17, 2025 21:16
@lkdvos lkdvos enabled auto-merge (squash) March 17, 2025 22:10
Copy link
Copy Markdown
Member

@leburgel leburgel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect!

@lkdvos lkdvos merged commit 5fcd93e into master Mar 18, 2025
28 checks passed
@lkdvos lkdvos deleted the densitymatrices branch March 18, 2025 07:30
@Qiaoyi-Li
Copy link
Copy Markdown

I am also working on MPO-based finite-T calculations, so I took a look at the example script. The comments in it are quite insightful---many of the observations align with challenges we have encountered as well. Some tricks may be helpful, listed below:

  • Using a bilayer MPO $\rho(\beta/2)$ to represent the density operator $\rho(\beta)$ indeed improves accuracy. If you are interested, some benchmark results can be found in PhysRevB.95.144428(2017).
  • The "MPO multiplication approach (exponential)" (we call it "XTRG"PhysRevX.8.031082(2018)) is a robust technical route, as if the initialized high-T state is accurate enough. Initializing a more accurate high-T state(PhysRevB.95.161104(2017) may be helpful) may help reduce errors?
  • Thanks to the TDVP, the time-evolution approach definitely improves the finite-T calculations with long-range interactions (as the key step is TDVP, a tangent-space technique, we call it "tanTRG"PhysRevLett.130.226502(2023)). In our initial benchmark tests, we found directly performing imaginary-time evolution with constant step length from an identity MPO leads to large free energy errors at low temperatures. You might try a linearly-increasing step length (equivalent to an exponential scaled $\beta$ list) in the initial stage, which works well in all models we have computed.

@lkdvos
Copy link
Copy Markdown
Member Author

lkdvos commented Mar 18, 2025

Hi Qiaoyi-Li, thanks for your comments and suggestions! It is really nice to hear some of the tips and tricks from someone that is actually working with this, since often the technical tricks get lost in the relevant papers.

  • I agree that it would be better to have a fully bilayer approach. However, as I'm not really working on this topic myself, I lack the time to do so. As always, I would be more than happy to collaborate on this if you would like, and contributions are more than welcome.
  • I am aware of that work for writing initial high-T states. However, I'm not convinced that this would increase accuracy. The initial state presented here is based on Efficient higher-order matrix product operators, which provide MPOs that are fully correct up to the specified order. The work you link involves truncations, which suffer from the same problem as all the methods presented here: interpreting an MPO as an MPS, and then truncating it is a truncation in the frobenius norm of the MPS. For states, this is indeed the relevant norm, while for operators we would really want the operator norm instead. In that sense, if one only cares about the accuracy of the initial state, I would argue that it is better to take the Taylor expansion up to the maximal order that fits in memory, and then making the initial beta smaller until the desired accuracy is reached. This aside, I would love to see an actual comparison of these two in practice, since there is always a trade-off between accuracy and CPU time and memory usage, and for concrete models one might be interested in different results.
  • For the algorithm names, I didn't see enough reason to change TDVP and DMRG to something else. The core algorithm really is exactly the same as TDVP and DMRG, and the only alteration is the specific contraction of the effective local operator. Therefore I think it is fair to use the same name, and also convenient, since otherwise I would have to duplicate a whole bunch of code, whereas now I simply modified the contractions. Obviously I have no problem linking these papers, somehow I just kind of forgot to put the citations in. If you want to, I'd be more than happy if you could add these performance tips and tricks and the references in the example.

@Qiaoyi-Li
Copy link
Copy Markdown

Hi Lukas, I ran some quick tests using my own package (since I am more familiar with it than MPSKit) and uploaded the benchmark script into https://github.com/Qiaoyi-Li/FiniteMPS.jl/tree/main/benchmark/XY_chain.

  • In all three test cases, even the worst one (with linearly increasing $\beta$) resulted in free energy errors of at most $\lesssim 10^{-5}$. However, when running the example script in MPSKit, I observed much larger errors. I’m not sure if there might be some undetected bugs in it?
  • Exponentially increasing $\beta$ significantly reduces errors. In fact, we proposed this choice in the maintext of PhysRevLett.130.226502(2023).
  • The XY chain might be too simple to reveal the benefits of SETTN initialization, making it nonessential in this case. A more complex test (4-leg spinless fermions) is provided in Fig.7 of SM, in where higher order expansion can further reduce errors in the initial stage.
  • Since I haven’t implemented XTRG in my package, I cannot provide a script to convince you. I suspect that truncating via Frobenius norm is not a problem just because XTRG finally works in many cases. I would be interested in seeing benchmark results from MPSKit if you have any.
  • I do not have any comment on the names of algorithms, please feel free to use any function names you prefer in your package.

@lkdvos
Copy link
Copy Markdown
Member Author

lkdvos commented Mar 20, 2025

Thanks for checking this: indeed there was a mistake. I was using analytic results for periodic boundary conditions, leading to small discrepancies.
I'm rerunning the examples and now simply basing of your (very nice!) BenchmarkFreeFermions results, to avoid these issues.

Also, I'm not saying these things are not working, I just mean that one should be a little careful about it. The frobenius norm is still a norm, so as long as the truncations aren't too severe this should still be fine. I just want to be careful advertising things in the examples so users are not entering with too high expectations: we are still solving an exponential problem, and we know that it shouldn't be possible to deal with arbitrary finite temperatures since there is no area law (I think)?

Anyways, thanks a lot for your tips and comments, this has been very helpful so I appreciate this greatly!

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