# Parallel Computing of Edwards—Anderson Model

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

- The polynomial increase in computation time (without increasing the amount of RAM) while fixing the size of one side and increasing the size of the other, which makes it possible to compute 40 × 100, 40 × 1000, 40 × 10,000 lattices etc. This feature is not available to the method presented in [23].
- The method is exact.
- The possibility to handle different distributions (not only bimodal). It is possible to take into account impurities and heterogeneities.
- The ease of implementation.

## 2. Algorithm

**Listing 1.**Pseudocode of enumeration rows and columns, splitting states into pairs, calculating new energy minima.

for (int row=0; row < Ly; row++) |

{ |

int max_step_out=(2^Lx)/2, max_step_in=1; |

int state1=0, state2=max_step_in; |

for (int col=0; col < Lx; col++) |

{ |

for (int index_out=0; index_out < max_step_out; index_out++) |

{ |

for (int index_in=0; index_in < max_step_in; index_in++) |

{ |

state1=index_out*max_step_in*2+index_in; |

state2=state1+max_step_in; |

..... |

calc_E(...) |

// (E[state1], E[state2]) => (E[state1], E[state2]) |

..... |

} |

} |

max_step_out=max_step_out/2; max_step_in=max_step_in*2; |

// |

} |

} |

**Listing 2.**Pseudocode of splitting states into pairs, calculating new energy minima for subsystems with column number n ≥ n

_{exch}. Nthr is the number of thread. startstate1 and startstate2 are the numbers of start states stored inside the memory blocks and transferred by threads.

int max_step_in=(2^Lx)/Nthr/2; |

int state1=0, state2=max_step_in; |

for (int index_in=0; index_in < max_step_in; index_in++) |

{ |

state1=startstate1+max_step_in; |

state2=startstate2+max_step_in; |

..... |

calc_E(...) |

// (E[state1], E[state2]) => (E[state1], E[state2]) |

..... |

} |

**Listing 3.**Pseudocode for rows and columns enumeration, memory exchange between threads, energy calculation for cases col < n

_{exch}and col ≥ n

_{exch}. After completion of building each row, the memory locations are moved in the opposite direction. The code does not consider the calculation of the subsystem consisting of the lowest row only, because in this case there is no data exchange between threads. In the latter case, its calculation is trivial. The data exchange between threads is performed using two nested cycles on variables thrd_num_out and thrd_num_in. When calculating the energy by the subprogram calc_E(...), it is necessary to dispatch as arguments the array of energy values, the number of the column, the length of the side Lx.

for (int row=1; row < Ly; row++) |

{ |

for (int col=0; col < n_exch; col++) |

{ |

for (int thrd_num=0; thrd_num < thrd_amount; thrd_num++) |

{calc_E(min_E_array, col, Lx);} |

} |

int interval_amount_of_thrds=2, interval_amount_of_thrds_div_2=1, |

amount_of_bunchs_of_connected_thrds=N_thrd/2; |

for (int col=n_exch; col < Lx; col++) |

{ |

// mem swap ====== v |

for (int thrd_num_out=0; thrd_num_out < |

amount_of_bunchs_of_connected_thrds; thrd_num_out++) |

{ |

for (int thrd_num_in=0; thrd_num_in < interval_amount_of_thrds_div_2; thrd_num_in++) |

{ |

int thrd_num_1=thrd_num_out*interval_amount_of_thrds+thrd_num_in, thrd_num_2=thrd_num_1+interval_amount_of_thrds_div_2; |

swap_mem(min_E_array, thrd_num_1, thrd_num_2); // ! ! ! ! |

! ! |

} |

} |

// mem swap ====== ^ |

for (int thrd_num=0; thrd_num < N_thrd; thrd_num++) |

{calc_E(min_E_array, col, Lx);} |

} |

... |

mem_restore(...); |

... |

} |

## 3. Performance

