Skip to content

Make MPO great again#230

Merged
kbidzhiev merged 13 commits into
mainfrom
kb/hermitean_MPO
Mar 30, 2026
Merged

Make MPO great again#230
kbidzhiev merged 13 commits into
mainfrom
kb/hermitean_MPO

Conversation

@kbidzhiev
Copy link
Copy Markdown
Contributor

@kbidzhiev kbidzhiev commented Mar 26, 2026

Summary

This PR enforces Hermiticity of MPO tensor nodes for the XY model by reformulating the interaction terms.

What changed

  • The XY Hamiltonian representation was rewritten from:
    $$\sigma^+_i \sigma^-_j + \sigma^-_i \sigma^+_j$$
    $$\sigma^+ = (\sigma^x + i \sigma^y)/2 $$
    $$\sigma^- = (\sigma^x - i \sigma^y)/2 $$
    to the equivalent form:
    $$\sigma^+_i \sigma^-_j + \sigma^-_i \sigma^+_j == (\sigma^x_i \sigma^x_j + \sigma^y_i \sigma^y_j)/2 == 2(S^x_i S^x_j + S^y_i S^y_j)$$, where $$S^{x,y}$$ are spin matrices $$S^a_i = \sigma^a_i /2$$
  • As a result, each MPO tensor node is now Hermitian (in the physical indices).

While MPO tensor nodes are not required to be Hermitian in general, the resulting Hamiltonian must be Hermitian. Enforcing Hermiticity at the tensor level provides a practical advantage:

Notes

  • This change does not alter the physical Hamiltonian, only its MPO representation.
  • The new formulation is mathematically equivalent but structurally better suited for downstream algorithms relying on Hermitian structure.

Comment :

Mauro suggested to compare memory consumption of the original and new MPO. I didn't bother making plots, because results are identical. Setup : quench with amplitude = 1. system size 4x2 rectangular array, initial state rrrrgggg

$$\sigma^+\sigma^-$$ (old):

S+S- Hamiltonian
step = 1/100, χ = 2, |ψ| = 0.001 MB, RSS = 322682.880 MB, Δt = 0.037 s
step = 2/100, χ = 4, |ψ| = 0.003 MB, RSS = 322748.416 MB, Δt = 0.019 s
step = 3/100, χ = 8, |ψ| = 0.005 MB, RSS = 322846.720 MB, Δt = 0.021 s
step = 4/100, χ = 10, |ψ| = 0.007 MB, RSS = 323076.096 MB, Δt = 0.022 s
step = 5/100, χ = 10, |ψ| = 0.008 MB, RSS = 323239.936 MB, Δt = 0.022 s
step = 6/100, χ = 10, |ψ| = 0.008 MB, RSS = 323321.856 MB, Δt = 0.022 s
step = 7/100, χ = 10, |ψ| = 0.008 MB, RSS = 323321.856 MB, Δt = 0.021 s
step = 8/100, χ = 11, |ψ| = 0.008 MB, RSS = 323321.856 MB, Δt = 0.021 s
step = 9/100, χ = 12, |ψ| = 0.009 MB, RSS = 323354.624 MB, Δt = 0.022 s
step = 10/100, χ = 12, |ψ| = 0.009 MB, RSS = 323354.624 MB, Δt = 0.021 s
step = 11/100, χ = 13, |ψ| = 0.009 MB, RSS = 323403.776 MB, Δt = 0.022 s
step = 12/100, χ = 13, |ψ| = 0.009 MB, RSS = 323403.776 MB, Δt = 0.021 s
step = 13/100, χ = 13, |ψ| = 0.009 MB, RSS = 323403.776 MB, Δt = 0.022 s
step = 14/100, χ = 14, |ψ| = 0.010 MB, RSS = 323420.160 MB, Δt = 0.022 s
step = 15/100, χ = 14, |ψ| = 0.010 MB, RSS = 323420.160 MB, Δt = 0.021 s
step = 16/100, χ = 15, |ψ| = 0.010 MB, RSS = 323452.928 MB, Δt = 0.022 s
step = 17/100, χ = 15, |ψ| = 0.010 MB, RSS = 323452.928 MB, Δt = 0.022 s
step = 18/100, χ = 15, |ψ| = 0.010 MB, RSS = 323452.928 MB, Δt = 0.023 s
step = 19/100, χ = 16, |ψ| = 0.011 MB, RSS = 323469.312 MB, Δt = 0.022 s
...

qubit density at the final time

