Mod2VQLS: a Variational Quantum Algorithm for Solving Systems of Linear Equations Modulo 2

This paper presents a system for solving binary-valued linear equations using quantum computers. The system is called Mod2VQLS, which stands for Modulo2 Variational Quantum Linear Solver. As far as we know, this is the first such proposal. The design is a classical-quantum hybrid. The quantum components are a new circuit design for implementing matrix multiplication modulo 2, and a variational circuit to be optimized. The classical components are the optimizer which measures the cost function and updates the quantum parameters for each iteration, and the controller that runs the quantum job and classical optimizer iterations. We propose two alternative ansatze or templates for the variational circuit, and present results showing that the rotation ansatz designed specifically for this problem provides the most direct path to a valid solution. Numerical experiments in low dimensions indicate that Mod2VQLS, using the custom rotations ansatz, is on-a-par with the block Wiedemann algorithm, the best-known to date for this problem.


Introduction
This report describes a new quantum hybrid algorithm for solving systems of linear equations modulo 2. In such problems, we want to find an n-vector x such that Ax = b, where A is an m × n matrix and b is an m-vector, all values are 0 or 1, and arithmetic is performed modulo 2, so that 1 + 1 = 0.
Solving systems of simultaneous linear equations is a standard problem, and is most familiar in situations where the coefficients in the equations are real or complex numbers.When the coefficient matrix is not square, direct methods leveraging the LU or QR decompositions emerge as the natural choice.Obtaining these factorizations is costly, incurring a computational cost of O(mn 2 ) Trefethen and Bau (1997).When A is square, and moreover enjoys additional structural properties like invertibility, symmetry, or positive-definiteness, faster iterative methods including various Krylov subspace iterations and Conjugate-Gradient are available Golub and van Loan (1996).
Linear equations with binary coefficients are less ubiquitous than those with real coefficients, but still they have key mathematical applications and commercial uses.One of these is integer factorization, in which we want to find large square numbers that are products of combinations of numbers whose prime factors are known, which means we want their exponents to be even (Pomerance, 1996;Aboumrad et al., 2023).The solution of some Boolean satisfiability problems can be optimized using Gaussian elimination with binary arithmetic, especially for cases with XOR constraints (Soos et al., 2009).(Quantum approaches to more general Boolean satisfiability problems are surveyed by Alonso et al. (2022).)Applications in cryptography and cryptanalysis, such as finding inverses of elements in the finite field GF (2 m ), have encouraged research on optimizing solutions of binary linear systems (Rupp et al., 2006;Wang et al., 2016).A component that solves linear systems modulo 2 is therefore required in various applications; choosing an optimal approach typically depends on features including the dimension, number of equations, and sparsity; and research on this problem is ongoing Hu et al. (2022).
This paper presents a new quantum hybrid algorithm for solving this problem, which as far as we know is the first to apply quantum computing to solving binary linear systems.The solution approach has two steps.First, we define a quantum circuit implementing matrix-vector products over the relevant finite vector spaces.Our circuit has one gate for each non-zero entry in the coefficient matrix.Then we derive a variational cost function that can be optimized in order to produce solutions to the given system.This frames the problem as one of optimizing a variational quantum circuit, which has become a standard approach in quantum machine learning on NISQ (noisy intermediate-scale quantum) hardware (Schuld and Petruccione, 2021, Ch 5)).
We deal with arbitrary unstructured matrices with entries in the finite field with two elements.Since the algorithm we present here leverages sparsity in the coefficient matrix, we comment on its computational complexity in relation to the state-of-the art block Wiedemann method in Section 6.We note that the block Wiedemann method has been used in recent recordbreaking RSA factorization calculations Boudot et al. (2020).
The rest of the paper is organized as follows.Section 2 introduces quantum gates and circuits used throughout the paper.Section 3 explains the construction of a quantum circuit that implements the crucial matrix-vector multiplication operation for binary-valued matrices and vectors.Section 4 pairs this circuit with a variational component that can be optimized in a hybrid quantum-classical computing framework in order to solve linear systems.In particular, this section introduces a simple rotations ansatz which is especially well-suited to the problem.Section 5 presents initial proof-of-concept experiments, showing that in low dimensions, with the rotations ansatz, the number of iterations needed to find a solution scales linearly in the number of dimensions (with a scaling factor around 4). Section 6 compares the method introduced here with established classical and quantum alternatives.
We shall use the following notation throughout.We let F 2 denote the field with the two elements 0, 1.(In other works, F 2 is sometimes written as Z 2 ∼ = Z/2Z, or GF (2), where GF stands for Galois Field.)Addition in F 2 is written using the symbol ⊕, so that 0 ⊕ 0 = 0, 0 ⊕ 1 = 1 ⊕ 0 = 1, and 1 ⊕ 1 = 0. We fix an m × n matrix A and an m-vector b with a ij , b i ∈ F 2 .In addition, we let x denote an arbitrary element of F n 2 .The problem of solving the linear system is to find x such that Ax = b, in this case over F m 2 (so all arithmetic is modulo 2).

