Skip to content

Commit cd7c88c

Browse files
authored
Optimizations for VUMPS (#64)
* Add `eager=true` to `eigsolve` for reducing the number of matrix-vector multiplications needed for `AC` and `C`. * Start improving tensor contraction sequences when computing `AC` and `C` in `InfiniteSum{MPO}`. * Make sure the phases of `AC` and `C` match when computing the precision error `|AC - AL * C|`. * Use `splitblocks` when making `MPO`s as an additional optimization.
1 parent 3004d37 commit cd7c88c

16 files changed

+97
-202
lines changed

examples/vumps/vumps_hubbard_extended.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ using ITensorInfiniteMPS
55
# VUMPS parameters
66
#
77

8-
maxdim = 30 # Maximum bond dimension
8+
maxdim = 50 # Maximum bond dimension
99
cutoff = 1e-6 # Singular value cutoff when increasing the bond dimension
1010
max_vumps_iters = 200 # Maximum number of iterations of the VUMPS algorithm at each bond dimension
1111
outer_iters = 5 # Number of times to increase the bond dimension
12-
localham_type = ITensor # or MPO
12+
localham_type = MPO # or ITensor
13+
eager = true
1314

1415
model_params = (t=1.0, U=10.0, V=0.0)
1516

@@ -47,7 +48,7 @@ println("\nCheck translational invariance of initial infinite MPS")
4748
@show norm(contract.AL[1:N]..., ψ.C[N]) - contract.C[0], ψ.AR[1:N]...))
4849

4950
outputlevel = 1
50-
vumps_kwargs = (tol=1e-8, maxiter=max_vumps_iters, outputlevel=outputlevel)
51+
vumps_kwargs = (tol=1e-8, maxiter=max_vumps_iters, outputlevel=outputlevel, eager)
5152
subspace_expansion_kwargs = (cutoff=cutoff, maxdim=maxdim)
5253

5354
# For now, to increase the bond dimension you must alternate
@@ -60,7 +61,7 @@ println("\nRun VUMPS on initial product state, unit cell size $N")
6061

6162
@time for _ in 1:outer_iters
6263
println("\nIncrease bond dimension")
63-
global ψ = subspace_expansion(ψ, H; subspace_expansion_kwargs...)
64+
global ψ = @time subspace_expansion(ψ, H; subspace_expansion_kwargs...)
6465
println("Run VUMPS with new bond dimension")
6566
global ψ = @time vumps(H, ψ; vumps_kwargs...)
6667
end
@@ -107,7 +108,7 @@ Hfinite = MPO(model, sfinite; model_params...)
107108
ψfinite = randomMPS(sfinite, initstate; linkdims=10)
108109
println("\nQN sector of starting finite MPS")
109110
@show flux(ψfinite)
110-
sweeps = Sweeps(30)
111+
sweeps = Sweeps(10)
111112
maxdims =
112113
min.(maxdim, [2, 2, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 32, 32, 32, 32, 50])
113114
@show maxdims
@@ -120,7 +121,7 @@ println("\nEnergy density")
120121

121122
nfinite = Nfinite ÷ 2 - 1
122123
bsfinite = [(nfinite, nfinite + 1), (nfinite + 1, nfinite + 2)]
123-
hfinite(b) = ITensor(model, sfinite[b[1]], sfinite[b[2]]; model_params...)
124+
hfinite(b) = ITensor(model, [sfinite[b[1]], sfinite[b[2]]]; model_params...)
124125
energy_finite = map(b -> expect_two_site(ψfinite, hfinite(b), b), bsfinite)
125126

126127
Nup_finite = ITensors.expect(ψfinite, "Nup")[nfinite:(nfinite + 1)]

examples/vumps/vumps_ising_extended.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cutoff = 1e-6 # Singular value cutoff when increasing the bond dimension
1010
max_vumps_iters = 100 # Maximum number of iterations of the VUMPS algorithm at each bond dimension
1111
vumps_tol = 1e-6
1212
outer_iters = 10 # Number of times to increase the bond dimension
13+
eager = true
1314

1415
##############################################################################
1516
# CODE BELOW HERE DOES NOT NEED TO BE MODIFIED
@@ -33,7 +34,7 @@ H = InfiniteSum{MPO}(model, s; J=J, J₂=J₂, h=h);
3334

3435
@show norm(contract.AL[1:N]..., ψ.C[N]) - contract.C[0], ψ.AR[1:N]...));
3536

36-
vumps_kwargs = (tol=vumps_tol, maxiter=max_vumps_iters)
37+
vumps_kwargs = (tol=vumps_tol, maxiter=max_vumps_iters, eager)
3738
subspace_expansion_kwargs = (cutoff=cutoff, maxdim=maxdim)
3839
ψ_0 = @time vumps(H, ψ; vumps_kwargs...)
3940

