diff --git a/Project.toml b/Project.toml index 4a32df05..cb913c83 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SpinGlassEngine" uuid = "0563570f-ea1b-4080-8a64-041ac6565a4e" authors = ["Anna Maria Dziubyna ", "Tomasz Śmierzchalski ", "Bartłomiej Gardas ", "Konrad Jałowiecki ", "Łukasz Pawela ", "Marek M. Rams "] -version = "1.3.0" +version = "1.4.0" [deps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" diff --git a/docs/src/params.md b/docs/src/params.md index cc67e234..5b9adc8b 100644 --- a/docs/src/params.md +++ b/docs/src/params.md @@ -15,7 +15,6 @@ SearchParameters In the boundary MPS-MPO approach we apply Matrix Product Operator (MPO) to appropriate sites of Matrix Product State (MPS). In this context, the absorption of a MPO into a MPS leads to an exponential growth of the bond dimension. Hence, a truncation scheme is necessary to mitigate this issue and to keep the bond dimension in a reasonable size. Our package offers users the flexibility to choose between three distinct methods for optimizing the boundary MPS used in contracting the tensor network: * `Zipper` -* `MPSAnnealing` * `SVDTruncate`. `Zipper` method combines randomized truncated Singular Value Decomposition (SVD) and a variational scheme. ```@raw html @@ -25,10 +24,6 @@ With the `SVDTruncate` method, the Matrix Product State (MPS) is systematically ```@raw html ``` -On the other hand, the `MPSAnnealing` method tailors the construction of MPS based on variational compression. -```@raw html - -``` # Sparsity Our software package acknowledges the importance of two fundamental methodologies in tensor processing diff --git a/examples/pegasus.jl b/examples/pegasus.jl index 3341d482..c38321eb 100644 --- a/examples/pegasus.jl +++ b/examples/pegasus.jl @@ -17,7 +17,6 @@ function bench(instance::String, β::Real, bond_dim::Integer, num_states::Intege dE = 3.0 δp = exp(-β * dE) - all_betas = [β / 8, β / 4, β / 2, β] potts_h = potts_hamiltonian( ising_graph(instance), @@ -25,8 +24,8 @@ function bench(instance::String, β::Real, bond_dim::Integer, num_states::Intege cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4, ts = 1E-16) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4, tol_SVD = 1E-16) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) Strategy = Zipper Sparsity = Sparse Layout = GaugesEnergy @@ -36,8 +35,8 @@ function bench(instance::String, β::Real, bond_dim::Integer, num_states::Intege ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; - βs = all_betas, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, onGPU = onGPU, ) diff --git a/examples/truncation_BP.jl b/examples/truncation_BP.jl index 751b0a6a..cfb7ae13 100644 --- a/examples/truncation_BP.jl +++ b/examples/truncation_BP.jl @@ -27,7 +27,6 @@ Dcut = 8 tolV = 1E-16 tolS = 1E-16 max_sweeps = 0 -indβ = 1 ITERS_SVD = 2 ITERS_VAR = 1 DTEMP_MULT = 2 @@ -43,7 +42,7 @@ params = MpsParameters(Dcut, tolV, max_sweeps, tolS, ITERS_SVD, ITERS_VAR, DTEMP_MULT, METHOD) search_params = SearchParameters(MAX_STATES, δp) -Strategy = Zipper # MPSAnnealing SVDTruncate +Strategy = Zipper # SVDTruncate Layout = GaugesEnergy Gauge = NoUpdate cl_states = [2^10] diff --git a/src/contractor.jl b/src/contractor.jl index fa1b7ea0..65329d84 100644 --- a/src/contractor.jl +++ b/src/contractor.jl @@ -1,5 +1,4 @@ export SVDTruncate, - MPSAnnealing, Zipper, MpoLayers, MpsParameters, @@ -35,7 +34,6 @@ abstract type AbstractStrategy end abstract type AbstractGauge end struct SVDTruncate <: AbstractStrategy end -struct MPSAnnealing <: AbstractStrategy end struct Zipper <: AbstractStrategy end struct GaugeStrategyWithBalancing <: AbstractGauge end struct GaugeStrategy <: AbstractGauge end @@ -87,15 +85,15 @@ struct MpsParameters{S<:Real} method::Symbol MpsParameters{S}(; - bd = typemax(Int), - ϵ::S = S(1E-8), - sw = 4, - ts::S = S(1E-16), - is = 1, - iv = 1, - dm = 2, - m = :psvd_sparse, - ) where {S} = new(bd, ϵ, sw, ts, is, iv, dm, m) + bond_dim = typemax(Int), + var_tol::S = S(1E-8), + num_sweeps = 4, + tol_SVD::S = S(1E-16), + iters_svd = 1, + iters_var = 1, + Dtemp_multiplier = 2, + method = :psvd_sparse, + ) where {S} = new(bond_dim, var_tol, num_sweeps, tol_SVD, iters_svd, iters_var, Dtemp_multiplier, method) end """ @@ -133,7 +131,7 @@ A mutable struct representing a contractor for contracting a PEPS (Projected Ent # Fields - `peps::PEPSNetwork{T, S}`: The PEPS network to be contracted. - `betas::Vector{<:Real}`: A vector of inverse temperatures (β) used during the search. The last one is the target one. This parameter plays a crucial role: a larger β enables a finer focus on low-energy states, although it may compromise the numerical stability of tensor network contraction. Determining the optimal β could be instance-dependent, and experimental exploration might be necessary for different classes of instances. -- `graduate_truncation::Symbol`: The truncation method to use for gradually truncating MPS bond dimensions. +- `graduate_truncation::Bool`: The truncation method to use for gradually truncating MPS bond dimensions. - `params::MpsParameters`: Control parameters for the MPO-MPS contraction. # Optional Arguments @@ -146,8 +144,8 @@ It encapsulates various components and settings required for the contraction pro mutable struct MpsContractor{T<:AbstractStrategy,R<:AbstractGauge,S<:Real} <: AbstractContractor peps::PEPSNetwork{T} where {T} - betas::Vector{S} - graduate_truncation::Symbol + beta::S + graduate_truncation::Bool depth::Int params::MpsParameters{S} layers::MpoLayers @@ -161,8 +159,8 @@ mutable struct MpsContractor{T<:AbstractStrategy,R<:AbstractGauge,S<:Real} <: function MpsContractor{T,R,S}( net, params; - βs::Vector{S}, - graduate_truncation::Symbol, + beta::S, + graduate_truncation::Bool, onGPU = true, depth::Int = 0, ) where {T,R,S} @@ -173,7 +171,7 @@ mutable struct MpsContractor{T<:AbstractStrategy,R<:AbstractGauge,S<:Real} <: node = ord[begin] new( net, - βs, + beta, graduate_truncation, depth, params, @@ -208,7 +206,6 @@ Construct and memoize a Matrix Product Operator (MPO) for a given set of layers. - `ctr::MpsContractor{T}`: The MpsContractor object representing the PEPS network contraction. - `layers::Dict{Site, Sites}`: A dictionary mapping sites to their corresponding layers. - `r::Int`: The current row index. -- `indβ::Int`: The index of the beta values. # Returns - `QMpo`: The constructed MPO for the specified layers. @@ -219,13 +216,12 @@ This function constructs an MPO by iterating through the specified layers and as ctr::MpsContractor{T,R,S}, layers::Dict{Site,Sites}, r::Int, - indβ::Int, ) where {T<:AbstractStrategy,R,S} mpo = Dict{Site,MpoTensor{S}}() for (site, coordinates) ∈ layers lmpo = TensorMap{S}() for dr ∈ coordinates - ten = tensor(ctr.peps, PEPSNode(r + dr, site), ctr.betas[indβ]) + ten = tensor(ctr.peps, PEPSNode(r + dr, site), ctr.beta) push!(lmpo, dr => ten) end push!(mpo, site => MpoTensor(lmpo)) @@ -241,7 +237,6 @@ Construct and memoize the top Matrix Product State (MPS) using Singular Value De # Arguments - `ctr::MpsContractor{SVDTruncate}`: The MpsContractor object representing the PEPS network contraction with SVD truncation. - `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. # Returns - `QMps`: The constructed top MPS for the specified row. @@ -251,7 +246,6 @@ This function constructs the top MPS using SVD for a given row in the PEPS netwo @memoize Dict function mps_top( ctr::MpsContractor{SVDTruncate,R,S}, i::Int, - indβ::Int, ) where {R,S} Dcut = ctr.params.bond_dimension tolV = ctr.params.variational_tol @@ -259,16 +253,16 @@ This function constructs the top MPS using SVD for a given row in the PEPS netwo max_sweeps = ctr.params.max_num_sweeps if i < 1 - W = mpo(ctr, ctr.layers.main, 1, indβ) + W = mpo(ctr, ctr.layers.main, 1) return IdentityQMps(S, local_dims(W, :up); onGPU = ctr.onGPU) end - ψ = mps_top(ctr, i - 1, indβ) - W = transpose(mpo(ctr, ctr.layers.main, i, indβ)) + ψ = mps_top(ctr, i - 1) + W = transpose(mpo(ctr, ctr.layers.main, i)) ψ0 = dot(W, ψ) canonise!(ψ0, :right) - if ctr.graduate_truncation == :graduate_truncate + if ctr.graduate_truncation canonise_truncate!(ψ0, :left, Dcut * 2, tolS / 2) variational_sweep!(ψ0, W, ψ, Val(:right)) end @@ -285,7 +279,6 @@ Construct and memoize the (bottom) Matrix Product State (MPS) using Singular Val # Arguments - `ctr::MpsContractor{SVDTruncate}`: The MpsContractor object representing the PEPS network contraction with SVD truncation. - `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. # Returns - `QMps`: The constructed (bottom) MPS for the specified row. @@ -295,7 +288,6 @@ This function constructs the (bottom) MPS using SVD for a given row in the PEPS @memoize Dict function mps( ctr::MpsContractor{SVDTruncate,R,S}, i::Int, - indβ::Int, ) where {R,S} Dcut = ctr.params.bond_dimension tolV = ctr.params.variational_tol @@ -303,16 +295,16 @@ This function constructs the (bottom) MPS using SVD for a given row in the PEPS max_sweeps = ctr.params.max_num_sweeps if i > ctr.peps.nrows - W = mpo(ctr, ctr.layers.main, ctr.peps.nrows, indβ) + W = mpo(ctr, ctr.layers.main, ctr.peps.nrows) return IdentityQMps(S, local_dims(W, :down); onGPU = ctr.onGPU) end - ψ = mps(ctr, i + 1, indβ) - W = mpo(ctr, ctr.layers.main, i, indβ) + ψ = mps(ctr, i + 1) + W = mpo(ctr, ctr.layers.main, i) ψ0 = dot(W, ψ) canonise!(ψ0, :right) - if ctr.graduate_truncation == :graduate_truncate + if ctr.graduate_truncation canonise_truncate!(ψ0, :left, Dcut * 2, tolS / 2) variational_sweep!(ψ0, W, ψ, Val(:right)) end @@ -330,7 +322,6 @@ Construct and memoize the (bottom) Matrix Product State (MPS) approximation usin # Arguments - `ctr::MpsContractor{SVDTruncate}`: The MpsContractor object representing the PEPS network contraction with SVD truncation. - `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. # Returns - `QMps`: The constructed (bottom) MPS approximation for the specified row. @@ -340,14 +331,13 @@ This function constructs the (bottom) MPS approximation using SVD for a given ro @memoize Dict function mps_approx( ctr::MpsContractor{SVDTruncate,R,S}, i::Int, - indβ::Int, ) where {R,S} if i > ctr.peps.nrows - W = mpo(ctr, ctr.layers.main, ctr.peps.nrows, indβ) + W = mpo(ctr, ctr.layers.main, ctr.peps.nrows) return IdentityQMps(S, local_dims(W, :down); onGPU = ctr.onGPU) # F64 for now end - W = mpo(ctr, ctr.layers.main, i, indβ) + W = mpo(ctr, ctr.layers.main, i) ψ = IdentityQMps(S, local_dims(W, :down); onGPU = ctr.onGPU) # F64 for now ψ0 = dot(W, ψ) @@ -374,7 +364,6 @@ Construct and memoize the top Matrix Product State (MPS) using the Zipper (trunc # Arguments - `ctr::MpsContractor{Zipper}`: The MpsContractor object representing the PEPS network contraction with the Zipper method. - `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. # Returns - `QMps`: The constructed top MPS using the Zipper method for the specified row. @@ -384,7 +373,6 @@ This function constructs the top Matrix Product State (MPS) using the Zipper (tr @memoize Dict function mps_top( ctr::MpsContractor{Zipper,R,S}, i::Int, - indβ::Int, ) where {R,S} Dcut = ctr.params.bond_dimension tolV = ctr.params.variational_tol @@ -396,12 +384,12 @@ This function constructs the top Matrix Product State (MPS) using the Zipper (tr method = ctr.params.method depth = ctr.depth if i < 1 - W = mpo(ctr, ctr.layers.main, 1, indβ) + W = mpo(ctr, ctr.layers.main, 1) return IdentityQMps(S, local_dims(W, :up); onGPU = ctr.onGPU) # F64 for now end - ψ = mps_top(ctr, i - 1, indβ) - W = transpose(mpo(ctr, ctr.layers.main, i, indβ)) + ψ = mps_top(ctr, i - 1) + W = transpose(mpo(ctr, ctr.layers.main, i)) canonise!(ψ, :left) ψ0 = zipper( @@ -428,14 +416,13 @@ Construct and memoize the (bottom) Matrix Product State (MPS) using the Zipper ( # Arguments - `ctr::MpsContractor{Zipper}`: The MpsContractor object representing the PEPS network contraction with the Zipper method. - `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. # Returns - `QMps`: The constructed (bottom) MPS using the Zipper method for the specified row. This function constructs the (bottom) Matrix Product State (MPS) using the Zipper (truncated Singular Value Decomposition) method for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing canonicalization, and truncation steps based on the specified parameters in `ctr.params`. The resulting MPS is memoized for efficient reuse. """ -@memoize Dict function mps(ctr::MpsContractor{Zipper,R,S}, i::Int, indβ::Int) where {R,S} +@memoize Dict function mps(ctr::MpsContractor{Zipper,R,S}, i::Int) where {R,S} Dcut = ctr.params.bond_dimension tolV = ctr.params.variational_tol tolS = ctr.params.tol_SVD @@ -447,11 +434,11 @@ This function constructs the (bottom) Matrix Product State (MPS) using the Zippe depth = ctr.depth if i > ctr.peps.nrows - W = mpo(ctr, ctr.layers.main, ctr.peps.nrows, indβ) + W = mpo(ctr, ctr.layers.main, ctr.peps.nrows) ψ0 = IdentityQMps(S, local_dims(W, :down); onGPU = ctr.onGPU) else - ψ = mps(ctr, i + 1, indβ) - W = mpo(ctr, ctr.layers.main, i, indβ) + ψ = mps(ctr, i + 1) + W = mpo(ctr, ctr.layers.main, i) canonise!(ψ, :left) ψ0 = zipper( W, @@ -473,139 +460,31 @@ end """ $(TYPEDSIGNATURES) -Construct and memoize the (bottom) top Matrix Product State (MPS) using the Annealing method for a given row. - -# Arguments -- `ctr::MpsContractor{MPSAnnealing}`: The MpsContractor object representing the PEPS network contraction with the Annealing method. -- `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. - -# Returns -- `QMps`: The constructed (bottom) top MPS using the Annealing method for the specified row. - -This function constructs the (bottom) top Matrix Product State (MPS) using the Annealing method for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing variational compression steps based on the specified parameters in `ctr.params`. The resulting MPS is memoized for efficient reuse. -""" -@memoize Dict function mps_top( - ctr::MpsContractor{MPSAnnealing,R,S}, - i::Int, - indβ::Int, -) where {R,S} - if i < 1 - W = mpo(ctr, ctr.layers.main, 1, indβ) - return IdentityQMps(S, local_dims(W, :up); onGPU = ctr.onGPU) - end - - ψ = mps_top(ctr, i - 1, indβ) - W = transpose(mpo(ctr, ctr.layers.main, i, indβ)) - - if indβ > 1 - ψ0 = mps_top(ctr, i, indβ - 1) - else - ψ0 = IdentityQMps( - S, - local_dims(W, :up), - ctr.params.bond_dimension; - onGPU = ctr.onGPU, - ) - # ψ0 = IdentityQMps(S, local_dims(W, :down), ctr.params.bond_dimension) # F64 for now - canonise!(ψ0, :left) - end - variational_compress!(ψ0, W, ψ, ctr.params.variational_tol, ctr.params.max_num_sweeps) - ψ0 -end - -""" -$(TYPEDSIGNATURES) - -Construct and memoize the (bottom) Matrix Product State (MPS) using the Annealing method for a given row. - -# Arguments -- `ctr::MpsContractor{MPSAnnealing}`: The MpsContractor object representing the PEPS network contraction with the Annealing method. -- `i::Int`: The current row index. -- `indβ::Int`: The index of the beta values. - -# Returns -- `QMps`: The constructed (bottom) MPS using the Annealing method for the specified row. - -This function constructs the (bottom) Matrix Product State (MPS) using the Annealing method for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing variational compression steps based on the specified parameters in `ctr.params`. The resulting MPS is memoized for efficient reuse. -""" -@memoize Dict function mps( - ctr::MpsContractor{MPSAnnealing,R,S}, - i::Int, - indβ::Int, -) where {R,S} - if i > ctr.peps.nrows - W = mpo(ctr, ctr.layers.main, ctr.peps.nrows, indβ) - return IdentityQMps(S, local_dims(W, :down); onGPU = ctr.onGPU) - end - - ψ = mps(ctr, i + 1, indβ) - W = mpo(ctr, ctr.layers.main, i, indβ) - - if indβ > 1 - ψ0 = mps(ctr, i, indβ - 1) - else - ψ0 = IdentityQMps( - S, - local_dims(W, :up), - ctr.params.bond_dimension; - onGPU = ctr.onGPU, - ) - canonise!(ψ0, :left) - end - - variational_compress!(ψ0, W, ψ, ctr.params.variational_tol, ctr.params.max_num_sweeps) - ψ0 -end - -""" -$(TYPEDSIGNATURES) - -Construct dressed Matrix Product State (MPS) for a given row and strategy. - -# Arguments -- `ctr::MpsContractor{T}`: The MpsContractor object representing the PEPS network contraction. -- `i::Int`: The current row index. - -# Returns -- `QMps`: The constructed dressed MPS for the specified row. - -This function constructs the dressed Matrix Product State (MPS) for a given row in the PEPS network contraction using the specified strategy. It internally calculates the length of the `ctr.betas` vector and then calls `dressed_mps(ctr, i, length(ctr.betas))` to construct the dressed MPS with the given parameters. -""" -function dressed_mps(ctr::MpsContractor{T}, i::Int) where {T<:AbstractStrategy} - dressed_mps(ctr, i, length(ctr.betas)) -end - -""" -$(TYPEDSIGNATURES) - Construct (and memoize) dressed Matrix Product State (MPS) for a given row and strategy. # Arguments - `ctr::MpsContractor{T}`: The MpsContractor object representing the PEPS network contraction. - `i::Int`: The current row index. -- `indβ::Int`: The index of the beta parameter vector used for construction. # Returns - `QMps`: The constructed dressed MPS for the specified row and strategy. -This function constructs the dressed Matrix Product State (MPS) for a given row in the PEPS network contraction using the specified strategy and memoizes the result for future use. It takes into account the beta parameter index `indβ` and internally calls other functions such as `mps` and `mpo` to construct the dressed MPS. Additionally, it normalizes the MPS tensors to ensure numerical stability. +This function constructs the dressed Matrix Product State (MPS) for a given row in the PEPS network contraction using the specified strategy and memoizes the result for future use. It internally calls other functions such as `mps` and `mpo` to construct the dressed MPS. Additionally, it normalizes the MPS tensors to ensure numerical stability. Note: The memoization ensures that the dressed MPS is only constructed once for each combination of arguments and is reused when needed. """ @memoize Dict function dressed_mps( ctr::MpsContractor{T}, i::Int, - indβ::Int, ) where {T<:AbstractStrategy} - ψ = mps(ctr, i + 1, indβ) + ψ = mps(ctr, i + 1) caches = Memoization.find_caches(mps) - delete!(caches[mps], ((ctr, i + 1, indβ), ())) + delete!(caches[mps], ((ctr, i + 1), ())) if ctr.onGPU ψ = move_to_CUDA!(ψ) end - W = mpo(ctr, ctr.layers.dress, i, indβ) + W = mpo(ctr, ctr.layers.dress, i) ϕ = dot(W, ψ) for j ∈ ϕ.sites nrm = maximum(abs.(ϕ[j])) @@ -625,12 +504,11 @@ Construct (and memoize) the right environment tensor for a given node in the PEP - `ctr::MpsContractor{T}`: The MpsContractor object representing the PEPS network contraction. - `i::Int`: The current row index. - `∂v::Vector{Int}`: A vector representing the partial environment configuration. -- `indβ::Int`: The index of the beta parameter vector used for construction. # Returns - `Array{S,2}`: The constructed right environment tensor for the specified node. -This function constructs the right environment tensor for a given node in the PEPS network contraction using the specified strategy and memoizes the result for future use. It takes into account the beta parameter index `indβ` and internally calls other functions such as `dressed_mps` and `mpo` to construct the right environment tensor. Additionally, it normalizes the right environment tensor to ensure numerical stability. +This function constructs the right environment tensor for a given node in the PEPS network contraction using the specified strategy and memoizes the result for future use. It internally calls other functions such as `dressed_mps` and `mpo` to construct the right environment tensor. Additionally, it normalizes the right environment tensor to ensure numerical stability. Note: The memoization ensures that the right environment tensor is only constructed once for each combination of arguments and is reused when needed. """ @@ -638,19 +516,18 @@ Note: The memoization ensures that the right environment tensor is only construc ctr::MpsContractor{T,R,S}, i::Int, ∂v::Vector{Int}, - indβ::Int, ) where {T<:AbstractStrategy,R,S} l = length(∂v) if l == 0 return ctr.onGPU ? CUDA.ones(S, 1, 1) : ones(S, 1, 1) end - R̃ = right_env(ctr, i, ∂v[2:l], indβ) + R̃ = right_env(ctr, i, ∂v[2:l]) if ctr.onGPU R̃ = CuArray(R̃) end - ϕ = dressed_mps(ctr, i, indβ) - W = mpo(ctr, ctr.layers.right, i, indβ) + ϕ = dressed_mps(ctr, i) + W = mpo(ctr, ctr.layers.right, i) k = length(ϕ.sites) site = ϕ.sites[k-l+1] M = W[site] @@ -684,12 +561,11 @@ Construct (and memoize) the left environment tensor for a given node in the PEPS - `ctr::MpsContractor{T}`: The MpsContractor object representing the PEPS network contraction. - `i::Int`: The current row index. - `∂v::Vector{Int}`: A vector representing the partial environment configuration. -- `indβ::Int`: The index of the beta parameter vector used for construction. # Returns - `Array{S,2}`: The constructed left environment tensor for the specified node. -This function constructs the left environment tensor for a given node in the PEPS network contraction using the specified strategy and memoizes the result for future use. It takes into account the beta parameter index `indβ` and internally calls other functions such as `dressed_mps` to construct the left environment tensor. Additionally, it normalizes the left environment tensor to ensure numerical stability. +This function constructs the left environment tensor for a given node in the PEPS network contraction using the specified strategy and memoizes the result for future use. It internally calls other functions such as `dressed_mps` to construct the left environment tensor. Additionally, it normalizes the left environment tensor to ensure numerical stability. Note: The memoization ensures that the left environment tensor is only constructed once for each combination of arguments and is reused when needed. @@ -698,15 +574,14 @@ Note: The memoization ensures that the left environment tensor is only construct ctr::MpsContractor{T,R,S}, i::Int, ∂v::Vector{Int}, - indβ::Int, ) where {T,R,S} l = length(∂v) if l == 0 return ctr.onGPU ? CUDA.ones(S, 1) : ones(S, 1) end - L̃ = left_env(ctr, i, ∂v[1:l-1], indβ) - ϕ = dressed_mps(ctr, i, indβ) + L̃ = left_env(ctr, i, ∂v[1:l-1]) + ϕ = dressed_mps(ctr, i) m = ∂v[l] site = ϕ.sites[l] M = ϕ[site] @@ -744,7 +619,7 @@ end $(TYPEDSIGNATURES) Clear memoization cache for specific operations for a given row and index beta. -This function clears the memoization cache for specific operations used in the PEPS network contraction for a given row and index beta (indβ). +This function clears the memoization cache for specific operations used in the PEPS network contraction for a given row. The cleared operations include `mps_top`, `mps`, `mpo`, `dressed_mps`, and related operations. Memoization is used to optimize the contraction process by avoiding redundant computations. Calling this function allows you to clear the cache for these specific operations for a particular row and index beta, which can be useful when you want to free up memory or ensure that the cache is refreshed with updated data for a specific computation. @@ -752,38 +627,34 @@ Calling this function allows you to clear the cache for these specific operation # Arguments - `ctr::MpsContractor{T, S}`: The PEPS network contractor object. - `row::Site`: The row for which the cache should be cleared. -- `indβ::Int`: The index beta for which the cache should be cleared. """ -function clear_memoize_cache(ctr::MpsContractor{T,S}, row::Site, indβ::Int) where {T,S} - for ind ∈ 1:indβ # indbeta a vector? - for i ∈ row:ctr.peps.nrows - delete!(Memoization.caches[mps_top], ((ctr, i, ind), ())) - end - for i ∈ 1:row+1 - delete!(Memoization.caches[mps], ((ctr, i, ind), ())) - end - for i ∈ row:row+2 - cmpo = Memoization.caches[mpo] - delete!(cmpo, ((ctr, ctr.layers.main, i, ind), ())) - delete!(cmpo, ((ctr, ctr.layers.dress, i, ind), ())) - delete!(cmpo, ((ctr, ctr.layers.right, i, ind), ())) - end - +function clear_memoize_cache(ctr::MpsContractor{T,S}, row::Site) where {T,S} + for i ∈ row:ctr.peps.nrows + delete!(Memoization.caches[mps_top], ((ctr, i), ())) + end + for i ∈ 1:row+1 + delete!(Memoization.caches[mps], ((ctr, i), ())) end + for i ∈ row:row+2 + cmpo = Memoization.caches[mpo] + delete!(cmpo, ((ctr, ctr.layers.main, i), ())) + delete!(cmpo, ((ctr, ctr.layers.dress, i), ())) + delete!(cmpo, ((ctr, ctr.layers.right, i), ())) + end + end function sweep_gauges!( ctr::MpsContractor{T,GaugeStrategy}, row::Site, - indβ::Int, tol::Real = 1E-4, max_sweeps::Int = 10, ) where {T} clm = ctr.layers.main - ψ_top = mps_top(ctr, row, indβ) - ψ_bot = mps(ctr, row + 1, indβ) + ψ_top = mps_top(ctr, row) + ψ_bot = mps(ctr, row + 1) ψ_top = deepcopy(ψ_top) ψ_bot = deepcopy(ψ_bot) @@ -805,18 +676,17 @@ function sweep_gauges!( g_bot = bot .* g_inv push!(ctr.peps.gauges.data, n_top => g_top, n_bot => g_bot) end - clear_memoize_cache(ctr, row, indβ) + clear_memoize_cache(ctr, row) end function sweep_gauges!( ctr::MpsContractor{T,GaugeStrategyWithBalancing}, row::Site, - indβ::Int, ) where {T} clm = ctr.layers.main - ψ_top = mps_top(ctr, row, indβ) - ψ_bot = mps(ctr, row + 1, indβ) + ψ_top = mps_top(ctr, row) + ψ_bot = mps(ctr, row + 1) ψ_top = deepcopy(ψ_top) ψ_bot = deepcopy(ψ_bot) for i ∈ ψ_top.sites @@ -826,7 +696,7 @@ function sweep_gauges!( _, _, scale = LinearAlgebra.LAPACK.gebal!('S', ρ) push!(ctr.peps.gauges.data, n_top => 1.0 ./ scale, n_bot => scale) end - clear_memoize_cache(ctr, row, indβ) + clear_memoize_cache(ctr, row) ψ_top * ψ_bot end @@ -834,7 +704,6 @@ end function sweep_gauges!( ctr::MpsContractor{T,NoUpdate}, row::Site, - indβ::Int, tol::Real = 1E-4, max_sweeps::Int = 10, ) where {T} @@ -845,11 +714,10 @@ end function update_gauges!( ctr::MpsContractor{T,S}, row::Site, - indβ::Vector{Int}, ::Val{:down}, ) where {T,S} - for j ∈ indβ, i ∈ 1:row-1 - sweep_gauges!(ctr, i, j) + for i ∈ 1:row-1 + sweep_gauges!(ctr, i) end end @@ -857,11 +725,10 @@ end function update_gauges!( ctr::MpsContractor{T,S}, row::Site, - indβ::Vector{Int}, ::Val{:up}, ) where {T,S} - for j ∈ indβ, i ∈ row-1:-1:1 - sweep_gauges!(ctr, i, j) + for i ∈ row-1:-1:1 + sweep_gauges!(ctr, i) end end diff --git a/src/droplets.jl b/src/droplets.jl index 2fffa23d..18d05424 100644 --- a/src/droplets.jl +++ b/src/droplets.jl @@ -40,7 +40,7 @@ struct SingleLayerDroplets min_size::Int metric::Symbol mode::Symbol - SingleLayerDroplets( + SingleLayerDroplets(; max_energy = 1.0, min_size = 1, metric = :no_metric, diff --git a/src/king_single_node.jl b/src/king_single_node.jl index e646c186..fda82653 100644 --- a/src/king_single_node.jl +++ b/src/king_single_node.jl @@ -188,16 +188,16 @@ function conditional_probability( ctr::MpsContractor{S}, ∂v::Vector{Int}, ) where {T<:KingSingleNode,S} - indβ, β = length(ctr.betas), last(ctr.betas) + β = ctr.beta i, j = ctr.current_node - L = left_env(ctr, i, ∂v[1:2*j-2], indβ) - R = right_env(ctr, i, ∂v[(2*j+3):2*ctr.peps.ncols+2], indβ) + L = left_env(ctr, i, ∂v[1:2*j-2]) + R = right_env(ctr, i, ∂v[(2*j+3):2*ctr.peps.ncols+2]) if ctr.onGPU R = CuArray(R) end - ψ = dressed_mps(ctr, i, indβ) + ψ = dressed_mps(ctr, i) MX, M = ψ[j-1//2], ψ[j] @tensor LMX[y, z] := L[x] * MX[x, y, z] @@ -205,7 +205,7 @@ function conditional_probability( v = ((i, j - 1), (i - 1, j - 1), (i - 1, j)) @nexprs 3 k -> (en_k = projected_energy(ctr.peps, (i, j), v[k], ∂v[2*j-1+k])) probs = probability(local_energy(ctr.peps, (i, j)) .+ en_1 .+ en_2 .+ en_3, β) - + # println("probs1 ", probs) p_rb = projector(ctr.peps, (i, j), (i + 1, j - 1)) pr = projector(ctr.peps, (i, j), @ntuple 3 k -> (i + 2 - k, j + 1)) pd = projector(ctr.peps, (i, j), (i + 1, j)) @@ -219,7 +219,9 @@ function conditional_probability( m = @inbounds M[:, :, pd[σ]] r = @inbounds R[:, pr[σ]] @inbounds probs[σ] *= (lmx'*m*r)[] + # println("probs2 ", probs) end + # println("probs3 ", probs) push!(ctr.statistics, ((i, j), ∂v) => error_measure(probs)) normalize_probability(probs) diff --git a/src/search.jl b/src/search.jl index 521e97a2..266c2444 100644 --- a/src/search.jl +++ b/src/search.jl @@ -21,16 +21,16 @@ A struct representing search parameters for low-energy spectrum search. ## Fields - `max_states::Int`: The maximum number of states to be considered during the search. Default is 1, indicating a single state search. -- `cut_off_prob::Real`: The cutoff probability for terminating the search. Default is 0.0, meaning no cutoff based on probability. +- `cutoff_prob::Real`: The cutoff probability for terminating the search. Default is 0.0, meaning no cutoff based on probability. SearchParameters encapsulates parameters that control the behavior of low-energy spectrum search algorithms in the SpinGlassPEPS package. """ struct SearchParameters max_states::Int - cut_off_prob::Real + cutoff_prob::Real - function SearchParameters(; max_states::Int = 1, cut_off_prob::Real = 0.0) - new(max_states, cut_off_prob) + function SearchParameters(; max_states::Int = 1, cutoff_prob::Real = 0.0) + new(max_states, cutoff_prob) end end @@ -78,7 +78,7 @@ An empty `Solution` object with default field values, ready to store search resu fill(Vector{Int}[], n), zeros(T, n), ones(Int, n), - -Inf, + T(-Inf), repeat([NoDroplets()], n), fill(Vector{Int}[], n), ) @@ -214,20 +214,20 @@ Discards low-probability states from the given solution. ## Arguments - `psol::Solution`: The input solution containing states and their probabilities. -- `cut_off_prob::Real`: The cutoff probability below which states will be discarded. +- `cutoff_prob::Real`: The cutoff probability below which states will be discarded. ## Returns - `Solution`: A new solution with low-probability states discarded. ## Description -This function removes states from the solution `psol` whose probabilities are below the specified `cut_off_prob`. -It calculates a cutoff probability (`pcut`) based on the maximum probability in `psol` and the provided `cut_off_prob`. +This function removes states from the solution `psol` whose probabilities are below the specified `cutoff_prob`. +It calculates a cutoff probability (`pcut`) based on the maximum probability in `psol` and the provided `cutoff_prob`. States with probabilities lower than `pcut` are considered discarded. The largest discarded probability (`ldp`) in the resulting solution is updated based on the maximum discarded probability among the removed states and the existing `ldp` in `psol`. """ -function discard_probabilities!(psol::Solution, cut_off_prob::Real) - pcut = maximum(psol.probabilities) + log(cut_off_prob) +function discard_probabilities!(psol::Solution, cutoff_prob::Real) + pcut = maximum(psol.probabilities) + log(cutoff_prob) if minimum(psol.probabilities) >= pcut return psol end @@ -291,14 +291,14 @@ end $(TYPEDSIGNATURES) Merge branches of a contractor based on specified merge type and droplet update strategy. -This function merges branches of a contractor (`ctr`) based on a specified merge type (`merge_type`) -and an optional droplet update strategy (`update_droplets`). +This function merges branches of a contractor (`ctr`) based on a specified merge type (`merge_prob`) +and an optional droplet update strategy (`droplets_encoding`). It returns a function `_merge` that can be used to merge branches in a solution. ## Arguments - `ctr::MpsContractor{T}`: A contractor for which branches will be merged. -- `merge_type::Symbol=:nofit`: (Optional) The merge type to use. Defaults to `:nofit`. Possible values are `:nofit`, `:fit`, and `:python`. -- `update_droplets=NoDroplets()`: (Optional) The droplet update strategy. Defaults to `NoDroplets()`. You can provide a custom droplet update strategy if needed. +- `merge_prob::Symbol=:none `: (Optional) The merge type to use. Defaults to `:none `. Possible values are `:none `, `:median`, and `:tnac4o`. +- `droplets_encoding=NoDroplets()`: (Optional) The droplet update strategy. Defaults to `NoDroplets()`. You can provide a custom droplet update strategy if needed. ## Returns A function `_merge` that can be used to merge branches in a solution. @@ -308,8 +308,8 @@ The `_merge` function can be applied to a `Solution` object to merge its branche """ function merge_branches( ctr::MpsContractor{T}; - merge_type::Symbol = :nofit, - update_droplets = NoDroplets(), + merge_prob::Symbol = :none , + droplets_encoding = NoDroplets(), ) where {T} function _merge(psol::Solution) node = get(ctr.nodes_search_order, length(psol.states[1]) + 1, ctr.node_outside) @@ -344,22 +344,22 @@ function merge_branches( end end - if merge_type == :fit + if merge_prob == :median c = Statistics.median( - ctr.betas[end] .* nsol.energies[start:stop] .+ + ctr.beta .* nsol.energies[start:stop] .+ nsol.probabilities[start:stop], ) - new_prob = -ctr.betas[end] .* nsol.energies[best_idx] .+ c + new_prob = -ctr.beta .* nsol.energies[best_idx] .+ c push!(probs, new_prob) - elseif merge_type == :nofit + elseif merge_prob == :none push!(probs, nsol.probabilities[best_idx]) - elseif merge_type == :python + elseif merge_prob == :tnac4o push!(probs, Statistics.mean(nsol.probabilities[ind_deg])) end ## states with unique boundary => we take the one with best energy ## treat other states with the same boundary as droplets on top of the best one - excitation = update_droplets( + excitation = droplets_encoding( ctr, best_idx_bnd, nsol.energies[start:stop], @@ -395,8 +395,8 @@ Generate a function for merging branches in a Gibbs network with a Hamming dista ## Arguments - `ctr::MpsContractor{T}`: The contractor representing the contracted Gibbs network. - `hamming_cutoff::Int`: The Hamming distance cutoff for blur. -- `merge_type::Symbol=:nofit`: The merging strategy, defaults to `:nofit`. -- `update_droplets=NoDroplets()`: Droplet update method, defaults to `NoDroplets()`. +- `merge_prob::Symbol=:none `: The merging strategy, defaults to `:none `. +- `droplets_encoding=NoDroplets()`: Droplet update method, defaults to `NoDroplets()`. ## Returns A function `_merge_blur` that can be used to merge branches with Hamming distance blur in a solution. @@ -411,12 +411,12 @@ States with Hamming distances greater than or equal to the specified cutoff are function merge_branches_blur( ctr::MpsContractor{T}, hamming_cutoff::Int, - merge_type::Symbol = :nofit, - update_droplets = NoDroplets(), + merge_prob::Symbol = :none , + droplets_encoding = NoDroplets(), ) where {T} function _merge_blur(psol::Solution) psol = - merge_branches(ctr; merge_type = merge_type, update_droplets = update_droplets)( + merge_branches(ctr; merge_prob = merge_prob, droplets_encoding = droplets_encoding)( psol, ) node = get(ctr.nodes_search_order, length(psol.states[1]) + 1, ctr.node_outside) @@ -562,13 +562,13 @@ function low_energy_spectrum( schmidts = Dict() @showprogress "Preprocessing: " for i ∈ ctr.peps.nrows+1:-1:2 - ψ0 = mps(ctr, i, length(ctr.betas)) + ψ0 = mps(ctr, i) push!(schmidts, i => measure_spectrum(ψ0)) clear_memoize_cache_after_row() Memoization.empty_cache!(SpinGlassTensors.sparse) empty!(ctr.peps.lp, :GPU) if i <= ctr.peps.nrows - ψ0 = mps(ctr, i + 1, length(ctr.betas)) + ψ0 = mps(ctr, i + 1) move_to_CPU!(ψ0) end end @@ -584,7 +584,7 @@ function low_energy_spectrum( push!(s, k => v) end - ψ0 = mps(ctr, 2, length(ctr.betas)) + ψ0 = mps(ctr, 2) move_to_CPU!(ψ0) # Start branch and bound search @@ -610,7 +610,7 @@ function low_energy_spectrum( sol = Solution(sol, indices_with_even_numbers) # end end - sol = bound_solution(sol, sparams.max_states, sparams.cut_off_prob, merge_strategy) + sol = bound_solution(sol, sparams.max_states, sparams.cutoff_prob, merge_strategy) Memoization.empty_cache!(precompute_conditional) if no_cache Memoization.empty_all_caches!() @@ -692,7 +692,7 @@ function gibbs_sampling( clear_memoize_cache_after_row() end sol = branch_solution(sol, ctr) - sol = sampling(sol, sparams.max_states, sparams.cut_off_prob, merge_strategy) + sol = sampling(sol, sparams.max_states, sparams.cutoff_prob, merge_strategy) Memoization.empty_cache!(precompute_conditional) # TODO: clear memoize cache partially if no_cache diff --git a/src/square_cross_double_node.jl b/src/square_cross_double_node.jl index 3a2d9206..91f2316d 100644 --- a/src/square_cross_double_node.jl +++ b/src/square_cross_double_node.jl @@ -241,7 +241,7 @@ The function is specialized for the `SquareCrossDoubleNode` tensor network type current_node, ) where {T<:SquareCrossDoubleNode,S} i, j, k = current_node - β = last(ctr.betas) + β = ctr.beta if k == 1 en12 = interaction_energy(ctr.peps, (i, j, 1), (i, j, 2)) p12 = projector(ctr.peps, (i, j, 1), (i, j, 2)) @@ -400,16 +400,16 @@ function conditional_probability( ctr::MpsContractor{S}, ∂v::Vector{Int}, ) where {T<:SquareCrossDoubleNode,S} - indβ, β = length(ctr.betas), last(ctr.betas) + β = ctr.beta i, j, k = ctr.current_node - L = left_env(ctr, i, ∂v[1:2*j-2], indβ) - ψ = dressed_mps(ctr, i, indβ) + L = left_env(ctr, i, ∂v[1:2*j-2]) + ψ = dressed_mps(ctr, i) MX, M = ψ[j-1//2], ψ[j] @tensor LMX[y, z] := L[x] * MX[x, y, z] if k == 1 # here has to avarage over s2 - R = right_env(ctr, i, ∂v[(2*j+12):end], indβ) + R = right_env(ctr, i, ∂v[(2*j+12):end]) if ctr.onGPU R = CuArray(R) end @@ -456,7 +456,7 @@ function conditional_probability( LR .*= tele probs = Array(dropdims(sum(LR, dims = 2), dims = 2)) else # k == 2 - R = right_env(ctr, i, ∂v[(2*j+10):end], indβ) + R = right_env(ctr, i, ∂v[(2*j+10):end]) if ctr.onGPU R = CuArray(R) end diff --git a/src/square_double_node.jl b/src/square_double_node.jl index 1e1266fc..9ad6aacf 100644 --- a/src/square_double_node.jl +++ b/src/square_double_node.jl @@ -156,15 +156,15 @@ function conditional_probability( ctr::MpsContractor{S}, ∂v::Vector{Int}, ) where {T<:SquareDoubleNode,S} - indβ, β = length(ctr.betas), last(ctr.betas) + β = ctr.beta i, j, k = ctr.current_node - L = left_env(ctr, i, ∂v[1:j-1], indβ) - M = dressed_mps(ctr, i, indβ)[j] + L = left_env(ctr, i, ∂v[1:j-1]) + M = dressed_mps(ctr, i)[j] @tensor LM[y, z] := L[x] * M[x, y, z] if k == 1 # here has to avarage over s2 - R = right_env(ctr, i, ∂v[(j+8):end], indβ) + R = right_env(ctr, i, ∂v[(j+8):end]) if ctr.onGPU R = CuArray(R) end @@ -201,7 +201,7 @@ function conditional_probability( probs = dropdims(sum(Array(LR) .* ele, dims = 2), dims = 2) else # k == 2 ; here s1 is fixed - R = right_env(ctr, i, ∂v[(j+7):end], indβ) + R = right_env(ctr, i, ∂v[(j+7):end]) if ctr.onGPU R = CuArray(R) end diff --git a/src/square_single_node.jl b/src/square_single_node.jl index d547e47c..a7475425 100644 --- a/src/square_single_node.jl +++ b/src/square_single_node.jl @@ -247,15 +247,15 @@ function conditional_probability( ctr::MpsContractor{S}, ∂v::Vector{Int}, ) where {T<:SquareSingleNode,S} - indβ, β = length(ctr.betas), last(ctr.betas) + β = ctr.beta i, j = ctr.current_node - L = left_env(ctr, i, ∂v[1:j-1], indβ) - R = right_env(ctr, i, ∂v[(j+2):ctr.peps.ncols+1], indβ) + L = left_env(ctr, i, ∂v[1:j-1]) + R = right_env(ctr, i, ∂v[(j+2):ctr.peps.ncols+1]) if ctr.onGPU R = CuArray(R) end - M = dressed_mps(ctr, i, indβ)[j] + M = dressed_mps(ctr, i)[j] @tensor LM[y, z] := L[x] * M[x, y, z] diff --git a/src/util.jl b/src/util.jl index 7982df18..ba336dd9 100644 --- a/src/util.jl +++ b/src/util.jl @@ -46,14 +46,14 @@ The `exact_marginal_probability` function calculates the exact marginal probabil It decodes the provided state vector `σ` using the `decode_state` function, obtains the exact spectrum and states from the Potts Hamiltonian of the associated PEPS, and computes the marginal probability of the target state using the Boltzmann distribution. The function utilizes the `exact_spectrum` function to obtain the energies and states of the Potts Hamiltonian, -exponentiates the negative energies multiplied by the inverse temperature (`ctr.betas[end]`), normalizes the probabilities, +exponentiates the negative energies multiplied by the inverse temperature (`ctr.beta`), normalizes the probabilities, and calculates the marginal probability of the target state. """ function exact_marginal_probability(ctr::MpsContractor{T}, σ::Vector{Int}) where {T} # TODO: Not going to work without PoolOfProjectors target_state = decode_state(ctr.peps, σ, true) energies, states = exact_spectrum(ctr.peps.potts_hamiltonian) - prob = exp.(-ctr.betas[end] .* energies) + prob = exp.(-ctr.beta .* energies) prob ./= sum(prob) sum(prob[findall([all(s[k] == v for (k, v) ∈ target_state) for s ∈ states])]) end diff --git a/test/chimera_overlap_python.jl b/test/chimera_overlap_python.jl index 6b031798..74ad530c 100644 --- a/test/chimera_overlap_python.jl +++ b/test/chimera_overlap_python.jl @@ -24,8 +24,8 @@ potts_h = potts_hamiltonian( cluster_assignment_rule = super_square_lattice((m, n, t)), ) -params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) -search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) +params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) +search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) Strategy = SVDTruncate Gauge = NoUpdate @@ -44,14 +44,14 @@ Gauge = NoUpdate network, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) @testset "Compare the results with Python" begin overlap_python = [0.2637787707674837, 0.2501621729619047, 0.2951954406837012] for i = 1:n-1 - psi_top = mps_top(ctr, i, 4) - psi_bottom = mps(ctr, i + 1, 4) + psi_top = mps_top(ctr, i) + psi_bottom = mps(ctr, i + 1) overlap = psi_top * psi_bottom @test isapprox(overlap, overlap_python[i], atol = 1e-5) end @@ -75,12 +75,12 @@ end net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) for i = 1:n-1 - psi_top = mps_top(ctr, i, 4) - psi_bottom = mps(ctr, i + 1, 4) + psi_top = mps_top(ctr, i) + psi_bottom = mps(ctr, i + 1) overlap = psi_top * psi_bottom @test isapprox(overlap, overlap_python[i], atol = 1e-5) end diff --git a/test/experimental/gauges.jl b/test/experimental/gauges.jl index f8706bb0..54edbcf6 100644 --- a/test/experimental/gauges.jl +++ b/test/experimental/gauges.jl @@ -31,14 +31,13 @@ search_params = SearchParameters(num_states, δp) # for Sparsity ∈ (Dense, Sparse), transform ∈ all_lattice_transformations[[1]] # for Layout ∈ (GaugesEnergy, EnergyGauges, EngGaugesEng) # net = PEPSNetwork{Lattice{Layout}, Sparsity}(m, n, potts_h, transform, :id) -# ctr_svd = MpsContractor{SVDTruncate, GaugeStrategy}(net, [β/8, β/4, β/2, β], :graduate_truncate, params; onGPU=onGPU) -# ctr_anneal = MpsContractor{MPSAnnealing, GaugeStrategy}(net, [β/8, β/4, β/2, β], :graduate_truncate, params; onGPU=onGPU) +# ctr_svd = MpsContractor{SVDTruncate, GaugeStrategy}(net, [β/8, β/4, β/2, β], true, params; onGPU=onGPU) +# ctr_anneal = MpsContractor{MPSAnnealing, GaugeStrategy}(net, [β/8, β/4, β/2, β], true, params; onGPU=onGPU) # @testset "Overlaps calculated for different Starategies are the same." begin -# indβ = 3 # for i ∈ 1:m-1 -# ψ_top = mps_top(ctr_svd, i, indβ) -# ϕ_top = mps_top(ctr_anneal, i, indβ) +# ψ_top = mps_top(ctr_svd, i) +# ϕ_top = mps_top(ctr_anneal, i) # @test ψ_top * ψ_top ≈ 1 # @test ϕ_top * ϕ_top ≈ 1 # @test ψ_top * ϕ_top ≈ 1 @@ -49,14 +48,13 @@ search_params = SearchParameters(num_states, δp) # for Layout ∈ (GaugesEnergy,) # net = PEPSNetwork{Lattice{Layout}, Sparsity}(m, n, potts_h, transform, :id) -# ctr_svd = MpsContractor{SVDTruncate, GaugeStrategy}(net, [β/8, β/4, β/2, β], :graduate_truncate, params; onGPU=onGPU) +# ctr_svd = MpsContractor{SVDTruncate, GaugeStrategy}(net, [β/8, β/4, β/2, β], true, params; onGPU=onGPU) # @testset "Overlaps calculated in Python are the same as in Julia." begin -# indβ = [4, ] # overlap_python = [0.2637787707674837, 0.2501621729619047, 0.2951954406837012] # for i ∈ vcat(1:m-1)#, m-1:-1:1) -# ψ_top = mps_top(ctr_svd, i, indβ[begin]) -# ψ_bot = mps(ctr_svd, i+1, indβ[begin]) +# ψ_top = mps_top(ctr_svd, i) +# ψ_bot = mps(ctr_svd, i+1) # overlap1 = ψ_top * ψ_bot # @test isapprox(overlap1, overlap_python[i], atol=1e-5) # end @@ -68,7 +66,7 @@ search_params = SearchParameters(num_states, δp) # end @testset "Updating gauges works correctly." begin - for Strategy ∈ (SVDTruncate, MPSAnnealing), Sparsity ∈ (Dense, Sparse) + for Strategy ∈ (SVDTruncate, ), Sparsity ∈ (Dense, Sparse) for Layout ∈ (GaugesEnergy,) for Gauge ∈ (GaugeStrategy,) for Lattice ∈ (SquareSingleNode, KingSingleNode), @@ -85,19 +83,18 @@ search_params = SearchParameters(num_states, δp) net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) @testset "Overlaps calculated differently are the same." begin - indβ = 3 for i ∈ 1:m-1 - ψ_top = mps_top(ctr, i, indβ) - ψ_bot = mps(ctr, i + 1, indβ) + ψ_top = mps_top(ctr, i) + ψ_bot = mps(ctr, i + 1) try - overlap = tr(overlap_density_matrix(ψ_top, ψ_bot, indβ)) + overlap = tr(overlap_density_matrix(ψ_top, ψ_bot, i)) @test overlap ≈ ψ_bot * ψ_top catch println(Strategy, " ", Sparsity, " ", Lattice, " ", i) @@ -111,15 +108,14 @@ search_params = SearchParameters(num_states, δp) clear_memoize_cache() # @testset "ψ_bot and ψ_top are not updated in place though memoize!" begin - # indβ = [3,] # for aba in 1:3, i ∈ 1:m-1 # println(aba," ", i) - # ψ_top = mps_top(ctr, i, indβ[begin]) - # ψ_bot = mps(ctr, i+1, indβ[begin]) + # ψ_top = mps_top(ctr, i) + # ψ_bot = mps(ctr, i+1) # overlap_old = ψ_top * ψ_bot - # update_gauges!(ctr, i, indβ, Val(:down)) + # update_gauges!(ctr, i, Val(:down)) # # assert that ψ_bot and ψ_top are not updated in place though memoize! # overlap_old2 = ψ_bot * ψ_top @@ -133,11 +129,10 @@ search_params = SearchParameters(num_states, δp) # clear_memoize_cache() # @testset "Updating gauges from top and bottom gives the same energy." begin - # indβ = [3,] - # update_gauges!(ctr, m, indβ, Val(:down)) + # update_gauges!(ctr, m, Val(:down)) # sol_l, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) # clear_memoize_cache() - # update_gauges!(ctr, m, indβ, Val(:up)) + # update_gauges!(ctr, m, Val(:up)) # sol_r, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) # @test sol_l.energies[begin] ≈ sol_r.energies[begin] # end diff --git a/test/experimental/gauges_cuda.jl b/test/experimental/gauges_cuda.jl index afcf6544..f4bc37c1 100644 --- a/test/experimental/gauges_cuda.jl +++ b/test/experimental/gauges_cuda.jl @@ -17,15 +17,14 @@ end DE = 16.0 δp = 1E-5 * exp(-β * DE) ig = ising_graph("$(@__DIR__)/../instances/pegasus_random/minimal.txt") - INDβ = [1, 2, 3] potts_h = potts_hamiltonian( ig, spectrum = my_brute_force, cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - params = MpsParameters{Float64}(BOND_DIM, VAR_TOL, MAX_SWEEPS, TOL_SVD) - search_params = SearchParameters(MAX_STATES, δp) + params = MpsParameters{Float64}(;bond_dim=BOND_DIM, var_tol=VAR_TOL, num_sweeps=MAX_SWEEPS, tol_SVD=TOL_SVD) + search_params = SearchParameters(;max_states=MAX_STATES, cutoff_prob=δp) Gauge = GaugeStrategy Strategy = Zipper Sparsity = Sparse @@ -44,17 +43,17 @@ end net, params; onGPU = onGPU, - βs = [β / 6, β / 3, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) - update_gauges!(ctr, m, INDβ, Val(:up)) + update_gauges!(ctr, m, Val(:up)) sol, s = low_energy_spectrum(ctr, search_params) #sol = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) - @test sol.energies ≈ energy.(Ref(ig), ig_states) + @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(ig), ig_states) potts_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) + @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) # println( maximum(abs.(norm_prob ./ exp.(-β .* (sol.energies .- sol.energies[1]))) .- 1 )) diff --git a/test/experimental/mpo_size.jl b/test/experimental/mpo_size.jl index f865d767..670fa929 100644 --- a/test/experimental/mpo_size.jl +++ b/test/experimental/mpo_size.jl @@ -33,7 +33,6 @@ Dcut = 8 tolV = 1E-16 tolS = 1E-16 max_sweeps = 1 -indβ = 1 ITERS_SVD = 1 ITERS_VAR = 1 DTEMP_MULT = 2 @@ -82,17 +81,16 @@ for cl_states in cluster_states Gauge = NoUpdate i = div(m, 2) - indβ = 1 net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparse,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; onGPU = onGPU, - βs = [β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) - Ws = SpinGlassEngine.mpo(ctr, ctr.layers.main, i, indβ) + Ws = SpinGlassEngine.mpo(ctr, ctr.layers.main, i) # println(" Ws -> ", which_device(Ws), " ", format_bytes.(measure_memory(Ws))) # println(ctr.layers.main) site = Ws[3].ctr diff --git a/test/experimental/sampling.jl b/test/experimental/sampling.jl index f3bdc80d..44631490 100644 --- a/test/experimental/sampling.jl +++ b/test/experimental/sampling.jl @@ -40,8 +40,8 @@ ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; onGPU = onGPU, - βs = [β / 8.0, β / 4.0, β / 2.0, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol = gibbs_sampling(ctr, search_params) diff --git a/test/experimental/search_chimera_gauge.jl b/test/experimental/search_chimera_gauge.jl index 74ee0d2a..8c0d6e5d 100644 --- a/test/experimental/search_chimera_gauge.jl +++ b/test/experimental/search_chimera_gauge.jl @@ -11,8 +11,7 @@ TOL_SVD = 1E-16 DE = 16.0 δp = 1E-5 * exp(-β * DE) - instance = "$(@__DIR__)/instances/chimera_droplets/512power/001.txt" - INDβ = [1, 2, 3] + instance = "$(@__DIR__)/../instances/chimera_droplets/512power/001.txt" ig = ising_graph(instance) potts_h = potts_hamiltonian( ig, @@ -20,8 +19,8 @@ cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(BOND_DIM, VAR_TOL, MAX_SWEEPS, TOL_SVD) - search_params = SearchParameters(MAX_STATES, δp) + params = MpsParameters{Float64}(; bond_dim=BOND_DIM, var_tol=VAR_TOL, num_sweeps=MAX_SWEEPS, tol_SVD=TOL_SVD) + search_params = SearchParameters(; max_states=MAX_STATES, cutoff_prob=δp) Gauge = GaugeStrategy energies = Vector{Float64}[] @@ -38,17 +37,17 @@ net, params; onGPU = onGPU, - βs = [β / 6, β / 3, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) - update_gauges!(ctr, m, INDβ, Val(:up)) - sol, s = low_energy_spectrum(ctr, search_params) - #sol = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) + update_gauges!(ctr, m, Val(:up)) + # sol, s = low_energy_spectrum(ctr, search_params) + sol, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) - @test sol.energies ≈ energy.(Ref(ig), ig_states) + @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(ig), ig_states) potts_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) + @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) # println( maximum(abs.(norm_prob ./ exp.(-β .* (sol.energies .- sol.energies[1]))) .- 1 )) diff --git a/test/experimental/squarestar_double_node_pegasus.jl b/test/experimental/squarestar_double_node_pegasus.jl index 0d579d08..6e984920 100644 --- a/test/experimental/squarestar_double_node_pegasus.jl +++ b/test/experimental/squarestar_double_node_pegasus.jl @@ -303,7 +303,7 @@ params = MpsParameters{Float64}(bond_dim, VAR_TOL, MS, TOL_SVD, ITERS_SVD, ITERS_VAR, DTEMP_MULT) search_params = SearchParameters(num_states, δp) energies = Vector{Float64}[] -Strategy = Zipper # MPSAnnealing # SVDTruncate +Strategy = Zipper # SVDTruncate Sparsity = Sparse #Dense Layout = GaugesEnergy Gauge = NoUpdate @@ -314,16 +314,16 @@ for tran ∈ all_lattice_transformations #[LatticeTransformation((1, 2, 3, 4), f net, params; onGPU = onGPU, - βs = [β / 6, β / 3, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum( ctr, search_params, merge_branches( ctr; - merge_type = :nofit, - update_droplets = SingleLayerDroplets(eng, hamming_dist, :hamming), + merge_prob = :none , + droplets_encoding = SingleLayerDroplets(; max_energy=eng, min_size=hamming_dist, metric=:hamming), ), ) println(sol.energies) diff --git a/test/experimental/squarestar_double_node_zephyr.jl b/test/experimental/squarestar_double_node_zephyr.jl index 77a47098..d0c54807 100644 --- a/test/experimental/squarestar_double_node_zephyr.jl +++ b/test/experimental/squarestar_double_node_zephyr.jl @@ -34,7 +34,7 @@ potts_h = potts_hamiltonian( iter = iter, ) -params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 10, ts = 1E-16) +params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 10, tol_SVD = 1E-16) search_params = SearchParameters(num_states, δp) # Solve using PEPS search @@ -50,8 +50,8 @@ ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; onGPU = onGPU, - βs = [β / 6, β / 3, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) # for i in 1//2 : 1//2 : m diff --git a/test/experimental/truncate.jl b/test/experimental/truncate.jl index 68518b73..69436e84 100644 --- a/test/experimental/truncate.jl +++ b/test/experimental/truncate.jl @@ -27,7 +27,6 @@ Dcut = 8 tolV = 1E-16 tolS = 1E-16 max_sweeps = 0 -indβ = 1 ITERS_SVD = 2 ITERS_VAR = 1 DTEMP_MULT = 2 @@ -42,7 +41,7 @@ params = MpsParameters(Dcut, tolV, max_sweeps, tolS, ITERS_SVD, ITERS_VAR, DTEMP_MULT, METHOD) search_params = SearchParameters(MAX_STATES, δp) -Strategy = Zipper # MPSAnnealing SVDTruncate +Strategy = Zipper # SVDTruncate Layout = GaugesEnergy Gauge = NoUpdate cl_states = [2^10] @@ -83,8 +82,8 @@ for cs ∈ cl_states net, params; onGPU = onGPU, - βs = [β / 6, β / 3, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, schmidts = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) println("sol ", sol) diff --git a/test/experimental/truncate_small.jl b/test/experimental/truncate_small.jl index ead4b2ce..10a48178 100644 --- a/test/experimental/truncate_small.jl +++ b/test/experimental/truncate_small.jl @@ -29,7 +29,6 @@ function run_test(instance, m, n, t) tolV = 1E-16 tolS = 1E-16 max_sweeps = 1 - indβ = 1 ITERS_SVD = 1 ITERS_VAR = 1 DTEMP_MULT = 2 @@ -52,7 +51,6 @@ function run_test(instance, m, n, t) search_params = SearchParameters(num_states, δp) energies = [] Gauge = NoUpdate - βs = [β / 16, β / 8, β / 4, β / 2, β] Strategy = Zipper Sparsity = Sparse Layout = GaugesEnergy @@ -86,8 +84,8 @@ function run_test(instance, m, n, t) net, params; onGPU = onGPU, - βs = βs, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, schmidts = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) #, merge_branches(ctr)) diff --git a/test/experimental/zipper.jl b/test/experimental/zipper.jl index fcdf1efc..39067f76 100644 --- a/test/experimental/zipper.jl +++ b/test/experimental/zipper.jl @@ -22,15 +22,11 @@ end m, n, t = 8, 8, 8 -β = 1 -Dcut = 8 - β = 1.0 Dcut = 7 tolV = 0.01 tolS = 0.0 max_sweeps = 4 -indβ = 1 ig = ising_graph("$(@__DIR__)/../instances/chimera_droplets/512power/001.txt") @@ -48,17 +44,16 @@ Layout = EnergyGauges Gauge = NoUpdate i = div(m, 2) -indβ = 1 net = PEPSNetwork{SquareSingleNode{Layout},Sparse,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; onGPU = onGPU, - βs = [β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) -Ws = SpinGlassEngine.mpo(ctr, ctr.layers.main, i, indβ) +Ws = SpinGlassEngine.mpo(ctr, ctr.layers.main, i) println(" Ws -> ", which_device(Ws), " ", format_bytes.(measure_memory(Ws))) net = PEPSNetwork{SquareSingleNode{Layout},Dense,Float64}(m, n, potts_h, tran) @@ -66,10 +61,10 @@ ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; onGPU = onGPU, - βs = [β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) -Wd = SpinGlassEngine.mpo(ctr, ctr.layers.main, i, indβ) +Wd = SpinGlassEngine.mpo(ctr, ctr.layers.main, i) println(" Wd -> ", which_device(Wd), " ", format_bytes.(measure_memory(Wd))) println( diff --git a/test/mwe.jl b/test/mwe.jl index 2e1c0a13..b7ab8f27 100644 --- a/test/mwe.jl +++ b/test/mwe.jl @@ -6,9 +6,11 @@ m, n, t = 3, 4, 1 bond_dim = 8 mstates = 10 instance = "$(@__DIR__)/instances/pathological/pegasus_3_4_1.txt" - +RESULTS_FOLDER="$(@__DIR__)/instances/pathological" +inst="001" iter = 2 δp = 0.0 +cs=2^0 MAX_SWEEPS = 0 VAR_TOL = 1E-16 TOL_SVD = 1E-16 @@ -27,6 +29,7 @@ potts_h = potts_hamiltonian( spectrum = full_spectrum, cluster_assignment_rule = pegasus_lattice((m, n, t)), ) +potts_h = truncate_potts_hamiltonian(potts_h, β, cs, RESULTS_FOLDER, inst; tol=1e-6, iter=iter) Gauge = NoUpdate for T in [Float64, Float32] @@ -34,24 +37,20 @@ for T in [Float64, Float32] println("type ", T) energies = Vector{T}[] params = MpsParameters{T}(; - bond_dim, - T(VAR_TOL), - MAX_SWEEPS, - T(TOL_SVD), - ITERS_SVD, - ITERS_VAR, - DTEMP_MULT, - METHOD, + bond_dim=bond_dim, + var_tol = T(VAR_TOL), + num_sweeps = MAX_SWEEPS, + tol_SVD = T(TOL_SVD), ) - search_params = SearchParameters(mstates, δp) + search_params = SearchParameters(;max_states=mstates, cutoff_prob=δp) net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,T}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,T}( net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = T(β), + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) @test eltype(sol.energies) == T diff --git a/test/random_markov_field.jl b/test/random_markov_field.jl index d07861ff..97c40eb8 100644 --- a/test/random_markov_field.jl +++ b/test/random_markov_field.jl @@ -7,10 +7,10 @@ num_states = 64 potts_h = potts_hamiltonian(instance_dir) Nx, Ny = get_prop(potts_h, :Nx), get_prop(potts_h, :Ny) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) Gauge = NoUpdate - graduate_truncation = :graduate_truncate + graduate_truncation = true energies = Vector{Float64}[] Strategy = Zipper Layout = GaugesEnergy @@ -21,8 +21,8 @@ net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, mode = :RMF, ) sol_peps, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) diff --git a/test/runtests.jl b/test/runtests.jl index 0fd811fd..24679370 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,7 +18,7 @@ my_tests = [] push!( my_tests, - # quick tests: + #quick tests: "operations.jl", "branch_and_bound.jl", "search_chimera_pathological.jl", diff --git a/test/search_chimera_droplets.jl b/test/search_chimera_droplets.jl index c86033fb..9b9a9739 100644 --- a/test/search_chimera_droplets.jl +++ b/test/search_chimera_droplets.jl @@ -16,7 +16,6 @@ function bench(instance::String) dE = 3.0 δp = exp(-β * dE) num_states = 500 - all_betas = [β / 8, β / 4, β / 2, β] potts_h = potts_hamiltonian( ising_graph(instance), @@ -24,8 +23,8 @@ function bench(instance::String) spectrum = my_brute_force, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4, ts = 1E-16) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4, tol_SVD = 1E-16) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) energies = Vector{Float64}[] for Strategy ∈ (Zipper,), Sparsity ∈ (Dense,) @@ -41,16 +40,16 @@ function bench(instance::String) net, params; onGPU = onGPU, - βs = all_betas, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol1, s = low_energy_spectrum( ctr, search_params, merge_branches( ctr; - merge_type = :nofit, - update_droplets = SingleLayerDroplets(1.0, 1000, :hamming), + merge_prob = :none , + droplets_encoding = SingleLayerDroplets(; max_energy=1, min_size=1000, metric=:hamming), ), ) diff --git a/test/search_chimera_full.jl b/test/search_chimera_full.jl index 40733607..f983ab13 100644 --- a/test/search_chimera_full.jl +++ b/test/search_chimera_full.jl @@ -15,7 +15,6 @@ function bench(instance::String) dE = 3.0 δp = exp(-β * dE) num_states = 500 - all_betas = [β / 8, β / 4, β / 2, β] potts_h = potts_hamiltonian( ising_graph(instance), @@ -23,8 +22,8 @@ function bench(instance::String) spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4, ts = 1E-16) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4, tol_SVD = 1E-16) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) energies = Vector{Float64}[] for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Dense, Sparse) @@ -41,13 +40,13 @@ function bench(instance::String) net, params; onGPU = onGPU, - βs = all_betas, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum( ctr, search_params, - merge_branches(ctr; merge_type = :nofit), + merge_branches(ctr; merge_prob = :none ), ) @test sol.energies[begin] ≈ ground_energy diff --git a/test/search_chimera_pathological.jl b/test/search_chimera_pathological.jl index 21381225..9bd343ed 100644 --- a/test/search_chimera_pathological.jl +++ b/test/search_chimera_pathological.jl @@ -5,7 +5,7 @@ Layout = $Layout Lattice = $Lattice transform = $transform " for Sparsity ∈ (Dense, Sparse), - Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), + Strategy ∈ (SVDTruncate, Zipper), Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations @@ -114,8 +114,8 @@ transform = $transform spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate energies = Vector{Float64}[] @@ -126,8 +126,8 @@ transform = $transform net, params; onGPU = onGPU, - βs = [β / 8.0, β / 4.0, β / 2.0, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) diff --git a/test/search_chimera_pathological_Z2.jl b/test/search_chimera_pathological_Z2.jl index fc290780..ec904f1b 100644 --- a/test/search_chimera_pathological_Z2.jl +++ b/test/search_chimera_pathological_Z2.jl @@ -103,12 +103,12 @@ spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate energies = Vector{Float64}[] - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) + for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Dense, Sparse) for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng) for Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations @@ -123,16 +123,16 @@ net, params; onGPU = onGPU, - βs = [β / 8.0, β / 4.0, β / 2.0, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol1, s = low_energy_spectrum( ctr, search_params, merge_branches( ctr; - merge_type = :nofit, - update_droplets = SingleLayerDroplets(10.0, 0, :hamming), + merge_prob = :none , + droplets_encoding = SingleLayerDroplets(; max_energy=10.0, min_size=0, metric=:hamming), ), :Z2, ) diff --git a/test/search_chimera_pathological_droplets.jl b/test/search_chimera_pathological_droplets.jl index c379375f..1d3092bc 100644 --- a/test/search_chimera_pathological_droplets.jl +++ b/test/search_chimera_pathological_droplets.jl @@ -104,12 +104,12 @@ spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate energies = Vector{Float64}[] - # for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) + # for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Dense, Sparse) # for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng) # for Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations for Strategy ∈ (Zipper,), Sparsity ∈ (Dense,) @@ -126,8 +126,8 @@ net, params; onGPU = onGPU, - βs = [β / 8.0, β / 4.0, β / 2.0, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol1, s = low_energy_spectrum( ctr, @@ -135,11 +135,11 @@ merge_branches_blur( ctr, hamming_dist, - :nofit, - SingleLayerDroplets(1.01, 1, :hamming), + :none , + SingleLayerDroplets(; max_energy=1.01, min_size=1, metric=:hamming), ), ) - # sol1, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr, :nofit, SingleLayerDroplets(1.01, 1, :hamming))) + # sol1, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr, :none , SingleLayerDroplets(1.01, 1, :hamming))) @test sol1.energies ≈ [exact_energies[1]] sol2 = unpack_droplets(sol1, β) diff --git a/test/search_chimera_pathological_hamming.jl b/test/search_chimera_pathological_hamming.jl index 7bee9ee9..35650d86 100644 --- a/test/search_chimera_pathological_hamming.jl +++ b/test/search_chimera_pathological_hamming.jl @@ -117,8 +117,8 @@ end cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate energies = Vector{Float64}[] @@ -137,8 +137,8 @@ end net, params; onGPU = onGPU, - βs = [β / 8.0, β / 4.0, β / 2.0, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol1, s = low_energy_spectrum( ctr, @@ -146,8 +146,8 @@ end merge_branches_blur( ctr, hamming_dist, - :nofit, - SingleLayerDroplets(1.01, 10, :hamming), + :none , + SingleLayerDroplets(; max_energy=1.01, min_size=10, metric=:hamming), ), ) @test sol1.energies ≈ [exact_energies[1]] diff --git a/test/search_chimera_smallest.jl b/test/search_chimera_smallest.jl index ed266a82..f322474a 100644 --- a/test/search_chimera_smallest.jl +++ b/test/search_chimera_smallest.jl @@ -16,11 +16,11 @@ cluster_assignment_rule = super_square_lattice((m, n, t)), ) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate for T in [Float32, Float64] energies = Vector{T}[] - params = MpsParameters{T}(; bd = bond_dim, ϵ = T(1E-8), sw = 4) + params = MpsParameters{T}(; bond_dim = bond_dim, var_tol = T(1E-8), num_sweeps = 4) for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Dense, Sparse), Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), @@ -31,8 +31,8 @@ net, params; onGPU = onGPU, - βs = T[β/8, β/4, β/2, β], - graduate_truncation = :graduate_truncate, + beta = T(β), + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) @test eltype(sol.energies) == T diff --git a/test/search_chimera_smallest_droplets.jl b/test/search_chimera_smallest_droplets.jl index a7af33e8..8ca2fe45 100644 --- a/test/search_chimera_smallest_droplets.jl +++ b/test/search_chimera_smallest_droplets.jl @@ -16,8 +16,8 @@ cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate energies = Vector{Float64}[] @@ -34,8 +34,8 @@ net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol1, s = low_energy_spectrum( @@ -43,8 +43,8 @@ search_params, merge_branches( ctr; - merge_type = :nofit, - update_droplets = SingleLayerDroplets(2.2, 1, :hamming), + merge_prob = :none , + droplets_encoding = SingleLayerDroplets(; max_energy=2.2, min_size=1, metric=:hamming), ), ) diff --git a/test/search_cross_square_star.jl b/test/search_cross_square_star.jl index 6b283ec6..d7fa5ea5 100644 --- a/test/search_cross_square_star.jl +++ b/test/search_cross_square_star.jl @@ -15,12 +15,12 @@ spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) Gauge = NoUpdate energies = Vector{Float64}[] - for Strategy ∈ (MPSAnnealing, Zipper, SVDTruncate), Sparsity ∈ (Dense, Sparse) + for Strategy ∈ (Zipper, SVDTruncate), Sparsity ∈ (Dense, Sparse) for Layout ∈ (GaugesEnergy, EngGaugesEng, EnergyGauges) # for transform ∈ all_lattice_transformations, Lattice ∈ (KingSingleNode,) net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, potts_h, transform) @@ -28,8 +28,8 @@ net, params; onGPU = onGPU, - βs = [β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) diff --git a/test/search_full_chimera.jl b/test/search_full_chimera.jl index 0161d870..ccbd312d 100644 --- a/test/search_full_chimera.jl +++ b/test/search_full_chimera.jl @@ -24,7 +24,7 @@ function bench() #for transform ∈ all_lattice_transformations peps = PEPSNetwork(m, n, fg, rotation(0), β = β, bond_dim = 32) - kupdate_gauges!(peps, :rand) + update_gauges!(peps, :rand) @time sol = low_energy_spectrum(peps, num_states)#, merge_branches(peps, 1.0)) println(sol.energies[1:1]) end diff --git a/test/search_pegasus_droplets.jl b/test/search_pegasus_droplets.jl index 415d8477..38dcd855 100644 --- a/test/search_pegasus_droplets.jl +++ b/test/search_pegasus_droplets.jl @@ -16,7 +16,6 @@ function bench(instance::String) dE = 3.0 δp = exp(-β * dE) num_states = 500 - all_betas = [β / 8, β / 4, β / 2, β] potts_h = potts_hamiltonian( ising_graph(instance), @@ -24,8 +23,8 @@ function bench(instance::String) spectrum = my_brute_force, cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4, ts = 1E-16) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4, tol_SVD = 1E-16) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) energies = Vector{Float64}[] for Strategy ∈ (Zipper,), Sparsity ∈ (Sparse,) @@ -41,16 +40,16 @@ function bench(instance::String) net, params; onGPU = onGPU, - βs = all_betas, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol1, s = low_energy_spectrum( ctr, search_params, merge_branches( ctr; - merge_type = :nofit, - update_droplets = SingleLayerDroplets(0.01, 20, :hamming), + merge_prob = :none , + droplets_encoding = SingleLayerDroplets(; max_energy=0.01, min_size=20, metric=:hamming), ), ) diff --git a/test/search_pegasus_nodiag_square_cross.jl b/test/search_pegasus_nodiag_square_cross.jl index 36bb3f62..7e9df3c0 100644 --- a/test/search_pegasus_nodiag_square_cross.jl +++ b/test/search_pegasus_nodiag_square_cross.jl @@ -19,12 +19,12 @@ function bench(instance::String) spectrum = my_brute_force, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) # Solve using PEPS search energies = Vector{Float64}[] - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), + for Strategy ∈ (SVDTruncate, Zipper), transform ∈ all_lattice_transformations for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), Sparsity ∈ (Dense,) @@ -38,8 +38,8 @@ function bench(instance::String) net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol_peps, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) push!(energies, sol_peps.energies) diff --git a/test/search_pegasus_square_cross.jl b/test/search_pegasus_square_cross.jl index b32b6888..9aec4903 100644 --- a/test/search_pegasus_square_cross.jl +++ b/test/search_pegasus_square_cross.jl @@ -17,14 +17,14 @@ function bench(instance::String) spectrum = my_brute_force, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(max_states = num_states, cutoff_prob = δp) Gauge = NoUpdate - graduate_truncation = :graduate_truncate + graduate_truncation = true # Solve using PEPS search energies = Vector{Float64}[] - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), + for Strategy ∈ (SVDTruncate, Zipper), transform ∈ all_lattice_transformations for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), Sparsity ∈ (Dense,) @@ -38,7 +38,7 @@ function bench(instance::String) net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], + beta = β, graduate_truncation = graduate_truncation, ) sol_peps, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) diff --git a/test/search_smallest_cross_square_cross.jl b/test/search_smallest_cross_square_cross.jl index 57c1bce8..3790e2c1 100644 --- a/test/search_smallest_cross_square_cross.jl +++ b/test/search_smallest_cross_square_cross.jl @@ -15,10 +15,10 @@ spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = 0.0) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = 0.0) - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) + for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Dense, Sparse) for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng) for transform ∈ all_lattice_transformations net = PEPSNetwork{KingSingleNode{Layout},Sparsity,Float64}( @@ -31,8 +31,8 @@ net, params; onGPU = onGPU, - βs = [β / 8.0, β / 4.0, β / 2.0, β], - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) diff --git a/test/search_square_double_node_basic.jl b/test/search_square_double_node_basic.jl index e4083a89..f4e763c7 100644 --- a/test/search_square_double_node_basic.jl +++ b/test/search_square_double_node_basic.jl @@ -1,11 +1,10 @@ using SpinGlassEngine function run_test_square_double_node(instance, m, n, t) - β = 2 + β = 2.0 bond_dim = 16 δp = 1e-10 num_states = 512 - βs = [β / 16, β / 8, β / 4, β / 2, β] ig = ising_graph(instance) @@ -20,12 +19,12 @@ function run_test_square_double_node(instance, m, n, t) cluster_assignment_rule = super_square_lattice((m, n, 8)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) energies = [] Gauge = NoUpdate - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) + for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Dense, Sparse) for Layout ∈ (EnergyGauges, GaugesEnergy) for tran ∈ all_lattice_transformations @@ -42,15 +41,15 @@ function run_test_square_double_node(instance, m, n, t) net, params; onGPU = onGPU, - βs = βs, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) ctr2 = MpsContractor{Strategy,Gauge,Float64}( net2, params; onGPU = onGPU, - βs = βs, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) #, merge_branches(ctr)) @@ -76,13 +75,13 @@ function run_test_square_double_node(instance, m, n, t) exct_prob = exp.(-β .* (sol2.energies .- sol2.energies[1])) @test norm_prob ≈ exct_prob - for ii ∈ 1:ctr.peps.nrows+1, jj ∈ 1:length(βs) - ψ1, ψ2 = mps(ctr, ii, jj), mps(ctr2, ii, jj) + for ii ∈ 1:ctr.peps.nrows+1 + ψ1, ψ2 = mps(ctr, ii), mps(ctr2, ii) o = ψ1 * ψ2 / sqrt((ψ1 * ψ1) * (ψ2 * ψ2)) @test o ≈ 1.0 end - for ii ∈ 0:ctr.peps.nrows, jj ∈ 1:length(βs) - ψ1_top, ψ2_top = mps_top(ctr, ii, jj), mps_top(ctr2, ii, jj) + for ii ∈ 0:ctr.peps.nrows + ψ1_top, ψ2_top = mps_top(ctr, ii), mps_top(ctr2, ii) o_top = ψ1_top * ψ2_top / sqrt((ψ1_top * ψ1_top) * (ψ2_top * ψ2_top)) @test o_top ≈ 1.0 end diff --git a/test/search_square_lattice.jl b/test/search_square_lattice.jl index f1efcdf6..4e410058 100644 --- a/test/search_square_lattice.jl +++ b/test/search_square_lattice.jl @@ -15,12 +15,12 @@ function bench(instance::String) spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) Gauge = NoUpdate - graduate_truncation = :graduate_truncate + graduate_truncation = true energies = Vector{Float64}[] - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), + for Strategy ∈ (SVDTruncate, Zipper), transform ∈ all_lattice_transformations for Layout ∈ (GaugesEnergy, EnergyGauges, EngGaugesEng), Sparsity ∈ (Dense, Sparse) @@ -29,7 +29,7 @@ function bench(instance::String) net, params; onGPU = onGPU, - βs = [β / 8, β / 4, β / 2, β], + beta = β, graduate_truncation = graduate_truncation, ) sol_peps, s = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) diff --git a/test/search_squarecross_double_node_basic.jl b/test/search_squarecross_double_node_basic.jl index efef11f0..bd782ab1 100644 --- a/test/search_squarecross_double_node_basic.jl +++ b/test/search_squarecross_double_node_basic.jl @@ -2,7 +2,7 @@ using SpinGlassEngine using Test function run_test_squarecross_double_node(instance, m, n, t) - β = 2 + β = 2.0 bond_dim = 16 δp = 1e-10 num_states = 512 @@ -20,13 +20,12 @@ function run_test_squarecross_double_node(instance, m, n, t) cluster_assignment_rule = super_square_lattice((m, n, 8)), ) - params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) - search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) + params = MpsParameters{Float64}(; bond_dim = bond_dim, var_tol = 1E-8, num_sweeps = 4) + search_params = SearchParameters(; max_states = num_states, cutoff_prob = δp) energies = [] Gauge = NoUpdate - βs = [β / 16, β / 8, β / 4, β / 2, β] - for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Sparse,) + for Strategy ∈ (SVDTruncate, Zipper), Sparsity ∈ (Sparse,) for Layout ∈ (EnergyGauges, GaugesEnergy) for tran ∈ all_lattice_transformations @@ -47,15 +46,15 @@ function run_test_squarecross_double_node(instance, m, n, t) net, params; onGPU = onGPU, - βs = βs, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) ctr2 = MpsContractor{Strategy,Gauge,Float64}( net2, params; onGPU = onGPU, - βs = βs, - graduate_truncation = :graduate_truncate, + beta = β, + graduate_truncation = true, ) sol, s = low_energy_spectrum(ctr, search_params) #, merge_branches(ctr)) @@ -80,13 +79,13 @@ function run_test_squarecross_double_node(instance, m, n, t) exct_prob = exp.(-β .* (sol2.energies .- sol2.energies[1])) @test norm_prob ≈ exct_prob - for ii ∈ 1:ctr.peps.nrows+1, jj ∈ 1:length(βs) - ψ1, ψ2 = mps(ctr, ii, jj), mps(ctr2, ii, jj) + for ii ∈ 1:ctr.peps.nrows+1 + ψ1, ψ2 = mps(ctr, ii), mps(ctr2, ii) o = ψ1 * ψ2 / sqrt((ψ1 * ψ1) * (ψ2 * ψ2)) @test o ≈ 1.0 end - for ii ∈ 0:ctr.peps.nrows, jj ∈ 1:length(βs) - ψ1_top, ψ2_top = mps_top(ctr, ii, jj), mps_top(ctr2, ii, jj) + for ii ∈ 0:ctr.peps.nrows + ψ1_top, ψ2_top = mps_top(ctr, ii), mps_top(ctr2, ii) o_top = ψ1_top * ψ2_top / sqrt((ψ1_top * ψ1_top) * (ψ2_top * ψ2_top)) @test o_top ≈ 1.0 end