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

Generalizing fitting algorithm to MPO-MPO multiplication #37

Open
shinaoka opened this issue Nov 21, 2022 · 7 comments
Open

Generalizing fitting algorithm to MPO-MPO multiplication #37

shinaoka opened this issue Nov 21, 2022 · 7 comments

Comments

@shinaoka
Copy link

shinaoka commented Nov 21, 2022

Thank you for developing the nice library!

I am wondering how to generalize the fitting algorithm to MPO-MPO multiplication. I am slowly understanding the internal structure of this library. This could be achieved by generalizing ProjMPOApply.

https://github.com/ITensor/ITensorTDVP.jl/blob/main/src/projmpo_apply.jl

But, the function tdvp is specialized to MPS. I am not sure if this restriction is strict. Is generalizing it to MPO possible technically?

@mtfishman
Copy link
Member

mtfishman commented Nov 22, 2022

Good question. Ultimately we plan to allow more general inputs to tdvp beyond MPS, for example tree tensor networks (#43), so it seems reasonable to allow MPO as well.

A minimal thing you can do is just convert your MPO to an MPS (there isn't any restriction that MPS must have only one site index per site), and see what breaks. At some point I tested this out for using TDVP to evolve a density matrix. I think it all worked after I generalized some of the projected MPO code to handle the "dangling" indices properly: ITensor/ITensors.jl@0101936

@shinaoka
Copy link
Author

shinaoka commented Nov 23, 2022

Thank you for the reply.

Ultimately, we plan to allow more general inputs to tdvp beyond MPS, for example tree tensor networks (ITensor/ITensorTDVP.jl#43), so it seems reasonable to allow MPO as well.

That'd be great!

In the meantime, I have just made a quick dirty hack to ITensorTDVP.jl and ITensors.jl.
You will find my code in the contract_mpo_mpo branch with a notebook:
https://github.com/shinaoka/ITensorTDVP.jl/blob/contract_mpo_mpo/examples/contract_mpo_mpo.ipynb

I had to extend ITensors.replacebond! to MPO in the notebook, but the rest was smooth. The notebook was tested with ITensors v0.3.20.

@emstoudenmire
Copy link
Contributor

Agreed with Matt's answer about mapping to the MPS type and back, and tweaking the code to handle doubled site indices. Sounds like it worked!

So do I understand from your code, literally the only change needed was defining replacebond!, and the rest just worked? That's great if so.

@shinaoka
Copy link
Author

@emstoudenmire

the only change needed was defining replacebond!, and the rest just worked?

Correct! Let me clean up the code.

@shinaoka
Copy link
Author

shinaoka commented Nov 23, 2022

Here is a small patch with a test:
https://github.com/shinaoka/ITensorTDVP.jl/tree/contract_mpo_mpo_clean

Changing a few lines in function ITensors.contract was enough! All the tests passed with ITensors v0.3.20. Shall I make a PR?

@emstoudenmire
Copy link
Contributor

Yes a PR would be great. Thanks! And for now you could put the MPO version of replacebond! in the contract_mpo_mps.jl file and I'll work myself on a separate PR for ITensors.jl to generalize replacebond! to handle MPOs, and can remove that (nearly) duplicate code myself later.

@shinaoka
Copy link
Author

shinaoka commented Nov 24, 2022

I am a bit confused. Do we need the MPO version of replacebond! at this point?

@mtfishman mtfishman transferred this issue from ITensor/ITensorTDVP.jl Oct 25, 2024
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

No branches or pull requests

3 participants