Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Implement evolve of an MPS with an MPO #35

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

jofrevalles
Copy link
Member

Summary

This PR introduces the evolve function, which evolves a Matrix Product State (MPS) using a Matrix Product Operator (MPO). The idea from @starsfordummies is that we contract the tensors of each corresponding site, and we then create the new λ with a kron product with the old λ (which come from the MPS) and the identity (comes from the MPO). Right now, this function only works for mps in the canonical form.

Example

Here we show how can we use this function:

julia> using Qrochet

julia> ψ = rand(Chain, Open, State; n=8, χ=10); canonize!(ψ)
MPS (inputs=0, outputs=8)

julia> mpo = rand(Chain, Open, Operator; n=8, χ=10)

MPO (inputs=8, outputs=8)

julia> Qrochet.@reindex! inputs(mpo) => outputs(ψ)

MPS (inputs=0, outputs=8)

julia> ψ = Qrochet.evolve(ψ, mpo)
MPS (inputs=0, outputs=8)

julia> size.(tensors(ψ))
15-element Vector{Tuple{Int64, Vararg{Int64}}}:
 (2, 8)
 (2, 8, 40)
 (2, 40, 80)
 (2, 80, 100)
 (2, 100, 80)
 (2, 80, 40)
 (2, 40, 8)
 (2, 8)
 (8,)
 (40,)
 (80,)
 (100,)
 (80,)
 (40,)
 (8,)

Copy link
Member

@mofeing mofeing left a comment

Choose a reason for hiding this comment

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

This is not the optimal way to evolve a MPS through a MPO, but it's good enough. Thanks for your PR!

src/Ansatz/Chain.jl Outdated Show resolved Hide resolved
src/Ansatz/Chain.jl Outdated Show resolved Hide resolved
src/Ansatz/Chain.jl Outdated Show resolved Hide resolved
src/Ansatz/Chain.jl Outdated Show resolved Hide resolved
@jofrevalles
Copy link
Member Author

This is not the optimal way to evolve a MPS through a MPO, but it's good enough. Thanks for your PR!

What is more optimal? Here we just contract and update the bond dimensions.

@mofeing
Copy link
Member

mofeing commented Jun 3, 2024

What is more optimal? Here we just contract and update the bond dimensions.

Well, you can do MPS compression algorithm with the partial traces but inserting the MPO in between the original MPS and the target MPS.

But just like we did with evolve!, it's good to have this method; we just need to keep in mind but in the future we might need to extend the function to support this other method.

@jofrevalles
Copy link
Member Author

@mofeing Now I managed to make this function in place, but if we followed my suggestion in bsc-quantic/Tenet.jl#147, these could be much more clean.

@mofeing
Copy link
Member

mofeing commented Jun 5, 2024

Great! Then let's fix bsc-quantic/Tenet.jl#147 first

@jofrevalles
Copy link
Member Author

@mofeing Now this works in place and the code is much better with Tenet.@unsafe_region.

julia> mps = rand(Chain, Open, State; n=8, χ=10)
MPS (inputs=0, outputs=8)

julia> mpo = rand(Chain, Open, Operator; n=8, χ=10)
MPO (inputs=8, outputs=8)

julia> canonize!(mps)
MPS (inputs=0, outputs=8)

julia> Qrochet.@reindex! inputs(mpo) => outputs(mps)
MPS (inputs=0, outputs=8)

julia> evolve!(mps, mpo)
MPS (inputs=0, outputs=8)

julia> size.(tensors(mps))
15-element Vector{Tuple{Int64, Vararg{Int64}}}:
 (8,)
 (40,)
 (80,)
 (100,)
 (80,)
 (40,)
 (8,)
 (2, 8)
 (2, 8, 40)
 (2, 40, 80)
 (2, 80, 100)
 (2, 100, 80)
 (2, 80, 40)
 (2, 40, 8)
 (2, 8)

@mofeing
Copy link
Member

mofeing commented Jun 11, 2024

Wait, why are there vectors of size 80? Also the sizes are too big for a 8-site MPS. The maximum theoretical bond dimension for a physical dim of 2 should be $2^4 = 16$.

@jofrevalles
Copy link
Member Author

Wait, why are there vectors of size 80? Also the sizes are too big for a 8-site MPS. The maximum theoretical bond dimension for a physical dim of 2 should be 24=16.

The bond dimensions go up to 100 since for both mps and mpo, the maximum bond dimension is 10, and since we have to contract both bond dimensions we get 10^2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement evolve! for MPS-MPO
2 participants