## 4. Use in a Quantum Computer Simulator

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- van Hemmen, J.L. Classical Spin-Glass Model. Phys. Rev. Lett.
**1982**, 49, 409–412. [Google Scholar] [CrossRef] - Edwards, S.F.; Anderson, P.W. Classical Theory of spin glasses. Phys. F Metal Phys.
**1975**, 5, 965–974. [Google Scholar] [CrossRef] - Rammal, R.; Toulouse, G.; Virasoro, M.A. Ultrametricity for physicists. Rev. Mod. Phys.
**1986**, 58, 765. [Google Scholar] [CrossRef] - Hopfield, J.J.; Tank, D.W. “Neural” Computation of Decisions in Optimization Problems. Biol. Cybern.
**1985**, 52, 141–152. [Google Scholar] - McEliece, R.; Posner, E.; Rodemich, E.; Venkatesh, S. The capacity of the Hopfield associative memory. IEEE Trans. Inf. Theory
**1987**, 33, 461–482. [Google Scholar] [CrossRef] [Green Version] - van Hemmen, J.L. Spin-glass models of a neural network. Phys. Rev. A
**1986**, 34, 3435–3445. [Google Scholar] [CrossRef] [PubMed] - Hartnett, G.S.; Parker, E.; Geist, E. Replica symmetry breaking in bipartite spin glasses and neural networks. Phys. Rev. E
**2018**, 98, 022116. [Google Scholar] [CrossRef] [Green Version] - Salakhutdinov, R.; Hinton, G. Deep Boltzmann machines. Phys. Rev. E
**2009**, 5, 448–455. [Google Scholar] - Amoruso, C.; Hartmann, A.K.; Moore, M.A. Determining energy barriers by iterated optimisation: The two-dimensional Ising spin glass. Phys. Rev. B
**2006**, 73, 184405. [Google Scholar] [CrossRef] [Green Version] - Waclaw, B.; Burda, Z. Counting metastable states of Ising spin glasses on arbitrary graphs. Phys. Rev. E
**2008**, 77, 041114. [Google Scholar] [CrossRef] [Green Version] - Burda, Z.; Krzywicki, A.; Martin, O.C.; Tabor, Z. From simple to complex networks: Inherent structures, barriers, and valleys in the context of spin glasses. Phys. Rev. E
**2006**, 73, 036110. [Google Scholar] [CrossRef] [Green Version] - Schnabel, S.; Janke, W. Distribution of metastable states of Ising spin glasses. Phys. Rev. E
**2018**, 97, 174204. [Google Scholar] [CrossRef] [Green Version] - Johnson, M.W.; Amin, M.H.; Gildert, S.; Lanting, T.; Hamze, F.; Dickson, N.; Harris, R.; Berkley, A.J.; Johansson, J.; Bunyk, P.; et al. Quantum annealing with manufactured spins. Nature
**2011**, 473, 194–198. [Google Scholar] [CrossRef] - Bunyk, P.I.; Hoskinson, E.M.; Johnson, M.W.; Tolkacheva, E.; Altomare, F.; Berkley, A.J.; Harris, R.; Hilton, J.P.; Lanting, T.; Przybysz, A.J.; et al. Quantum annealing with manufactured spins. IEEE Trans. Appl. Supercond.
**2014**, 24, 1–20. [Google Scholar] [CrossRef] [Green Version] - Perera, D.; Hamze, F.; Raymond, J.; Weigel, M.; Katzgraber, H. Computational hardness of spin-glass problems with tile-planted solutions. Phys. Rev. E
**2020**, 101, 023316. [Google Scholar] [CrossRef] [Green Version] - Hen, I. Equation Planting: A Tool for Benchmarking Ising Machines. Phys. Rev. Appl.
**2019**, 12, 011003. [Google Scholar] [CrossRef] [Green Version] - Pierangeli, D.; Rafayelyan, M.; Conti, C.; Gigan, S. Scalable Spin-Glass Optical Simulator. Phys. Rev. Appl.
**2019**, 15, 034087. [Google Scholar] [CrossRef] - Kadowaki, T.; Nishimori, H. Quantum annealing in the transverse Ising model. Phys. Rev. E
**2019**, 58, 5355–5363. [Google Scholar] [CrossRef] [Green Version] - Santoro, G.E.; Martonak, R.; Tosatti, E.; Car, R. Theory of Quantum Annealing of an Ising Spin Glass. Phys. Rev. Appl.
**2002**, 295, 2427–2430. [Google Scholar] [CrossRef] [Green Version] - Houdayer, J.; Martin, O.C. Hierarchical approach for computing spin glass ground states. Phys. Rev. E
**2001**, 64, 056704. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Wang, W.; Machta, J.; Katzgraber, H.G. Population annealing: Theory and application in spin glasses. Phys. Rev. E
**2015**, 92, 063307. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Hatano, N. Evidence for the double degeneracy of the ground state in the three-dimensional ± J spin glass. Phys. Rev. B
**2002**, 66, 054437. [Google Scholar] [CrossRef] [Green Version] - Galluccio, A. New Algorithm for the Ising Problem: Partition Function for Finite Lattice Graphs. Phys. Rev. Lett.
**2000**, 84, 5924–5927. [Google Scholar] [CrossRef] - Hartmann, A.K.; Rieger, H. New Optimization Algorithms in Physics; Wiley-VCH: Berlin, Germany, 2004; pp. 1–312. [Google Scholar]
- Hartmann, A.K. Cluster-exact approximation of spin glass ground states. Phys. A
**1996**, 224, 480. [Google Scholar] [CrossRef] [Green Version] - Hartmann, A.K. Ground States of Two-Dimensional Ising Spin Glasses: Fast Algorithms, Recent Developments and a Ferromagnet-Spin Glass Mixture. J. Stat. Phys.
**2011**, 144, 519. [Google Scholar] [CrossRef] - Pardella, G.; Liers, F. Exact Ground States of Large Two-Dimensional Planar Ising Spin Glasses. Phys. Rev. E Stat. Nonlinear Soft Matter Phys.
**2011**, 78, 056705. [Google Scholar] [CrossRef] [Green Version] - Kaufman, B. Crystal statistics. ii. partition function evaluated by spinor analysis. Phys. Rev.
**1949**, 78, 1232–1243. [Google Scholar] [CrossRef] - Suzuki, M. Transfer-matrix method and Monte Carlo simulation in quantum spin systems. Phys. Rev. B.
**1985**, 31, 2957–2965. [Google Scholar] [CrossRef] [PubMed] - Suzuki, M. Generalized Trotter’s Formula and Systematic Approximants of Exponential Operators and Inner Derivations with Applications to Many-Body Problems. Commun. Math. Phys.
**1976**, 51, 183–190. [Google Scholar] [CrossRef] - Nielsen, M.; Chuang, I. Quantum Computation and Quantum Information; Cambridge University Press: Cambridge, UK, 2011; pp. 1–702. [Google Scholar]
- Edwards_Anderson_parall_2D. Available online: https://github.com/kukurbitX29MIH/Edwards_Anderson_parall_2D (accessed on 27 December 2021).

