From 855787b402f9578b90c74f9f3007a0ed5bcfb23c Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Sat, 28 Feb 2026 09:21:53 -0500 Subject: [PATCH 1/9] remove explicit call to InfiniteMPS in VUMPS and IDMRG --- src/algorithms/groundstate/idmrg.jl | 2 +- src/algorithms/groundstate/vumps.jl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index fab2c96da..913880150 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -102,7 +102,7 @@ function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, end alg_gauge = updatetol(alg.alg_gauge, it.state.iter, it.state.ϵ) - ψ′ = InfiniteMPS(it.state.mps.AR[1:end]; alg_gauge.tol, alg_gauge.maxiter) + ψ′ = typeof(mps)(it.state.mps.AR; alg_gauge.tol, alg_gauge.maxiter) envs = recalculate!(it.state.envs, ψ′, it.state.operator, ψ′) return ψ′, envs, it.state.ϵ end diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index 99da8234c..c3d497603 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -151,9 +151,11 @@ function _localupdate_vumps_step!( return regauge!(AC, C; alg = alg_orth) end -function gauge_step!(it::IterativeSolver{<:VUMPS}, state, ACs::AbstractVector) +function gauge_step!( + it::IterativeSolver{<:VUMPS,VUMPSState{S}}, state, ACs::AbstractVector + ) where {S} alg_gauge = updatetol(it.alg_gauge, state.iter, state.ϵ) - return InfiniteMPS(ACs, state.mps.C[end]; alg_gauge.tol, alg_gauge.maxiter) + return S(ACs, state.mps.C[end]; alg_gauge.tol, alg_gauge.maxiter) end function gauge_step!(it::IterativeSolver{<:VUMPS}, state, ACs::AbstractMatrix) alg_gauge = updatetol(it.alg_gauge, state.iter, state.ϵ) From f9858a4a74e7a4a30725c63c6e96004b77b5cb1e Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Sat, 28 Feb 2026 09:26:57 -0500 Subject: [PATCH 2/9] fix formatting --- src/algorithms/groundstate/vumps.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index c3d497603..9752f135a 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -152,7 +152,7 @@ function _localupdate_vumps_step!( end function gauge_step!( - it::IterativeSolver{<:VUMPS,VUMPSState{S}}, state, ACs::AbstractVector + it::IterativeSolver{<:VUMPS, VUMPSState{S}}, state, ACs::AbstractVector ) where {S} alg_gauge = updatetol(it.alg_gauge, state.iter, state.ϵ) return S(ACs, state.mps.C[end]; alg_gauge.tol, alg_gauge.maxiter) From ce53a264a48e361af8dae8843d957094111e978b Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Mon, 2 Mar 2026 06:40:46 -0500 Subject: [PATCH 3/9] revert original change and instead use gaugefix! in the gauging step --- src/algorithms/groundstate/idmrg.jl | 5 ++++- src/algorithms/groundstate/vumps.jl | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index 913880150..01b662b97 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -102,7 +102,10 @@ function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, end alg_gauge = updatetol(alg.alg_gauge, it.state.iter, it.state.ϵ) - ψ′ = typeof(mps)(it.state.mps.AR; alg_gauge.tol, alg_gauge.maxiter) + ψ′ = gaugefix!( + similar(it.state.mps), copy(it.state.mps.AR); + tol = alg_gauge.tol, maxiter = alg_gauge.maxiter + ) envs = recalculate!(it.state.envs, ψ′, it.state.operator, ψ′) return ψ′, envs, it.state.ϵ end diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index 9752f135a..68370f520 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -151,11 +151,12 @@ function _localupdate_vumps_step!( return regauge!(AC, C; alg = alg_orth) end -function gauge_step!( - it::IterativeSolver{<:VUMPS, VUMPSState{S}}, state, ACs::AbstractVector - ) where {S} +function gauge_step!(it::IterativeSolver{<:VUMPS}, state, ACs::AbstractVector) alg_gauge = updatetol(it.alg_gauge, state.iter, state.ϵ) - return S(ACs, state.mps.C[end]; alg_gauge.tol, alg_gauge.maxiter) + return gaugefix!( + state.mps, ACs, state.mps.C[end]; + alg_gauge.tol, alg_gauge.maxiter + ) end function gauge_step!(it::IterativeSolver{<:VUMPS}, state, ACs::AbstractMatrix) alg_gauge = updatetol(it.alg_gauge, state.iter, state.ϵ) From d2a28183013055dbe2d31a917675338eabf1b7f3 Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Mon, 2 Mar 2026 06:45:03 -0500 Subject: [PATCH 4/9] format --- src/algorithms/groundstate/idmrg.jl | 2 +- src/algorithms/groundstate/vumps.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index 01b662b97..b62e201e3 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -103,7 +103,7 @@ function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, alg_gauge = updatetol(alg.alg_gauge, it.state.iter, it.state.ϵ) ψ′ = gaugefix!( - similar(it.state.mps), copy(it.state.mps.AR); + similar(it.state.mps), copy(it.state.mps.AR); tol = alg_gauge.tol, maxiter = alg_gauge.maxiter ) envs = recalculate!(it.state.envs, ψ′, it.state.operator, ψ′) diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index 68370f520..c4a5fac6a 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -154,7 +154,7 @@ end function gauge_step!(it::IterativeSolver{<:VUMPS}, state, ACs::AbstractVector) alg_gauge = updatetol(it.alg_gauge, state.iter, state.ϵ) return gaugefix!( - state.mps, ACs, state.mps.C[end]; + state.mps, ACs, state.mps.C[end]; alg_gauge.tol, alg_gauge.maxiter ) end From 76765e1b786f89ea60f50c782d7690bf8260bffc Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Mon, 2 Mar 2026 07:58:52 -0500 Subject: [PATCH 5/9] copy mps in VUMPSState to avoid modifying the input mps during the iteration --- src/algorithms/groundstate/vumps.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index c4a5fac6a..974154cf5 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -61,7 +61,7 @@ function dominant_eigsolve( alg_environments = updatetol(alg.alg_environments, iter, ϵ) recalculate!(envs, mps, operator, mps; alg_environments.tol) - state = VUMPSState(mps, operator, envs, iter, ϵ, which) + state = VUMPSState(copy(mps), operator, envs, iter, ϵ, which) it = IterativeSolver(alg, state) return LoggingExtras.withlevel(; alg.verbosity) do From a86d1bc798a66f5444050bdaf64aa7b4ab72fabe Mon Sep 17 00:00:00 2001 From: Andreas Feuerpfeil Date: Mon, 2 Mar 2026 08:58:50 -0500 Subject: [PATCH 6/9] copy instead of similar in IDMRG --- src/algorithms/groundstate/idmrg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index b62e201e3..5e0e7f78e 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -103,7 +103,7 @@ function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, alg_gauge = updatetol(alg.alg_gauge, it.state.iter, it.state.ϵ) ψ′ = gaugefix!( - similar(it.state.mps), copy(it.state.mps.AR); + copy(it.state.mps), copy(it.state.mps.AR); tol = alg_gauge.tol, maxiter = alg_gauge.maxiter ) envs = recalculate!(it.state.envs, ψ′, it.state.operator, ψ′) From 91fac7906cd8aeb55ff384f89c25342929d1142c Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Mon, 2 Mar 2026 13:12:06 -0500 Subject: [PATCH 7/9] fix vumps --- src/algorithms/groundstate/vumps.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index 974154cf5..0cc6c5ad4 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -57,11 +57,12 @@ function dominant_eigsolve( ) log = IterLog("VUMPS") iter = 0 + mps = copy(mps) ϵ = calc_galerkin(mps, operator, mps, envs) alg_environments = updatetol(alg.alg_environments, iter, ϵ) recalculate!(envs, mps, operator, mps; alg_environments.tol) - state = VUMPSState(copy(mps), operator, envs, iter, ϵ, which) + state = VUMPSState(mps, operator, envs, iter, ϵ, which) it = IterativeSolver(alg, state) return LoggingExtras.withlevel(; alg.verbosity) do From 5a9525e2c4f1e861c40612f464d9f341d605cc8b Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Mon, 2 Mar 2026 14:14:46 -0500 Subject: [PATCH 8/9] hopefully fix idmrg bug (no copy needed, as mps is copied at the beginning) --- src/algorithms/groundstate/idmrg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index 5e0e7f78e..712fe228e 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -103,7 +103,7 @@ function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, alg_gauge = updatetol(alg.alg_gauge, it.state.iter, it.state.ϵ) ψ′ = gaugefix!( - copy(it.state.mps), copy(it.state.mps.AR); + it.state.mps, copy(it.state.mps.AR); tol = alg_gauge.tol, maxiter = alg_gauge.maxiter ) envs = recalculate!(it.state.envs, ψ′, it.state.operator, ψ′) From 69ab162c261f7302b839bad0ad4d2146e626b6e4 Mon Sep 17 00:00:00 2001 From: AFeuerpfeil Date: Tue, 3 Mar 2026 07:19:51 -0500 Subject: [PATCH 9/9] hopefully fix idmrg --- src/algorithms/groundstate/idmrg.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index 712fe228e..265148ae9 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -102,8 +102,10 @@ function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, end alg_gauge = updatetol(alg.alg_gauge, it.state.iter, it.state.ϵ) + V = _firstspace(it.state.mps.AR[1]) + C₀ = isomorphism(storagetype(eltype(it.state.mps.AR)), V, V) ψ′ = gaugefix!( - it.state.mps, copy(it.state.mps.AR); + copy(it.state.mps), copy(it.state.mps.AR), C₀; tol = alg_gauge.tol, maxiter = alg_gauge.maxiter ) envs = recalculate!(it.state.envs, ψ′, it.state.operator, ψ′)