Contracting PEPS tensor network
Once we construct the tensor network, we can proceed with its contraction. The first step involves preparing structures to store information about the approximate contraction using the MPS-MPO method and the exploration of states through the branch-and-bound algorithm.
SpinGlassEngine.MpsContractor
— TypeMpsContractor is a mutable struct that represents the contractor responsible for contracting a PEPS (Projected Entangled Pair States) network using the MPO-MPS (Matrix Product Operator - Matrix Product State) scheme.
Type Parameters
T<:AbstractStrategy
: Specifies the contraction strategy to be employed.R<:AbstractGauge
: Specifies the gauge-fixing method used for optimizing the contraction.S<:Real
: Represents the numeric precision type for real values (e.g., Float64).
Constructor
This constructor initializes an instance of MpsContractor with the following arguments: Positional arguments:
net
: The PEPS network to be contracted.params
: Contains the control parameters for the MPO-MPS contraction, such as bond dimension and the number of sweeps.
Keyword arguments:
beta::S
: The inverse temperature, β, which is crucial for focusing on low-energy states. A larger β sharpens the focus on these states but may reduce the numerical stability of the tensor contraction. The optimal value of β often depends on the problem instance.graduate_truncation::Bool
: A flag indicating whether bond dimensions in the MPS are truncated progressively. When set to true, this truncation method adjusts the bond dimensions gradually during contraction.onGPU::Bool
: A flag indicating whether the computation should be performed on a GPU (default is true).depth::Int
: Specifies the depth of variational sweeps during the Zipper algorithm. A value of 0 implies a full variational sweep across all lattice sites.
The constructor sets up the internal structure of the contractor, including the MPO layers, search order for nodes, and storage for contraction statistics.
Structures to store parameters used in branch and bound search
SpinGlassEngine.MpsParameters
— TypeA struct representing control parameters for the MPO-MPS (Matrix Product Operator - Matrix Product State) scheme used to contract a PEPS (Projected Entangled Pair States) network.
Fields
bond_dimension::Int
: The maximum bond dimension to be used during contraction.variational_tol::Real
: The tolerance for the variational solver used in MPS optimization. It gives the condition for overlap convergence during one sweep in boundary MPS. Default is 1E-8.max_num_sweeps::Int
: The maximum number of sweeps to perform during variational compression. Default is 4.tol_SVD::Real
: The tolerance used in singular value decomposition (SVD) operations. It means that smaller singular values are truncated. Default is 1E-16.iters_svd::Int
: The number of iterations to perform in SVD computations. Default is 1.iters_var::Int
: The number of iterations for variational optimization. Default is 1.Dtemp_multiplier::Int
: A multiplier for the bond dimension when temporary bond dimensions are computed. Default is 2.method::Symbol
: The type of SVD method to use (e.g.,:psvd_sparse
). Default is:psvd_sparse
.
Keyword Arguments:
bond_dim
: Specifies the maximum bond dimension (default is typemax(Int)).var_tol
: Tolerance for the variational solver (default is 1E-8).num_sweeps
: Maximum number of sweeps for variational compression (default is 4).tol_SVD
: Tolerance for SVD operations (default is 1E-16).iters_svd
: Number of SVD iterations (default is 1).iters_var
: Number of iterations for variational optimization (default is 1).Dtemp_multiplier
: Multiplier for temporary bond dimensions (default is 2).method
: SVD method to use, such as :psvdsparse (default is :psvdsparse).
Description: The MpsParameters struct encapsulates various control parameters that influence the behavior and accuracy of the MPO-MPS contraction scheme used in PEPS network calculations. This allows fine-tuning of tolerances, iteration limits, and methods for efficient and accurate tensor network contractions.
SpinGlassEngine.SearchParameters
— TypeA struct representing search parameters for low-energy spectrum search.
Constructor
Keyword arguments:
max_states::Int
: The maximum number of states to be considered during the search. Default is 1, indicating a single state search.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.
Strategy
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
SVDTruncate
.
Zipper
method combines a zipper scheme of Ref.. with the standard variational optimization of the resulting MPS (see Ref.)

With the SVDTruncate
method, the Matrix Product State (MPS) is systematically constructed row by row, contracted with the Matrix Product Operator (MPO) from the preceding row. The resulting MPS undergoes a Singular Value Decomposition (SVD) to truncate its bond dimension, followed by variational compression.

Sparsity
The Sparsity
parameter controls whether
Dense
or
Sparse
tensor representations are used during calculations. Sparse
tensors are particularly useful for handling large clusters containing around 10 to 20 spins. When bond dimensions increase, constructing PEPS tensors explicitly (triggered by Sparsity=Dense
) becomes computationally expensive and quickly infeasible. In contrast, setting Sparsity=Sparse
avoids the direct construction of full tensors. Instead, it performs optimal contractions on smaller tensor structures, which are then combined to contract the entire network efficiently. This approach leverages the internal structure of the individual tensors to reduce computational overhead and memory usage.
Geometry
One can specify the type of the node used within the tensor networks:
SquareSingleNode