Quantum Circuits and Gates Used in this Paper
This background section briefly reviews the quantum gates used in the circuits below.These include the single-qubit Pauli-X gate and fractional Y -rotation gate R Y (θ) (Figure 1), and the 2-qubit CNOT and controlled-Z gates (Figure 2).The Pauli-X gate is commonly used to flip a qubit between the |0⟩ and |1⟩ gates, which is why it is also sometimes called the quantum NOT gate.X-gates directed at different qubits can be used to prepare an input state representing a binary-valued vector: the state |010... . . ....001⟩ is prepared by applying an X-gate to each of the qubits to be switched to the |1⟩ state.
The Hadamard (H) gate is commonly used to put a qubit into a superposition state: for example, it maps a qubit prepared in the state |0⟩ to the superposition 1 Pauli-X (NOT) X 0 1 1 0

Hadamard (H) H
Figure 1: Single-qubit gates used in this paper, and their corresponding matrices, which operate on the superposition state α |0⟩ + β |1⟩ written as the column vector α β T .
Controlled Not (CNOT, CX) The CNOT gate is a 2-qubit entangling gate, that acts upon the state α |00⟩ + β |01⟩ + γ |10⟩ + δ|11⟩.In the standard basis, its behavior can be described as "performing a NOT operation on the target qubit if the control qubit is in state |1⟩", which in terms of operations in F 2 can be written as CNOT |y, z⟩ = |y, y ⊕ z⟩.
The Pauli-X, Hadamard, CNOT, and CX gates are self-inverse: performing these operations twice gives the identity map.These periodic properties are crucial for performing the binary arithmetic operations in the matrix-vector product of Section 3.
The R Y (θ) rotates a single-qubit through an angle θ around the Y -axis on the Bloch sphere Nielsen and Chuang (2002, Ch 1).The angle θ can be varied, and optimizing these angles for many gates is the task of the variational algorithm in Section 4. The controlled-Z gate is similar to the CNOT gate and entangles 2 qubits: in the standard basis, its action is symmetric (in the sense that it doesn't matter which qubit is considered to be the control and which the target qubit).

Implementing the Matrix-Vector Product as a Quantum Circuit
This section introduces a quantum circuit that implements the binary-valued matrix-vector product Ax, where A is a matrix and x is a vector, and both have values in F 2 as defined above.
The trick is to notice that binary arithmetic may be implemented with controlled-NOT operations.The NOT gate switches the state of an individual qubit between |0⟩ and |1⟩, and the CNOT gate performs such an operation only if the so-called control qubit is in state |1⟩.In particular, the CNOT gate acts on the two-qubit state |y, z⟩ as CNOT |y, z⟩ = |y, y ⊕ z⟩ . (1) Now let |x⟩ = |x 1 , x 2 , . . ., x n ⟩ denote the n-qubit quantum state corresponding to x and notice that Thus the m-qubit state |Ax⟩ can be prepared by applying the quantum circuit to the tensor product |x⟩ |0⟩.Here CNOT(k, ℓ) denotes a CNOT gate controlled by the k th qubit and targeting the ℓ th one.The product operator Π in these definitions denotes composition, so it is implemented by applying the gates in sequence.Both products in Relation (2) may be taken in any order.We note that A requires m + n qubits and N quantum gates, with N denoting the number of non-zero entries in A.
In particular, we obtain the following theorem.
Theorem 1.Using A as in Relation (2), with |0⟩ denoting the m-qubit all-zero state, and with |x⟩ |0⟩ denoting the concatenation / tensor product of |x⟩ and |0⟩, we have Proof.The proof follows from an easy argument by induction on n that is left to the reader: the base case n = 1 can be easily established for all m by verifying that the i th qubit in the output register is zero precisely when a ij = 0, and the inductive step follows from a quick calculation considering the inductive hypothesis and the action of the CNOT gate, as in Relation (1).
Example 1.The following example elucidates Theorem 1.For concreteness, consider the 2 Then and therefore The diagram in Figure 3 shows how the operator A is implemented explicitly as a quantum circuit.These circuits work because the self-inverse behavior of the X and CNOT gates is ideal for binary arithmetic over F 2 .It is possible that the periodic nature of other gates could be used similarly to perform arithmetic operations over other finite fields, but such an adaptation is not straightforward unless we consider qudits instead of qubits, because the way several CNOT gates combine angles into a single target qubit does not perform like group addition for fields other than F 2 .More precisely, the X and CNOT gates rotate their target qubits through angles 0 and π, which is all we need for the 0 and 1 elements of F 2 , but if this is extended to a larger set of angles 2π/p for p ̸ = 2, the use of CNOT gates to combine different contributions into a single target qubit as in Figure 4 is nonlinear Widdows et al. (2022).It follows that the coordinates of the output vector b are not the same as the sums of the various inputs (Ax) j , except for the 2-element field F 2 .(2022).Note the structural similarity with the inputs to (Ax) 0 in Figure 3.

Solving the Linear System using a Variational Quantum Algorithm
Now we propose a Variational Quantum Algorithm (VQA) designed to solve the linear system Ax ≡ b mod 2. As with any VQA, there are two main ingredients: a variational ansatz, and a cost function that serves as the optimization objective.The ansatz gives a circuit pattern or template, with gate parameters (typically angles) that can be varied and optimized.In this report we consider one objective function and compare two different ansatze: a Rotations ansatz specially designed for the task, and a more generic Brickwork ansatz.The system as a whole is called Mod2VQLS, which stands for Modulo-2 Variational Quantum Linear Solver.Figure 5 illustrates the full variational circuit evaluated by Mod2VQLS when solving the linear system described in Example 1.In this case, the brickwork layout variational ansatz described in Section 4.2 is used, with 4 layers.
Our cost function here measures the overlap between the projector |ψ(θ)⟩ ⟨ψ(θ)| and the subspace orthogonal to |b⟩, which is given by We note that this cost function has appeared before in (Bravo-Prieto et al., 2020) as Equation (3) in the setting of solving square linear systems with real entries.
Some algebra shows that C can be evaluated by computing the expected energy of an Ising Hamiltonian: where we have omitted the dependence on θ for simplicity of notation.Notice that the second term is the expected value of the rank-1 Ising Hamiltonian |b⟩ ⟨b| with eigenvalue 1 corresponding to the eigenstate |b⟩, computed with respect to the variational state |ψ⟩.Although it may be difficult to express this Hamiltonian as a linear combination of tensor products of Pauli matrices, we do not need to construct or even to know it explicitly: all we need is an oracle that can lazily evaluate the Hamiltonian's eigenvalues.

Rotations Ansatz
Now we turn to our variational ansatze.The first is a simple rotations pattern that is particularly well-suited for the Mod2VQLS cost function C.This ansatz is just a product of singlequbit rotations about the Y -axis; in particular, we take with R j Y denoting an R Y rotation applied on the j th r qubit and each parameter θ ∈ [−2π, 2π] n .This circuit is interesting because it does not add to the overall computational cost of each iteration, and it is amenable to direct mathematical analysis.
In particular, we can derive an explicit formula for the variational cost as a function of the circuit parameters.
Proof.The theorem follows from direct calculation.First note that So a quick induction, left to the reader as an exercise, shows that Combined with Theorem 1, the last equation yields an expression for our variational quantum state: We use this expression to compute the variational cost with respect to |ψ(θ)⟩.In particular, let and use Relation (3) to write Moreover, we can obtain a similar formula for the gradient of the cost function with respect to the circuit parameters.
Theorem 3.For each j = 1, . . ., n, the cost function C(θ) varies like with respect to θ j .Here ⊕ denotes binary addition over F n 2 and e j denotes the j th standard basis vector in F n 2 .
Proof.The theorem follows from a direct computation using the chain rule.The key is to notice that differentiating α x swaps a sine for a cosine and vice versa; for instance, if x j = 0, and we fix c k = cos θ k 2 and s k = sin θ k 2 for simplicity of notation, we see that Theorem 3 helps us understand the critical points on the variational cost landscape.In particular, it shows that the gradient ∇ C(θ) is smooth, and moreover, each of its entries is a trigonometric polynomial on the 2n variables c j = cos It is interesting to note that when (c j , s j ) is an 8n-th root of unity, our variational cost can be written in terms of quantum integers or q-integers, which are ubiquitous in q-calculus, the representation theory of quantized enveloping algebras and quantum groups, and in the theory of crystal bases, amongst others Kac and Cheung (2015); Kassel (1995); Chari and Pressley (2000); Kashiwara (1990); Lusztig (1990).We conjecture that these points characterize the extrema of our cost function.The conjecture is motivated by the size of the variety characterized by ∇ C = 0 together with the Pythagorean identities as computed by Bezout's Theorem and by the explicit computations summarized by Theorem 5. Definition 1.For any complex q ̸ = 1 and any integer n, the quantum integer or q-integer [n] q is defined by In this setting, quantum integers appear in the coefficients α x (θ).In particular, let θ j = π 2n p j for any p j ∈ {0, 1, . . ., 4n − 1}, let ξ = e iπ 4n denote a primitive 8n-th root of unity, and notice We use the last identity to prove the existence of globally optimal parameters for our variational circuit.It is important to observe these guarantees are not typically offered by VQAs; for instance, QAOA can only guarantee such parameters in the limit of infinite circuit depth.
We will need the following identities.
Proof.The lemma follows from direct calculation.For example, The second equality follows because sin n • π 4n = 1/ √ 2 and ξ 2n = i, so that ξ 2n − ξ −2n = 2i.The last equality holds because ξ is an 8n-th root of unity; in particular, ξ 4kn = ξ −4kn .Theorem 5. Let θ = π 2n p for some p ∈ Z n .First suppose p = 2nx ′ for some x ′ ∈ {0, 1} n .Then C(θ) = 0 is a global minimum of C : R n → R if x ′ satisfies Ax ′ = b; otherwise, C(θ) = 1 is a global maximum of the cost function.Now assume p 1 = • • • = p n = kn for some odd integer k and let rk(A) denotes the rank of A over Proof.First notice our cost function is non-negative; for any θ ∈ R n , we have This follows from Relation (5), which writes |ψ(θ)⟩ as a superposition over a tensor product of computational basis states with amplitudes given by α x (θ).In addition, C is bounded above by 1 because each α x (θ) 2 is non-negative.This means 0 ≤ C(θ) ≤ 1 for every θ ∈ R n .Thus, to prove the first claim, it remains to show that when p = 2nx ′ , the cost function vanishes if x ′ belongs to the inverse image A −1 (b) and it is unity otherwise.This follows from direct calculation: Note that the product in the second equality vanishes whenever x ̸ = x ′ because [4n] ξ = 0.
For the second claim, write k = 4m + r for some integer m and with r = 1, 3. Now recall the well-known "summation rule" [s + t] q = q s [t] + q −t [s] q for quantum integers (Kassel, 1995, Relation V1.1.2).When combined with Lemma 4, the summation rule implies In addition, note that if r = 3, Relation 6 implies denotes the (integer) sum of the elements of x, we see that In the fourth equality we used Lemma 4 to simplify In the fifth equality we applied Lemma 4 again, this time substituting To conclude, we recall the solution set A −1 (b) is an affine space in F n 2 with one point for each element of the kernel of A. Hence if we let null(A) denote the dimension of ker A over F 2 and we recall the Rank-Nullity Theorem we obtain the desired result:

Brickwork Ansatz
The other variational ansatz we consider is comprised by a brickwork layout of parametrized two-qubit gates.For instance, Figure 6  Figure 6: A brickwork layout ansatz on 4 qubits with a depth of 5 layers.
With enough layers, it should be possible for the brickwork ansatz to provide solutions to the equation Ax = b, and intuitively, we expected that convergence would be slower but that the method might find more solutions overall.In practice, the convergence was considerably slower, and in most cases, the number of extra solutions found was modest.

Alternatives
There are several alternatives and ways this design could be varied.For instance, one could use a different two-qubit block in the brickwork layout ansatz.More generally, we could use a different ansatz altogether.In particular, it might be beneficial to incorporate linear-algebraic information into the ansatz, such as something that encourages the superposition to be orthogonal to the range of A, in case b = 0. Also, a swap test could be used for computing C as part of the quantum circuit itself Buhrman et al. (2001).This may serve as a way to mitigate the measurement error, at the cost of requiring additional qubits.

Experimental Results
This section describes the results of experiments evaluating the performance of Mod2VQLS solvers using both the rotation and brickwork ansatze.In each dimension from 1 to 9, we generated ten consistent binary linear systems by constructing n × n matrices A and n-vectors x with independent and uniformly selected entries in {0, 1} and then computing Ax = b.Then we solved the systems using Mod2VQLS, using both the brickwork and rotation ansatze.Solving a linear system entails optimizing the model's variational parameters and then measuring the optimized state |ψ(θ * )⟩.We tested all the computational states observed in the optimized superposition in order to determine whether they were valid solutions to the linear system in question.We counted the number of distinct valid and invalid solutions proposed, as well as the average number of iterations required for convergence of the variational method.We used SciPy's COBYLA implemetation to update the variational parameters in our circuits; we note this optimization routine only requires a single quantum circuit execution per iteration.Circuits were coded and simulated using the Qiskit Python package ANIS et al. (2021).
In the Brickwork case, the number of layers in the variational ansatz is an extra configuration parameter.From experimenting, we found that at least 2 layers were needed, and that matching the number of layers / parameters to the number of dimensions produced a reasonable tradeoff between solution iterations and correctness.
Our results are presented in Table 1.The rotations ansatz performed quite simply and effectively, always finding a correct solution, and occasionally finding more than one, with a reasonably small number of iterations.The rotations ansatz proposed no invalid solutions.The brickwork ansatz was more costly and error-prone, using more iterations and producing some invalid solutions.The brickwork ansatz was also able to find a greater variety of valid solutions, though not dramatically so.
Figure 7 show the growth in the number of iterations used by Mod2VQLS with the rotations ansatz.The growth is roughly linear in small dimensions, with a slope of (just under) 4.This allows for comparison with block Wiedemann, as explained in Section 6 below.
These experiments demonstrate proof-of-concept, in that the Mod2VQLS system does find correct solutions.They also demonstrate that there are performance tradeoffs, and that different choices of ansatz may be appropriate, depending on whether the task requires for searching for any solution, or a more exhaustive search for all solutions.

Related Classical and Quantum Methods for Solving Linear Systems
To begin we comment on the computational complexity of our Mod2VQLS to the block Wiedemann method when m = n, which is the fastest known classical algorithm for dealing with sparse unstructured systems over finite fields Coppersmith (1994).This method requires a linear number of matrix-vector multiplications plus a quadratic number of arithmetic operations in F 2 .In fact, large scale implementations, like the one leveraged in the record-breaking RSA-240 calculation described in Boudot et al. (2020), have used ≥ 3n matrix-vector multiplications and it is not known if less than 2n can be used Kaltofen (1995).In our quantum setting, we consider the cost of executing our matrix-vector product circuit A from Section 3. The results from our numerical experiments using the rotations ansatz described in Section 4.1, as recorded in Table 1, indicate that the gate complexity of our simple quantum algorithm is on par with the state-of-the-art block Wiedemann approach: the number of matrix-vector multiplications needed to achieve a solution is linear in the system dimension and we do not require the additional quadratic number of field operations or linear storage.(However, our method requires at least one qubit per variable, so large-scale systems encountered in practice will require larger quantum computers.) Now we turn to highlighting some important distinctions between Mod2VQLS and quantum linear solvers that have appeared previously, like the VQLS algorithm in (Bravo-Prieto et al., 2020) and the renowned HHL algorithm (Harrow et al., 2009) (some of whose variants and improvements are described in (Dervovic et al., 2018)).To date, works on matrix multiplication and solving linear equations using quantum computing have addressed the cases of real-and complex-valued matrices.As far as we know, our proposal here is the first attempt to address this problem matrices over F 2 .
In addition, Mod2VQLS can tackle matrices of any size and rank, whereas both HHL and VQLS are restricted to square matrices with full rank (invertible operators).Indeed the runtime of both HHL and VQLS depends on the condition number of the coefficient matrix, so effectively they assume the coefficient matrix is not only invertible, but robustly so (wellconditioned).
The ability to work with matrices of different sizes and ranks is especially beneficial for solving problems where the matrix sizes are not fixed in advance.A case-in-point is the integer factoring problems investigated by Aboumrad et al. (2023), which motivated the development of Mod2VQLS.In this application, each equation (each row of the matrix A) is discovered in-dependently in a massively-parallel data collection phase.We are not looking for a unique solution to a fixed system of equations, but any solution to any subset of this system of equations.The Mod2VQLS works especially well for this, because the optimized variational circuit produces a superposition over multiple solutions to Ax = b.
On the flip side, while HHL and VQLS promise an exponential speed-up over classical solvers, because they leverage a dense amplitude encoding that requires log 2 n qubits to represent the linear system A ′ x ′ = b ′ with an n × n coefficient matrix A ′ , Mod2VQLS can only promise a polynomial speed-up over the fastest-known classical solvers (which are already polynomial), because Mod2VQLS requires circuits with m + n qubits for solving the system Ax = b with an m × n coefficient matrix A.
However, the Mod2VQLS encoding furnishes several advantages that address the HHL caveats delineated by (Aaronson, 2015).For starters, in HHL the load vector b ′ must be loaded onto the quantum processor and this task in itself may require an exponential number of steps (with respect to the number of qubits in the circuit) (Aaronson, 2015, Caveat 1).By contrast, in our setting the load vector b is merely an m-bit string so it corresponds to an m-qubit computational basis state.As such, it can be efficiently loaded on the quantum computer using at most m NOT-or Pauli-X-gates, although it turns out it is not even necessary to load b onto the quantum processor in our current implementation.
Moreover, HHL assumes that the quantum computer can apply the unitary operator e −iA ′ t efficiently, for various values of t (Aaronson, 2015, Caveat 2).In our setting the closest analogue is applying the matrix-vector product operator defined below, and doing so requires precisely N two-qubit gates, where N is the number of non-zero entries in A. The complexity here indicates that Mod2VQLS directly benefits from the sparsity of A, which is useful in applied settings where one typically deals with large, (very) sparse matrices.For instance, the matrices encountered in recent large factoring calculations have millions of rows and columns, but only a few hundred non-zero entries per row.
Finally, extracting the solution vector x ′ upon executing the HHL algorithm requires an exponential number of circuit measurements (Aaronson, 2015, Caveat 4).Again, the exponential here is with respect to the number of qubits in the HHL circuit.By contrast, in our modulo 2 setting the solution vector x is an n-bit string, which corresponds to an n-qubit computational basis state, so it can be read-off from the optimized quantum ansatz using a fixed number of shots.An added benefit of our method is that the optimized quantum ansatz obtained upon running Mod2VQLS is a superposition over computational basis states corresponding to every possible solution to Ax = b, so we can effectively sample the solution set by measuring the optimized quantum state.This is quite useful in the factoring application, where we typically need to find more than one element in the kernel of the coefficient matrix in order to build a factor.
There are a few additional differences that distinguish our present context from that of Bravo-Prieto et al. (Bravo-Prieto et al., 2020).They use a dense encoding which means that their cost function can be evaluated by executing quantum circuits with a logarithmic number of qubits.This is in contrast to our encoding, which requires a linear number of qubits.With the particular implementation details of the VQLS routine explained in (Bravo-Prieto et al., 2020) in mind, we see that our encoding has several benefits.For instance, in this context A is a unitary operation that can be performed using N gates, where N is the number of non-zero entries in the coefficient matrix.By contrast, the A operator in (Bravo-Prieto et al., 2020) is a linear combination of L unitaries, and L may be exponential in the number of qubits in their circuit.Moreover, the authors do not explain how to achieve such a decomposition in general; however, in Appendix A, they provide some hints for how to proceed when the coefficient matrix is sparse.In this section, they assume access to some oracle O A that can effectively query the entries of A. Regardless, it's not clear how to implement this oracle and indeed the authors comment that, "The gate complexity of both of these strongly depends on the form and precision with which the matrix elements of A are specified" (Bravo-Prieto et al., 2020, Appendix A).
Also in (Bravo-Prieto et al., 2020), the cost function C G vanishes when the norm of |ψ⟩ vanishes, making it deficient in the sense that non-solutions to Ax ≡ b mod 2 correspond to local extrema.By contrast, the variational state |ψ(θ)⟩ used here is normalized because AV (θ) is a unitary operation.Thus there is no need to normalize the cost function, as in Equation ( 5) in (Bravo-Prieto et al., 2020), and consider the more complicated so-called local cost functions.

Conclusion
Variational quantum circuits provide design patterns that can be applied to a range of mathematical problems, especially ones that can be expressed as optimization problems with respect to some cost function.This paper demonstrated the Mod2VQLS system, which applies this design pattern to the problem of solving linear systems modulo 2. The key ingredients are a circuit for computing the matrix multiplication, a variational ansatz including parameters to optimize, and a classical optimization process.The rotation ansatz provided the most direct path to results, largely because its simple design made it amenable to analytical methods.
At the scales available to quantum computers today, the results here are potentially promising, but do not compete with classical solvers.The goal of this research is to investigate potential advantages at larger scale: we expect that medium-scale quantum computers will find their first regular commercial uses as part of larger hybrid pipelines.Understanding the quantum opportunities, and in particular, their scaling properties on real data sizes and distributions, will be crucial for guiding the choice between quantum opportunities.The Mod2VQLS system presented here is a worked example of how such proposals can be implemented and investigated today.

Figure 3 :
Figure 3: Quantum circuit implementing the operator A

Figure 5 :
Figure 5: Variational circuit for solving Ax = b as in Example 1 using a brickwork layout ansatz with 2 layers.
illustrates a brickwork layout ansatz with a depth of 5 layers on 4 qubits.The two-qubit "brick" design was used by authors including Bravo-Prieto et al. (2020) for general linear solving, and Niu et al. (2022) for electron simulation.Various other general-purpose ansatz designs could be tried.

Figure 7 :
Figure 7: Average number of iterations needed to find a solution for each dimension using the rotations ansatz.The number of iterations grows approximately linearly, with a slope just under 4.

Table 1 :
Experimental results using Brickwork and Rotation Ansatze in various dimensions, using 10 randomly-generated matrices in each dimension, showing how many valid and invalid solutions were proposed, and how many iterations used, by each method.