**Figure 1.**Notations for ${L}_{x}=4$ for different lengths of the top row filled in from left to right. The upper boundary is indicated by shaded squares.

**Figure 2.**Partitioning of the states of the lattice spin boundary with ${L}_{x}=5$ into pairs when extending the row number $m+1$. To complete the row, 5 spins must be added. Starting from the second row, pairing no longer takes place between adjacent memory cells. Thus, the arrows can intersect many times. The numbers under the arrows signify the locations of the memory. In turn, the each location corresponds to the given state of a spin boundary. The arrows show the transmission of the values of the energy to calculate the next energy minima according to (4) and (5).

**Figure 3.**Splitting states of the lattice boundary spins with ${L}_{x}=5$ into pairs while expanding line $m+1$. In this scheme, the spins of each pair are written together: one below the other. The numbers correspond to the values of E with the fixed boundaries. Position of the number corresponds to location in the memory. A pair of the cells with paired E (one below the other) are located next door to each other in the memory. Obviously all pairs of variables with E of must be in adjacent cells of the memory. sponds to a subsystem with a given number of spins of the uppermost row (a view of all 5 subsystems is shown in Figure 2). For ${L}_{x}=5$ we have 5 possible subsystems of different forms with spins filled from left to right (with one top spin, two, etc.). The bidirectional arrows here mean data exchange. One part takes the place of the another part, which in turn takes up the place of the first part.

**Figure 4.**The data exchange scheme between 16 threads. In each thread the memory is divided into two parts. One stays, the other is transmitted to the other thread. Meanwhile the half of the memory of the other thread is written in its place. The numbers indicate the thread number, and the shaded squares indicate the memory block. This scheme corresponds to one in Figure 3. The positions of the coloured squares correspond exactly to the memory locations. The transmitted data are the energy values for the fixed boundaries.

**Figure 5.**A 4-qubit quantum scheme with one 2-qubit operator $\widehat{A}$. To reproduce it on a quantum simulator we have to operate in the 16-dimensional Hilbert space (with 16-component vectors correspondingly). Here $\widehat{A}$ acts on the qubits 2 and 4 and $\overrightarrow{{\mathsf{\Psi}}^{{}^{\prime}}}=\widehat{A}\overrightarrow{\mathsf{\Psi}}$.

**Figure 6.**Using the parallelisation scheme of computation of Edwards-Anderson model to simulate the 2-qubit quantum operator $\widehat{A}$ acting on the 4-qubit quantum scheme. We have 4 steps with 3-fold data exchange and 2-fold data copying. The arrows denote the directions in which the components of $\overrightarrow{\mathsf{\Psi}}$ move. The large numbers indicate the memory locations. In steps 2 and 4 we copy pairs of states to transmit them further. Eventually we have all 4 input components of $\overrightarrow{\mathsf{\Psi}}$ to apply $\widehat{A}$ to them. $\widehat{A}$ is given so that it acts only on qubit 2 and 4. We can make sure that by copying the pairs in steps 2 and 4 we get exactly necessary 4 components with the different states of the qubits 2 and 4 and the same states of the qubit 1 and 3 in each of the 4 components. To copy the data, we allocate the extra memory to store the 4 variables for each component. Some of the memory cells are unoccupied at the beginning. Therefore we see the empty cells at the beginning.