tensor([0.6842, 0.6856, 0.6494, 0.6525, 0.3502, 0.3474, 0.3162, 0.3146],
       dtype=torch.float64)

$$S^xS^y$$ (new):

SxSy Hamiltonian
step = 1/100, χ = 2, |ψ| = 0.001 MB, RSS = 322224.128 MB, Δt = 0.034 s
step = 2/100, χ = 4, |ψ| = 0.003 MB, RSS = 322306.048 MB, Δt = 0.019 s
step = 3/100, χ = 8, |ψ| = 0.005 MB, RSS = 322420.736 MB, Δt = 0.020 s
step = 4/100, χ = 10, |ψ| = 0.007 MB, RSS = 322732.032 MB, Δt = 0.021 s
step = 5/100, χ = 10, |ψ| = 0.008 MB, RSS = 322912.256 MB, Δt = 0.022 s
step = 6/100, χ = 10, |ψ| = 0.008 MB, RSS = 323010.560 MB, Δt = 0.021 s
step = 7/100, χ = 10, |ψ| = 0.008 MB, RSS = 323010.560 MB, Δt = 0.021 s
step = 8/100, χ = 11, |ψ| = 0.008 MB, RSS = 323043.328 MB, Δt = 0.021 s
step = 9/100, χ = 12, |ψ| = 0.009 MB, RSS = 323076.096 MB, Δt = 0.021 s
step = 10/100, χ = 12, |ψ| = 0.009 MB, RSS = 323076.096 MB, Δt = 0.021 s
step = 11/100, χ = 13, |ψ| = 0.009 MB, RSS = 323125.248 MB, Δt = 0.022 s
step = 12/100, χ = 13, |ψ| = 0.009 MB, RSS = 323174.400 MB, Δt = 0.021 s
step = 13/100, χ = 13, |ψ| = 0.009 MB, RSS = 323174.400 MB, Δt = 0.021 s
step = 14/100, χ = 14, |ψ| = 0.010 MB, RSS = 323174.400 MB, Δt = 0.021 s
step = 15/100, χ = 14, |ψ| = 0.010 MB, RSS = 323174.400 MB, Δt = 0.022 s
step = 16/100, χ = 15, |ψ| = 0.010 MB, RSS = 323207.168 MB, Δt = 0.021 s
step = 17/100, χ = 15, |ψ| = 0.010 MB, RSS = 323256.320 MB, Δt = 0.021 s
step = 18/100, χ = 15, |ψ| = 0.010 MB, RSS = 323256.320 MB, Δt = 0.021 s
step = 19/100, χ = 16, |ψ| = 0.011 MB, RSS = 323272.704 MB, Δt = 0.021 s
...

qubit density at the final time

tensor([0.6842, 0.6856, 0.6494, 0.6525, 0.3502, 0.3474, 0.3162, 0.3146],
       dtype=torch.float64)

@kbidzhiev kbidzhiev marked this pull request as ready for review March 27, 2026 10:22
Comment thread emu_mps/hamiltonian.py
Comment thread emu_mps/hamiltonian.py Outdated
Comment thread test/emu_mps/test_hamiltonian.py Outdated
Comment thread emu_mps/hamiltonian.py
Comment thread emu_mps/hamiltonian.py Outdated
Copy link
Copy Markdown
Contributor

@murogrande murogrande left a comment

Choose a reason for hiding this comment

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

Is it possible to have value as a metric regarding this change? Because, I have the feeling that something internally in the code has changed. I see that all the test pass but internally, what about the bond dimension? it grows faster than before? I think that the bond will increase, won't it?

@kbidzhiev
Copy link
Copy Markdown
Contributor Author

kbidzhiev commented Mar 27, 2026

@murogrande I dont see at the moment why the bond dim should grow. Actually, the Hamiltonian bond dim stays the same

UPD: added a comment to the PR description. XY and S+S- are identical in terms of bond dim and memory and observables

Comment thread emu_mps/hamiltonian.py
Comment thread emu_mps/hamiltonian.py Outdated
Comment thread emu_mps/hamiltonian.py Outdated
Comment thread emu_mps/hamiltonian.py
Comment thread emu_mps/hamiltonian.py
Copy link
Copy Markdown
Contributor

@elmerhej elmerhej left a comment

Choose a reason for hiding this comment

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

LGTM

@kbidzhiev kbidzhiev merged commit d755930 into main Mar 30, 2026
12 checks passed
@murogrande murogrande deleted the kb/hermitean_MPO branch March 30, 2026 15:24
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