@@ -52,18 +53,17 @@ sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
5253
Hfinite = MPO(model, sfinite; J=J, J₂=J₂, h=h)
5354
ψfinite = randomMPS(sfinite, initstate; linkdims=10)
5455
@show flux(ψfinite)
55-
sweeps = Sweeps(15)
56+
sweeps = Sweeps(10)
5657
setmaxdim!(sweeps, maxdim)
5758
setcutoff!(sweeps, cutoff)
5859
energy_finite_total, ψfinite = dmrg(Hfinite, ψfinite, sweeps)
5960

6061
nfinite = Nfinite ÷ 2
6162
Sz_finite = expect(ψfinite, "Sz")[nfinite:(nfinite + N - 1)]
6263

63-
@show (
64-
energy_infinite,
65-
energy_finite_total / Nfinite,
66-
reference(model, Observable("energy"); J=J, h=h, J₂=J₂),
67-
)
64+
@show energy_infinite
65+
@show energy_finite_total / Nfinite
66+
@show reference(model, Observable("energy"); J=J, h=h, J₂=J₂)
6867

69-
@show (Sz, Sz_finite)
68+
@show Sz
69+
@show Sz_finite

src/ITensorInfiniteMPS.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ include("models/hubbard.jl")
4343
include("models/xx.jl")
4444
include("orthogonalize.jl")
4545
include("infinitemps_approx.jl")
46-
include("nullspace.jl")
4746
include("subspace_expansion.jl")
4847
include("vumps_generic.jl")
4948
include("vumps_localham.jl")

src/models/fqhe13.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function ITensors.MPO(::Model"fqhe_2b_pot", s::CelledVector, n::Int64; Ly, Vs, p
2626
end
2727
opsum = generate_Hamiltonian(opt)
2828

29-
return MPO(opsum, [s[x] for x in n:(n + range_model)])
29+
return splitblocks(linkinds, MPO(opsum, [s[x] for x in n:(n + range_model)]))
3030
end
3131

3232
#Please contact Loic Herviou before using this part of the code for production

src/models/heisenberg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function ITensors.MPO(::Model"heisenberg", s)
1515
os .+= 0.5, "S-", j, "S+", j + 1
1616
os .+= "Sz", j, "Sz", j + 1
1717
end
18-
return MPO(os, s)
18+
return splitblocks(linkinds, MPO(os, s))
1919
end
2020

2121
"""

src/models/hubbard.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function ITensors.MPO(::Model"hubbard", s; t, U, V)
3131
opsum .+= U, "Nupdn", n
3232
end
3333
end
34-
return MPO(opsum, s)
34+
return splitblocks(linkinds, MPO(opsum, s))
3535
end
3636

3737
function ITensors.ITensor(model::Model"hubbard", s; kwargs...)

src/models/ising.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function ITensors.MPO(::Model"ising", s; J, h)
88
for n in 1:N
99
a .+= -h, "Z", n
1010
end
11-
return MPO(a, s)
11+
return splitblocks(linkinds, MPO(a, s))
1212
end
1313

1414
# H = -J Σⱼ XⱼXⱼ₊₁ - h Σⱼ Zⱼ

src/models/ising_extended.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function ITensors.MPO(::Model"ising_extended", s; J=1.0, h=1.0, J₂=0.0)
1818
a += -h, "Z", n
1919
end
2020
end
21-
return MPO(a, s)
21+
return splitblocks(linkinds, MPO(a, s))
2222
end
2323

2424
# H = -J Σⱼ XⱼXⱼ₊₁ - h Σⱼ Zⱼ - J₂ Σⱼ XⱼZⱼ₊₁Xⱼ₊₂

src/models/models.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424

2525
function InfiniteSum{MPO}(model::Model, s::CelledVector; kwargs...)
2626
N = length(s)
27-
mpos = [MPO(model, s, n; kwargs...) for n in 1:N] #slightly improved version. Note: the current implementation does not really allow for staggered potentials for example
27+
mpos = [splitblocks(linkinds, MPO(model, s, n; kwargs...)) for n in 1:N] #slightly improved version. Note: the current implementation does not really allow for staggered potentials for example
2828
return InfiniteSum{MPO}(mpos, translator(s))
2929
end
3030

@@ -38,7 +38,7 @@ end
3838
function ITensors.MPO(model::Model, s::CelledVector, n::Int64; kwargs...)
3939
n1, n2 = 1, 2
4040
opsum = OpSum(model, n1, n2; kwargs...)
41-
return MPO(opsum, [s[x] for x in n:(n + nrange(model) - 1)]) #modification to allow for more than two sites per term in the Hamiltonians
41+
return splitblocks(linkinds, MPO(opsum, [s[x] for x in n:(n + nrange(model) - 1)])) #modification to allow for more than two sites per term in the Hamiltonians
4242
end
4343

4444
# Version accepting IndexSet

src/models/xx.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function ITensors.MPO(::Model"xx", s)
66
os .+= 1, "X", n, "X", n + 1
77
os .+= 1, "Y", n, "Y", n + 1
88
end
9-
return MPO(os, s)
9+
return splitblocks(linkinds, MPO(os, s))
1010
end
1111

1212
# H = X₁X₂ + Y₁Y₂

0 commit comments

Comments
 (0)