**Figure 7.**The computing result wave function by applying the operator $\widehat{A}$. One can note that some of the new components of $\overrightarrow{{\mathsf{\Psi}}^{{}^{\prime}}}$ are redundant. Therefore, we leave only unique components in the result.

**Table 1.**Performance of the parallel algorithm for fbc spin lattice calculation for 20 × 20, 25 × 25, 30 × 30, 35 × 35 lattices on 64 threads.

Calc. Number i | Lattice | Time ${\mathit{t}}_{\mathit{i}}$ | Ratio of ${\mathit{t}}_{\mathit{i}}$ to ${\mathit{t}}_{\mathit{i}-1}$ | Memory Size |
---|---|---|---|---|

1 | 20 × 20 | 81 ms | 384 kb | |

2 | 25 × 25 | 4 s 282 ms | 52.86 | 12 Mb |

3 | 30 × 30 | 3 min 15 s | 48.75 | 384 Mb |

4 | 35 × 35 | 2 h 20 min | 43.07 | 12 Gb |

**Table 2.**Performance of the parallel algorithm of fbc spin lattice calculation for 35 × 35, 50 × 35, 100 × 35, 250 × 35, 500 × 35 lattices on 64 threads.

Calc. Number i | $\mathit{Ly}$ | Ratio of ${\mathit{Ly}}_{\mathit{i}}$ to ${\mathit{Ly}}_{\mathit{i}-1}$ | Time ${\mathit{t}}_{\mathit{i}}$ | Ratio of ${\mathit{t}}_{\mathit{i}}$ to ${\mathit{t}}_{\mathit{i}-1}$ |
---|---|---|---|---|

1 | 35 | 2.33 h | ||

2 | 50 | 1.4 | 3.46 h | 1.49 |

3 | 100 | 2.0 | 6.89 h | 1.99 |

4 | 250 | 2.5 | 17.17 h | 2.49 |

5 | 500 | 2.0 | 35.00 h | 2.03 |

**Table 3.**Performance of the parallel algorithm of 25 × 25 and 28 × 28 lattices calculation for 1, 2, 4, 8, 16, 32 and 64 threads.

25 × 25 | 25 × 25 | 28 × 28 | 28 × 28 | ||
---|---|---|---|---|---|

Calc. Number i | Amount of Threads | ${\mathit{t}}_{\mathit{i}}$ | Ratio of ${\mathit{t}}_{\mathit{i}}$ to ${\mathit{t}}_{\mathit{i}-1}$ | Time ${\mathit{t}}_{\mathit{i}}$ | Ratio of ${\mathit{t}}_{\mathit{i}}$ to ${\mathit{t}}_{\mathit{i}-1}$ |

1 | 1 | 2 min 3 s | 20 min 58 s | ||

2 | 2 | 1 min 55 s | 1.07 | 19 min 37 s | 1.07 |

3 | 4 | 59 s | 1.94 | 9 min 39 s | 2.03 |

4 | 8 | 29 s | 2.00 | 4 min 50 s | 1.99 |

5 | 16 | 17 s | 1.96 | 2 min 47 s | 1.73 |

6 | 32 | 9 s | 2.0 | 1 min 34 s | 1.78 |

7 | 64 | 5 s | 1.7 | 51 s | 1.84 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Padalko, M.A.; Shevchenko, Y.A.; Kapitan, V.Y.; Nefedev, K.V.
Parallel Computing of Edwards—Anderson Model. *Algorithms* **2022**, *15*, 13.
https://doi.org/10.3390/a15010013

**AMA Style**

Padalko MA, Shevchenko YA, Kapitan VY, Nefedev KV.
Parallel Computing of Edwards—Anderson Model. *Algorithms*. 2022; 15(1):13.
https://doi.org/10.3390/a15010013

**Chicago/Turabian Style**

Padalko, Mikhail Alexandrovich, Yuriy Andreevich Shevchenko, Vitalii Yurievich Kapitan, and Konstantin Valentinovich Nefedev.
2022. "Parallel Computing of Edwards—Anderson Model" *Algorithms* 15, no. 1: 13.
https://doi.org/10.3390/a15010013