Skip to content

Commit 12aef35

Browse files
authored
DMRG3S: strictly single-site DMRG subspace expansion (Hubig et al. 2015) (#460)
1 parent d01bab8 commit 12aef35

10 files changed

Lines changed: 357 additions & 27 deletions

File tree

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ MPSKitAdaptExt = "Adapt"
3636
[compat]
3737
Accessors = "0.1"
3838
Adapt = "4"
39-
BlockTensorKit = "0.3.14"
39+
BlockTensorKit = "0.3.15"
4040
Compat = "3.47, 4.10"
4141
DocStringExtensions = "0.9.3"
4242
HalfIntegers = "1.6.0"

‎docs/src/assets/mpskit.bib‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,18 @@ @article{zhang2023
614614
url = {https://link.aps.org/doi/10.1103/PhysRevLett.130.151602},
615615
abstract = {We show that the Klein bottle entropy [H.-H. Tu, Phys. Rev. Lett. 119, 261603 (2017)] for conformal field theories perturbed by a relevant operator is a universal function of the dimensionless coupling constant. The universal scaling of the Klein bottle entropy near criticality provides an efficient approach to extract the scaling dimension of lattice operators via data collapse. As paradigmatic examples, we validate the universal scaling of the Klein bottle entropy for Ising and {$\mathbb{Z}$}3 parafermion conformal field theories with various perturbations using numerical simulation with continuous matrix product operator approach.}
616616
}
617+
618+
@article{Hubig2015,
619+
title = {Strictly single-site DMRG algorithm with subspace expansion},
620+
author = {Hubig, C. and McCulloch, I. P. and Schollw\"ock, U. and Wolf, F. A.},
621+
journal = {Phys. Rev. B},
622+
volume = {91},
623+
issue = {15},
624+
pages = {155115},
625+
numpages = {10},
626+
year = {2015},
627+
month = {Apr},
628+
publisher = {American Physical Society},
629+
doi = {10.1103/PhysRevB.91.155115},
630+
url = {https://link.aps.org/doi/10.1103/PhysRevB.91.155115}
631+
}

‎src/MPSKit.jl‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export time_evolve, timestep, timestep!, make_time_mpo
3838
export TDVP, TDVP2, WI, WII, TaylorCluster
3939
export changebonds, changebonds!
4040
export VUMPSSvdCut, OptimalExpand, SvdCut, RandExpand, SketchedExpand
41+
export NoiseSchedule, FunctionalSchedule, ExponentialDecay, Warmup, DMRG3S
4142
export propagator
4243
export DynamicalDMRG, NaiveInvert, Jeckelmann
4344
export exact_diagonalization, fidelity_susceptibility
@@ -160,6 +161,9 @@ include("algorithms/changebonds/svdcut.jl")
160161
include("algorithms/changebonds/randexpand.jl")
161162
include("algorithms/changebonds/sketchedexpand.jl")
162163

164+
include("algorithms/post_expand/post_expand.jl")
165+
include("algorithms/post_expand/dmrg3s.jl")
166+
163167
include("algorithms/timestep/tdvp.jl")
164168
include("algorithms/timestep/taylorcluster.jl")
165169
include("algorithms/timestep/wii.jl")

‎src/algorithms/approximate/fvomps.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function approximate!(ψ::AbstractFiniteMPS, Oϕ, alg::DMRG2, envs = environment
88
ϵ = 0.0
99
for pos in [1:(length(ψ) - 1); (length(ψ) - 2):-1:1]
1010
AC2′ = AC2_projection(pos, ψ, Oϕ, envs)
11-
al, c, ar, = svd_trunc!(AC2′, alg.alg_gauge)
11+
al, c, ar, = svd_trunc!(AC2′, inner_alg_gauge(alg))
1212

1313
AC2 = ψ.AC[pos] * _transpose_tail(ψ.AR[pos + 1])
1414
ϵ = max(ϵ, norm(al * c * ar - AC2) / norm(AC2))

‎src/algorithms/groundstate/dmrg.jl‎

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,54 @@
22
# center-move as in textbook single-site DMRG)
33
_truncates(::MatrixAlgebraKit.AbstractAlgorithm) = false
44
_truncates(::MatrixAlgebraKit.TruncatedAlgorithm) = true
5+
_truncates(alg::DMRG3S) = _truncates(alg.alg_gauge)
6+
7+
# a no-truncation `trscheme` selects a (bond-preserving) QR gauge, anything else a truncated SVD
8+
_build_inner_gauge(trscheme, alg_svd, alg_orth) =
9+
trscheme isa MatrixAlgebraKit.NoTruncation ? alg_orth :
10+
MatrixAlgebraKit.TruncatedAlgorithm(alg_svd, trscheme)
11+
12+
_expands(alg) = false
13+
_expands(::DMRG3S) = true
514

615
"""
716
$(TYPEDEF)
817
918
Density Matrix Renormalization Group algorithm for finding the dominant eigenvector.
1019
1120
Each site update is, in order: (1) an optional bond expansion (`alg_expand`), (2) a single-site
12-
eigensolve, and (3) a gauge step (`alg_gauge`). With the defaults (`alg_expand = nothing` and a
13-
non-truncating QR `alg_gauge`) this is textbook single-site DMRG, which cannot change the bond
14-
dimension. Setting `alg_expand` to a bond-expansion algorithm (e.g. [`OptimalExpand`](@ref),
15-
[`RandExpand`](@ref), [`SketchedExpand`](@ref)) enriches the bond with directions orthogonal to
16-
the current state ahead of each eigensolve, recovering Controlled Bond Expansion (CBE) DMRG; a
17-
truncating `alg_gauge` is then desirable to cut the enlarged bond back down.
18-
19-
The gauge algorithm is selected in the keyword constructor from the `trscheme` argument: when it
20-
is `notrunc()` the gauge is a QR decomposition (`alg_orth`, [`Householder`](@extref
21-
MatrixAlgebraKit.Householder) by default), otherwise it is a truncated SVD (`alg_svd` with the
22-
given `trscheme`).
21+
eigensolve, and (3) a gauge step (`alg_gauge`). With the defaults (`alg_expand = nothing` and
22+
`alg_gauge = nothing`, a non-truncating QR gauge derived from `trscheme = notrunc()`) this is
23+
textbook single-site DMRG, which cannot change the bond dimension. Setting `alg_expand` to a
24+
bond-expansion algorithm (e.g. [`OptimalExpand`](@ref), [`RandExpand`](@ref), [`SketchedExpand`](@ref))
25+
enriches the bond with directions orthogonal to the current state ahead of each eigensolve,
26+
recovering Controlled Bond Expansion (CBE) DMRG. Setting `alg_gauge` to a bond-expanding gauge
27+
algorithm (e.g. [`DMRG3S`](@ref)) instead enriches the bond as part of the gauge step, after the
28+
eigensolve. Either way, a truncating gauge (see below) is then desirable to cut the enlarged
29+
bond back down.
30+
31+
# Choosing the gauge
32+
33+
By default, `alg_gauge` is built for you from `trscheme`/`alg_svd`/`alg_orth`: `trscheme =
34+
notrunc()` (the default) gives a QR decomposition (`alg_orth`, [`Householder`](@extref
35+
MatrixAlgebraKit.Householder) by default), any other `trscheme` gives a truncated SVD (`alg_svd`
36+
with that `trscheme`).
37+
38+
```julia
39+
DMRG() # QR gauge, no truncation
40+
DMRG(; trscheme = truncdim(50)) # truncated SVD gauge
41+
```
42+
43+
To use a bond-expanding gauge such as [`DMRG3S`](@ref), pass it directly as `alg_gauge`; `trscheme`
44+
etc. are still routed through to build the *inner* gauge it wraps, exactly as above:
45+
46+
```julia
47+
DMRG(; alg_gauge = DMRG3S(0.1, ExponentialDecay(0.7)), trscheme = truncdim(50))
48+
```
49+
50+
If `alg_gauge` is instead given with its inner gauge already set (e.g. `DMRG3S(0.1, sched,
51+
some_gauge)`), `trscheme`/`alg_svd`/`alg_orth` must be left at their defaults — passing both is an
52+
error, since it leaves two conflicting sources for the same setting.
2353
2454
## Fields
2555
@@ -44,24 +74,38 @@ struct DMRG{A, F, E, G} <: Algorithm
4474
"algorithm used to expand the bond ahead of each local update, or `nothing` for none"
4575
alg_expand::E
4676

47-
"factorization used for the post-update gauge: a QR algorithm (no truncation) or a truncated SVD"
77+
"gauge algorithm applied after each local update: `NoExpand` for a plain gauge step (a QR
78+
algorithm with no truncation, or a truncated SVD), or an algorithm that additionally expands
79+
the bond beforehand (e.g. [`DMRG3S`](@ref))"
4880
alg_gauge::G
4981
end
5082
function DMRG(;
5183
tol = Defaults.tol, maxiter = Defaults.maxiter, alg_eigsolve = (;),
5284
verbosity = Defaults.verbosity, finalize = Defaults._finalize,
53-
alg_expand = nothing, trscheme = notrunc(),
85+
alg_expand = nothing, alg_gauge = nothing, trscheme = nothing,
5486
alg_svd = Defaults.alg_svd(), alg_orth = Defaults.alg_orth()
5587
)
5688
# single-site DMRG defaults to the per-bond adaptive controller (`AdaptiveKrylov`); pass
5789
# `alg_eigsolve = (; adaptive = false, ...)` to opt out (the splat overrides the default).
5890
alg_eigsolve′ = alg_eigsolve isa NamedTuple ?
5991
Defaults.alg_eigsolve(; adaptive = true, alg_eigsolve...) : alg_eigsolve
60-
# a no-truncation `trscheme` selects a (bond-preserving) QR gauge, anything else a truncated SVD
61-
alg_gauge = trscheme isa MatrixAlgebraKit.NoTruncation ? alg_orth :
62-
MatrixAlgebraKit.TruncatedAlgorithm(alg_svd, trscheme)
63-
if !isnothing(alg_expand) && !_truncates(alg_gauge)
64-
@warn "DMRG with `alg_expand` but no truncation (`trscheme = notrunc()`): the bond dimension will grow unboundedly each sweep."
92+
93+
if isnothing(alg_gauge) || isnothing(alg_gauge.alg_gauge)
94+
trscheme = something(trscheme, notrunc()) # enforce trscheme default here
95+
inner_gauge = _build_inner_gauge(trscheme, alg_svd, alg_orth)
96+
alg_gauge = set_alg_gauge(alg_gauge, inner_gauge)
97+
else
98+
isnothing(trscheme) || throw(
99+
ArgumentError(
100+
"`trscheme` was given together with an `alg_gauge` that already carries its own " *
101+
"gauge algorithm (e.g. `DMRG3S(noise, schedule, some_gauge)`); set the truncation " *
102+
"via one or the other, not both."
103+
)
104+
)
105+
end
106+
107+
if (!isnothing(alg_expand) || _expands(alg_gauge)) && !_truncates(alg_gauge)
108+
@warn "DMRG with a bond-expanding `alg_expand` and/or `alg_gauge` but no truncation (`trscheme = notrunc()`): the bond dimension will grow unboundedly each sweep."
65109
end
66110
return DMRG(tol, maxiter, verbosity, alg_eigsolve′, finalize, alg_expand, alg_gauge)
67111
end
@@ -71,7 +115,7 @@ function local_update!(
71115
site, direction,
72116
ψ, O, alg::DMRG, envs,
73117
ϵ_global, ϵ_trunc, decay_rate,
74-
timeroutput
118+
iter, timeroutput
75119
)
76120
ϵ_local = calc_galerkin(site, ψ, O, ψ, envs)
77121

@@ -87,8 +131,10 @@ function local_update!(
87131
fixedpoint(H_effective, ac_old, :SR, alg_eigsolve)
88132
end
89133

134+
alg_gauge = _update_alg_gauge(alg.alg_gauge, iter, ϵ_global)
135+
90136
# 3. gauge
91-
ψ, ϵ_trunc = @timeit timeroutput "gauge" gauge!(ψ, site, direction, AC′, alg.alg_gauge; normalize = true)
137+
ψ, ϵ_trunc = @timeit timeroutput "gauge" gauge!(ψ, site, direction, O, envs, AC′, alg_gauge; normalize = true)
92138

93139
# 4. bookkeeping: measured contraction factor per matvec, kept a strict contraction in (0, 1)
94140
decay_rate = clamp((first(info.normres) / ϵ_local)^(1 / max(1, info.numops)), 1.0e-3, 0.999)
@@ -145,7 +191,7 @@ function local_update!(
145191
pos, direction,
146192
ψ, O, alg::DMRG2, envs,
147193
ϵ_global, ϵ_trunc, decay_rate,
148-
timeroutput
194+
iter, timeroutput
149195
)
150196
Heff = @timeit timeroutput "AC2_hamiltonian" AC2_hamiltonian(pos, ψ, O, ψ, envs)
151197

@@ -162,9 +208,11 @@ function local_update!(
162208
(newA2center, info)
163209
end
164210

211+
alg_gauge = _update_alg_gauge(alg.alg_gauge, iter, ϵ_global)
212+
165213
# 2. gauge: truncated SVD split back into single-site tensors and install;
166214
# the discarded weight is the truncation error
167-
ψ, ϵ_trunc = @timeit timeroutput "gauge" gauge2!(ψ, pos, direction, newA2center, alg.alg_gauge; normalize = true)
215+
ψ, ϵ_trunc = @timeit timeroutput "gauge" gauge2!(ψ, pos, direction, O, envs, newA2center, alg_gauge; normalize = true)
168216

169217
# 3. bookkeeping: measured contraction factor per matvec, kept a strict contraction in (0, 1)
170218
decay_rate = clamp((first(info.normres) / ϵ_local)^(1 / max(1, info.numops)), 1.0e-3, 0.999)
@@ -184,6 +232,8 @@ _num_updates(::DMRG2, ψ) = length(ψ) - 1
184232
_sweep_ranges(::DMRG, ψ) = (1:(length(ψ) - 1), length(ψ):-1:2)
185233
_sweep_ranges(::DMRG2, ψ) = (1:(length(ψ) - 1), (length(ψ) - 2):-1:1)
186234

235+
inner_alg_gauge(alg::Union{DMRG, DMRG2}) = alg_gauge(alg.alg_gauge)
236+
187237
function find_groundstate!(
188238
ψ::AbstractFiniteMPS, H, alg::Union{DMRG, DMRG2}, envs = environments(ψ, H, ψ)
189239
)
@@ -211,7 +261,7 @@ function find_groundstate!(
211261
pos, Val(:right),
212262
ψ, H, alg, envs,
213263
ϵ_global, ϵ_truncs[pos], decay_rates[pos],
214-
timeroutput
264+
iter, timeroutput
215265
)
216266
ϵ_global = maximum(ϵ_locals)
217267
end
@@ -223,7 +273,7 @@ function find_groundstate!(
223273
pos, Val(:left),
224274
ψ, H, alg, envs,
225275
ϵ_global, ϵ_truncs[pos], decay_rates[pos],
226-
timeroutput
276+
iter, timeroutput
227277
)
228278
ϵ_global = maximum(ϵ_locals)
229279
end

0 commit comments

Comments
 (0)