SpinGlassEngine.SquareSingleNode
— TypeA geometric structure representing a 1-layer grid with nodes arranged in a grid of rows and columns.
Type Parameters
T <: AbstractTensorsLayout
: The layout of decomposition of tensors into MPS. Can beGaugesEnergy
,EnergyGauges
orEngGaugesEng
.
Constructors
SquareDoubleNode(layout::T)
: Create aSquareDoubleNode
with the specified tensor layout.
SquareDoubleNode

SpinGlassEngine.SquareDoubleNode
— TypeA geometric structure representing a 2-layer grid with nodes arranged in rows and columns. Each node is labeled with a tuple (i, j, k), where i is the row index, j is the column index, and k is the layer index (1 or 2).
Type Parameters
T <: AbstractTensorsLayout
: The layout of decomposition of tensors into MPS. Can beGaugesEnergy
,EnergyGauges
orEngGaugesEng
.
Constructors
SquareDoubleNode(layout::T)
: Create aSquareDoubleNode
with the specified tensor layout.
KingSingleNode

SpinGlassEngine.KingSingleNode
— TypeA geometric structure representing a 1-layer grid with nodes arranged in a grid of rows and columns, and additional diagonal edges forming a cross pattern between neighboring nodes.
Type Parameters
T <: AbstractTensorsLayout
: The layout of decomposition of tensors into MPS. Can beGaugesEnergy
,EnergyGauges
orEngGaugesEng
.
Constructors
KingSingleNode(layout::T)
: Create aKingSingleNode
with the specified tensor layout.
SquareCrossDoubleNode

SpinGlassEngine.SquareCrossDoubleNode
— TypeA geometric structure representing a 2-layer grid with nodes arranged in rows and columns, and additional diagonal edges forming a cross pattern between neighboring nodes. Each node is labeled with a tuple (i, j, k), where i is the row index, j is the column index, and k is the layer index (1 or 2).
Type Parameters
T <: AbstractTensorsLayout
: The layout of decomposition of tensors into MPS. Can beGaugesEnergy
,EnergyGauges
orEngGaugesEng
.
Constructors
KingSingleNode(layout::T)
: Create aSquareCrossDoubleNode
with the specified tensor layout.
Description
SquareCrossDoubleNode
is a geometry type that models a double unit cell square lattice with diagonal interaction. This geometry is suitable for systems with tensors laid out according to the specified AbstractTensorsLayout
. It can be used in Pegasus and Zephyr graphs.
Layout
SpinGlassPEPS.jl
allows for different decompositions of the PEPS network into MPOs:
GaugesEnergy
EnergyGauges
EngGaugesEng
For complex problems, the solution may depend on the choice of decomposition.

Lattice transformations
Our package provides users with the ability to apply various transformations to the PEPS network, allowing for flexibility in tensor network manipulation. The available transformations include rotations
by multiples of $\frac{\pi}{2}$ radians and reflections
along different axes. Specifically, users can apply rotations and reflections around the horizontal (x), vertical (y), diagonal, and antidiagonal axes.
These transformations are useful when contracting PEPS or performing searches from different lattice sites. For instance, the transform
parameter allows the user to rotate the quasi-2D graph, which influences the order of sweeping through local variables during branch-and-bound search. By rotating the tensor network, the search and contraction process can start from different positions on the 2D grid, improving the stability and robustness of the results.
In practice, searches can be performed across all eight possible transformations (four rotations and four reflections, all_lattice_transformations
) of the 2D grid, comparing the energies obtained for each configuration to identify the most optimal outcome.

SpinGlassEngine.all_lattice_transformations
— ConstantA tuple containing all possible lattice transformations.
This constant includes rotations at angles 0, 90, 180, and 270 degrees, as well as reflections across the x-axis, y-axis, diagonal, and antidiagonal axes. These lattice transformations can be applied to the PEPS lattice to achieve various orientations and reflections in order to start the search on a different sites of lattice.
SpinGlassEngine.rotation
— Functionrotation(θ::Int64) -> LatticeTransformation
Create a rotation transformation by a specified angle.
Arguments
θ::Int
: The angle of rotation, expressed in degrees. Only integral multiples of 90° can be passed as θ.
Returns
A LatticeTransformation
object representing the specified rotation transformation.
SpinGlassEngine.reflection
— Functionreflection(axis::Symbol) -> LatticeTransformation
Create a reflection transformation along the specified axis.
Arguments
axis::Symbol
: The axis of reflection, which can be one of the following::x
for reflection along the x-axis.:y
for reflection along the y-axis.:diag
for reflection along the main diagonal.:antydiag
for reflection along the anti-diagonal.
Returns
A LatticeTransformation
object representing the specified reflection transformation.
Gauge
Currently only NoUpdate
mode is supported.