# Parallel Computing of Edwards--Anderson Model
## 2 Algorithm

Table 3: Performance of the parallel algorithm of 25 \(\times\) 25 and 28 \(\times\) 28 lattices calculation for 1, 2, 4, 8, 16, 32 and 64 threads. ## 4 Use in a Quantum Computer Simulator

Further, we will show how to use the proposed scheme in a quantum simulator. Unitary operators in quantum computers can be represented as a product of 1-qubit and 2-qubit operators [31]. Therefore, to understand the principle of operation, it is sufficient to consider a 2-qubit quantum gate. To reproduce an action of a quantum gate on \(n\) qubits in the common case we have to apply a \(2^{n}\times 2^{n}\) matrix operator \(\hat{A}\) on the \(2^{n}\) components of a vector in a \(2^{n}\)-dimensional Hilbert space (see [31]). Each component of a new vector-state is computed using 4 other components as input for a 2-qubit operator \(\hat{A}\). Let us a 2-qubit operator acts on qubits number \(p\) and number \(q\). So in the result qubit and in 4 input ones all qubit states are the same except for the states with the numbers numbers \(p\) and \(q\) as it's shown here

\[ \begin{pmatrix}\Psi^{\prime}_{k_{n\omega},0,\ldots,0,\ldots,k_{2},k_{1}}\\ \Psi^{\prime}_{k_{n\omega},0,\ldots,1,\ldots,k_{2},k_{1}}\\ \Psi^{\prime}_{k_{n\omega},1,\ldots,1,\ldots,k_{2},k_{1}}\\ \Psi^{\prime}_{k_{n\omega},1,\ldots,1,\ldots,k_{2},k_{1}}\\ \end{pmatrix} = \begin{pmatrix}a_{11}&a_{12}&a_{13}&a_{14}\\ a_{21}&a_{22}&a_{23}&a_{24}\\ a_{31}&a_{32}&a_{33}&a_{34}\\ a_{41}&a_{42}&a_{43}&a_{44}\\ \end{pmatrix}\begin{pmatrix}\Psi_{k_{n\omega},0,\ldots,0,\ldots,k_{2},k_{1}}\\ \Psi_{k_{n\omega},0,\ldots,1,\ldots,k_{2},k_{1}}\\ \Psi_{k_{n\omega},1,\ldots,0,\ldots,k_{2},k_{1}}\\ \Psi_{k_{n\omega},1,\ldots,1,\ldots,k_{2},k_{1}}\\ \end{pmatrix} . \tag{6}\]

So the problem is to find and match all groups of 5 components (1 output and 4 inputs) from the \(2^{n}\) Hilbert space. Applying the proposed approach of pairing elements we can find all groups of 5 elements to apply a 2-qubit operator to them. In the scheme in Figure 3 we can notice that after each addition of a spin in the resulting pairs the 2 spin states differ by only 1 number (0 or 1) in the binary representation. We can use it in quantum simulators. The operation scheme of the algorithm can be clearly understood using the example of a quantum circuit of 4 qubits. Let us an operator \(\hat{A}\) act on the qubits number 2 and number 4. It's shown in Figure 5.

Next, we are going to reproduce the sequence of operations in Figure 3. Our goal is to calculate all components of \(\vec{\Psi}^{\prime}\) which are linear combinations of components \(\vec{\Psi}\). Every component of \(\vec{\Psi}\) contains amplitudes and phases of the appropriate wave function. The whole scheme for 4-qubit is given in Figure 6 with the components of \(\vec{\Psi}^{\prime}\) which are written in the binary representation. Here we collect 4 input variables-components \(\vec{\Psi}\) in one place in the memory and match them with the components of \(\vec{\Psi}^{\prime}\). In Figure 6 we get in each step pairs of states differing only by one qubit state. We must catch the components of \(\vec{\Psi}\) with different states of qubit 2 and qubit 4. As it's seen in Figure 6 on steps 2 and 4 these qubit states are different in every pair. Keeping this in mind, we can try to copy the pair as done in the diagram. Beforehand we allocate memory to store the additional data after copying. Thus, in step 3 we transmit already the pairs, not just one component (with only the state of the second qubit being different). In step 4, by copying pairs, we get exactly states with all 4 combinations of states of the qubits 2 and 4, but with the same states of the qubits 1 and 3. The big numbers denote memory locations. Figure 5: A 4-qubit quantum scheme with one 2-qubit operator \(\hat{A}\). To reproduce it on a quantum simulator we have to operate in the 16-dimensional Hilbert space (with 16-component vectors correspondingly). Here \(\hat{A}\) acts on the qubits 2 and 4 and \(\vec{\Psi}^{\prime}=\hat{A}\vec{\Psi}\).