Parity Quantum Optimization: Encoding Constraints

Constraints make hard optimization problems even more challenging to solve on quantum devices because they are typically implemented with large energy penalties and additional qubit overhead. The parity mapping, which has been introduced as an alternative to the spin encoding, translates the problem to a representation using parity variables that encode products of spin variables into a single parity variable. By combining exchange interaction and single spin ﬂip terms in the parity representation, constraints on sums, products of arbitrary k -body terms and sums over such products can be implemented without penalty terms in two-dimensional quantum systems


Introduction
Constraints to optimization problems are crucial for many problems that are encountered in science, technology, and industry, ranging from scheduling problems to quantum chemistry [1][2][3][4][5][6][7][8].Quantum computing as a new paradigm of computing, which aims, among other things, at enhancing optimization algorithms by making use of quantum phenomena, may improve upon existing algorithms to solve these kinds of problems.However, quantum computers are limited in coherence, control, and connectivity [9][10][11][12][13][14] which makes encoding of optimization problems one of the current grand challenges in the field.Constraints are an additional complication to the encoding challenge and they are typically encoded via large energy penalties [15][16][17] given as quadratic terms leading to fully connected interactions.These penalties introduce an additional energy scale and in most cases additional qubits and couplings to the computation, making algorithms, such as the quantum approximate optimization algorithm (QAOA) [18] or quantum annealing [19][20][21], less efficient.Some recent works [22][23][24] present more efficient quantum annealing methods to solve problems with linear equality constraints, which are pure sums over single spin variables, while the penalty method is applicable for general equality and inequality constraints.Reference [25] gets rid of penalty terms in the QAOA by extending it to the quantum alternating operator ansatz, introducing a Wolfgang Lechner: wolfgang@parityqc.comwolfgang.lechner@uibk.ac.at tailored mixing Hamiltonian for each constrained optimization problem specifically.
To encode constraints we introduce a combination of exchange interactions and spin-flip terms in combination with the parity encoding.The parity transformation encodes optimization problems in a lattice gauge model with local 3-body and 4-body interactions on a square lattice.We introduce exchange terms that only act on qubits that are part of the constraints and spin-flip terms that act on the rest of the qubits.Using a compiler [37], qubits can be arranged on the square lattice with flexibility.In particular, one can place qubits that are part of the constraint in close vicinity and thus allow for local hopping terms only.The points mentioned above make the method presented here implementable on current quantum devices for both quantum annealing and digital quantum computing.
We consider optimization problems in the form of a general k-body Hamiltonian where s i are the spin variables with values in {−1, 1}.This Hamiltonian can be efficiently implemented using the parity transformation [37].We assume that the terms can go up to N -body terms and the k-body interaction tensors J are sparse.We assume that the total number of qubits is N and the number of terms in the Hamiltonian is K.
In addition to the k-body optimization problem we consider a list of equality constraints where each constraint m can be written as Side Condition: σ z σ (3) z σ (2) z σ ijk , ... depend on the problem and its constraints.Constraints of optimization problems comprising inequalities can be rewritten as constraints comprising only equalities by increasing the number of spins [17].Therefore, a large number of optimization problems with both equality and inequality constraints are covered by a set of equality constraints given by Eq. (2).
Here we will restrict ourselves to constraints which are represented by Eq. (2) and coefficients g (m) α which are zero or one.Furthermore, we only consider the case of disjoint constraints, which excludes all inequalities.Multiple constraints are disjoint if they have no common qubits, i.e., all qubits are only included in one of the constraints.Otherwise we call them overlapping constraints.An idea of how to extend this method to overlapping constraints in the parity encoding and coefficients g (m) α > 1 (and therefore also inequalities) is illustrated and discussed in Appendix A. 4.However, since in these cases the implementation is unclear, it remains a task for future work.

Encoding Constraints
The parity transformation translates each term in the Hamiltonian in Eq. (1) to a single parity qubit and all k-body interaction strengths J i1...i k become local fields J αi only.We denote parity qubits with σ(i) and their corresponding eigenstates with |±1 .A detailed explanation of the parity transformation can be found in Ref. [37] and in Appendix A, which contains the transformation of the graph shown in Fig. 1 and some other examples of optimization problems in the presence of side conditions.In the following, we summarize the most important aspects for completeness: The logical qubits σ with eigenvalues ±1 represent the spins s i in the z-basis.A parity qubit represents the product of k logical qubits, e.g., σ(1,2,3) for k = 3.The parity transformation transforms the graph into a parity layout, which then encodes the optimization problem in terms of parity variables.This step increases the number of degrees of freedom from N to K, where N is the number of spins and K is the number of non-zero terms in the problem Hamiltonian.If we have additional hard constraints as in Eq. (2), K is the number of distinct spin products in both the non-zero terms of the problem Hamiltonian and the hard constraints combined plus the number of ancilla qubits, if they are needed.Thus, K − N + D parity constraints are introduced to restrict the low-energy subspace to the original size, where D is related to the degeneracy of the Hamiltonian (see Ref. [37] for further explanation).For the unconstrained optimization problem, the parity constraints are constructed from generalized closed cycles in the logical graph [37], for example σ(1,2) z , which is a valid parity constraint as the corresponding product in the logical variables is always +1.The main challenge in the parity transformation is to select K −N +D generalized closed cycles such that the resulting parity constraints can be laid out on a chip with local connectivity.For an all-to-all connected model with only 2-body terms, the choice of cycles and the layout was shown for the Lechner-Hauke-Zoller (LHZ) architecture [36].For other graphs and hypergraphs, the choice and arrangement of qubits is done by compilation [37].
To avoid confusion between parity constraints and constraints of the optimization problem, we will refer to the constraints of the optimization problem as side conditions.Side conditions in the form of a single product of logical spins can be natively encoded in the parity mapping as shown in Ref. [37].Side conditions in Eq. (2) are arbitrary sums and products (polynomials) of logical qubits and will be discussed here.Such side conditions can be transformed to the parity encoding by adding a physical qubit with zero local field for each product (including single-body terms) of logical qubits given in the side condition, which is not already in the Hamiltonian in Eq. (1).This means that if each product of logical qubits in the side condition is already present in the problem Hamiltonian, then no additional physical qubits are needed.The example in Fig. 1 illustrates this case.
Traditionally, side conditions in optimization problems are imposed with large energy penalties.For example, the side condition s 1 s 2 + s 2 s 3 = +1 would be imposed by adding the energy term C penalty (σ z − 1) 2 to the problem Hamiltonian.When C penalty is large enough, the ground state of the Hamiltonian satisfies the side condition.The challenges that come with this method are twofold: Firstly, the additional terms are higher-order interactions which introduces an additional overhead when embedding it in physical hardware with pair interactions [23,24,39,40].Moreover, if we have optimization problems with a sparse problem Hamiltonian, side conditions can lead to a highly connected Hamiltonian leading to an overhead in qubits and couplings when embedding the side condition in currently available quantum hardware.Secondly, the large penalty strength C penalty introduces an additional energy scale to the system, which is unfavorable for the implementation as well as for the dynamics.
In this work, we use a different approach where side conditions are implemented in the dynamics rather than in the energy term, i.e., by using exchange terms as proposed in Refs.[23,24].There, only side conditions which are sums over single logical qubits, can be realized by the given driver Hamiltonian.Furthermore, the authors note that in some of the investigated cases the experimental feasibility of the driver Hamiltonians requires further consideration.In contrast to that, we are able to use a similar driver Hamiltonian for side conditions, which are polynomial disjoint equality constraints (i.e., sums over products of logical qubits).In combination with a compiler [37] that is able to lay out qubits, these exchange terms can be realized among nearest neighbors only, which makes it experimental feasible.
Our strategy is to transform the problem into the parity encoding, in which we can split up the parity qubits into two sets: 1.) qubits that are not part of the side condition terms [U], and 2.) qubits that are part of the side condition terms [C]. Figure 1 illustrates this setup for a particular example.In this example, the side condition includes the physical qubits σ(2,3) In this example we do not need to add any physical qubits or any parity constraints for the side condition, because each product of logical qubits present in the side condition (σ z ) is already present in the problem Hamiltonian.For a side condition of the form c = σ z , one would have to add the two physical qubits σ(1,2,3) z (for the side condition) and σ(2) z (ancilla qubit) and the parity constraint σ(2,3) For further details on the interplay between side conditions and the parity encoding, including decoding strategies with and with out side condition and in the presence and absence of errors we refer to Appendix A.
In the annealing protocol, which is introduced below, terms that are part of [U] are driven with single body terms σx , while terms in [C] are driven by exchange terms.These exchange terms (or hopping terms) between qubits in the set [C] are of the form σ(ki y .The global ground state of this exchange term is in the zero magnetization sector.However, the magnetization sector required by a side condition is The exchange Hamiltonian preserves the magnetization required by the side condition during the annealing process.The final state is the lowest-energy state in the magnetization (symmetry) sector which fulfills the side condition -which may or may not be the unconstrained ground state.By starting in a configuration that satisfies the side condition, as the exchange term conserves the sum, the state will stay in the side-condition-satisfying subspace, i.e., the subspace of H(t) that satisfies the side conditions.The parity constraints (i.e., 4-body or 3-body terms) act on all qubits, including [C] and [U], the hopping term only on qubits in [C] and the single spin flip term σx only on qubits in [U].
In the following we will describe the protocols for Hamiltonian dynamics and digital quantum computing.

Hamiltonian Dynamics
The optimization problem with side conditions encoded as described above can be solved using an adiabatic quantum computing protocol.Our protocol introduces a few novelties compared to standard quantum annealing: 1.)The initial state is a classical state similar to reverse annealing protocols [41], which is chosen such that the side condition is fulfilled.2.) We introduce exchange terms acting on parts of the system and single spin flips acting on the rest.3.) The target state is not necessary the ground state but we instead aim at obtaining a lowest-energy state in a different symmetry sector.With the prescriptions 1.) -3.), the annealing process only popu-lates states that fulfill the side condition, which is ensured by the driver Hamiltonian.It is important that the driver Hamiltonian reaches each side-conditionfulfilling eigenstate, but no others.
As in all adiabatic protocols, we start from the ground state of an initial Hamiltonian.In quantum annealing, this is the ground state of the driver Hamiltonian.In the following we consider the case of a single side condition.This protocol can be easily extended to multiple disjoint side conditions, although generally ancilla qubits and extra couplings for a suitable parity layout might be required.We refer to Appendix C for more details.The initial Hamiltonian reads as follows: The sum [C] runs over all qubits that are included in the side condition, which we call conditioned qubits in the following.The sum [U] runs over the rest of the qubits.The coefficients ε i are chosen randomly from {−1, 1}.The coefficients η i are chosen from {−1, 1} such that the side conditions are satisfied, e.g., for a side condition with where c target is the target expectation value of the side condition.The optimization problem is encoded in the local fields of the final Hamiltonian consisting of and Here, C l is some coupling strength for the l-th parity constraint P l and the sum runs over all P parity constraints P l , where P is K − N + D and the product [P l ] runs over all qubits in the parity constraint P l .Note that the number of qubits in P l is |[P l ]| = k for a k-body parity constraint.In Fig. 1, we have two 3-body and two 4-body parity constraints.The coupling strength C l is chosen to be sufficiently large, such that all parity constraints z have eigenvalue +1 for all l = 1, ..., P , if the system is in a physical ground state of The single spin flip driver Hamiltonian acts only on qubits not associated with the side condition terms, In addition to the terms above, an exchange term is introduced among [C], which is, Here, the bracket [] * denotes a sum over all pairs i, j of neighboring qubits connected via an exchange term in [C] e.g., in Fig. 1 [21,42].Some of them are similar to the protocol presented here in that they have an additional time-dependent term that is only switched on at intermediate times (i.e., zero for s = 0, 1 and finite else), but they have different intentions.This includes works that stay in specific sub-spaces [43] or use randomly chosen catalyst Hamiltonians to improve the performance of the annealing process [44,45].While most of them have three individually driven terms, the initial, the intermediate and the final one, there is the quantum counter-diabatic annealing used in Ref. [46] where each sub-term of these three Hamiltonian parts is driven individually in time.The basic idea of the exchange Hamiltonian (7) introduced in Refs.[23,24] can only handle side conditions that are sums over single logical qubits.Indeed, due to the parity transformation, we can map sums over arbitrary products of logical qubits, i.e., polynomial side conditions, to sums over single physical qubits, such that we are also able to solve problems with polynomial side conditions.This generalization from linear to polynomial side conditions is one of the main results of this work.The Hamiltonian (5) contains each physical qubit at least once and the sum runs over all parity constraints, which ensures that we only get results with a valid correspondence to the logical problem.The exchange Hamiltonian swaps only the spin direction of neighboring qubits, such that the sum over all side conditioned qubits stays constant.With a classical preprocessing step, side conditions which can not be fulfilled can be excluded (for a detailed discussion we refer to Appendix A.1).If a solution of the problem exists (and the parity-constraint strength is large enough), no parity constraint will be violated and all side conditions will be fulfilled in the end.However, to ensure that the target ground state is reached, it could be necessary to set the parity constraint strengths to higher values.In the case that side conditions are unsolvable the final states would always be parityconstraint-violating states.For more details see Appendix A.1.
Since the exchange Hamiltonian acts only on neighboring qubits, the parity transformation has to translate the logical graph and the product terms of the side conditions into a common parity layout where all side conditioned qubits are connected via adjacent conditioned qubits.If this is not possible with the resulting physical qubits, one has to introduce ancilla qubits.With these ancilla qubits one must construct new parity constraints, which make it possible to find a suitable layout.Therefore, laying out the parity qubits for exchange terms among neighbors, just like adding product terms of the side condition, which are not included in the problem Hamiltonian, leads to extra qubits and therefore additional and possibly different parity constraints.It is possible that the encoding of the side conditions does not need any extra qubits, as it is the case for the example presented here.For some special case it is even possible to subsume a side condition into a parity constraint or to drop a parity constraint due to the given side condition.There are more details on the usage of ancillas and these special cases in Ref. [37] and in Appendix A.
As mentioned above, as long as in the parity encoding the multiple side conditions do not overlap, i.e., they are disjoint, the method presented here can be extended to cases with multiple side conditions.Side conditions overlap in the parity encoding only if different side conditions have the same product terms of logical qubits.We analyse these cases in in Appendices A and C.

Numerical Simulations
To interpret the results we have to distinguish between the ground state of the optimization problem Hamiltonian without side conditions, gs and the ground state of the optimization problem with side condition, i.e., the sidecondition-satisfying ground states gs is what we are seeking and corresponds to the lowest-lying eigenstate of H problem , which satisfies the side conditions.
In the following, we will give an example for (i) the case gs .In the latter case a crossing of the energy levels must occur.We will present the protocol of the annealing process, discuss diabatic transitions and consider Ψ (c) gs and/or Ψ (u) gs to be degenerate.We will also consider the role of the initial state.The numerical results are presented for a random example where the unconditioned optimization problem is encoded together with the side condition in the parity model with 9 qubits, as shown in Fig. 1(b).For details on the annealing protocol of all examples, we refer to Appendix B. The random problem instance is encoded in the local fields J i as the field vector J = (0.8, 0.6, 1.0, 1.0, 0.7, 0.7, 0.1, 0.6, 0.8) T .(9) For better comprehensibility, the first ten eigenstates of this problem are explicitly written out in Eq. (64) of Appendix D. The components of the field vector and of the system states correspond to the qubits in Fig. 1 in the order from top to bottom and from left to right, i.e., as (23,12,26,34,14,16,35,45,56) T .As the initial state satisfies the side condition c = z , the system ends up in the conditioned ground state.Nevertheless, the instantaneous energy spectrum and the dynamics of the evolution of the system are affected by the choice of the initial state.Therefore, for some choices of initial states, multiple level crossings to instantaneous excited energy states and back to the instantaneous ground state of the time-dependent Hamiltonian given in Eq. (8) are possible (even for gs , further discussed in Appendix D) while in other cases the system remains in the instantaneous ground state during the whole annealing process, as in Fig. 2(a).Furthermore, the choice of the initial state affects the minimal energy gap between the conditioned ground state and the first excited state inside the side-condition-fulfilling subspace during the annealing process.This minimum energy gap is crucial for the adiabatic condition [47] and gives a lower limit for the computation time t f .We remark that by increasing the constant prefactor Γ of the driver Hamiltonian we are able to shift the required final annealing time to lower values.In Appendix E we discuss this in more detail and present an example for the adiabatic condition of the given annealing protocol. If gs is equal to the lowest-energy eigenstate that satisfies the side condition.Therefore, there must be a level crossing, such that system can end up in the lowest-energy state in the symmetry sector satisfying the side condition.In Fig. 2(b) we consider the same problem example, and choose the side conditions such that the solution to the problem without side condition is different to the one with side condition.
Note that the energy of the instantaneous system state crosses different energy levels of the spectrum of which satisfies the side condition.Therefore, the energy of the time evolved system state crosses multiple energy levels of the Hamiltonian in Eq. (8).The kinks in the energy spectra (as the one near s = 0.4 and s = 0.8 in (b)) occur when higher-energy states cross the ground state because the energy difference to the instantaneous ground state is shown.These crossings of the instantaneous ground state with states of different magnetization sectors are allowed and even necessary here.
the time-dependent Hamiltonian given in Eq. (8).If the solution of the problem with side condition is the n-th excited eigenstate of the problem without side condition, the instantaneous energy of the system has to cross at least n energy levels of the spectrum of the time-dependent Hamiltonian.This effect can be explained by the fact that the system is initialized in the instantaneous ground state and has to end up in an excited state after the adiabatic annealing process.If we only consider the subspace of side-conditionsatisfying eigenstates (colored lines in bottom row of Fig. 2) we are able to see that the system follows the instantaneous conditioned ground state without any level crossings inside this subspace.
In the case that the non-degenerate conditioned ground state is one of the degenerate ground states of the problem without side condition, the unique solution is reached.For the case that the conditioned ground state Ψ (c) gs is degenerate, these degenerated states are populated with a bias, influenced by a combination of the choice of the parity layout, the chosen exchange terms and the strength of the parity constraints.Note that a similar effect was used to program superpositions in unconditioned models using the strength of the parity constraints C l [48].For more details on degenerate conditioned ground states we refer to Appendix F.
Next, we discuss multiple side conditions with different values z for j = 1, ..., M .If the different side conditions are disjoint in the parity encoding, this method can be extended in a straightforward manner.For details we refer to Appendix C. By using ancilla qubits, a parity layout can be constructed, where the qubits included in all given disjoint side conditions are arranged next to each other.In general, one has to pay the price of more qubits and more parity constraints (i.e., physical couplings).We give an example for one side condition for which the introduction of an ancilla qubit is necessary to arrange all conditioned qubits next to each other in Appendix A. The same can be done for multiple side conditions as long as they do not overlap in the parity encoding.We also give an example where two side conditions can be encoded without any ancilla qubits and additional parity constraints.
If two side conditions overlap in one or more parity qubits, this method with the given exchange Hamiltonian (7) cannot be applied directly.However, as long as the complexity of overlapping side conditions is not to high, utilizing Hamiltonians with exchange terms including more than two qubits could be the solution, but this point certainly needs further research.We provide an example in Appendix A.2.

Digital Quantum Computing
In digital quantum computing, an initial state is transferred to a final state via unitary operations.In the quantum approximate optimization algorithm (QAOA) [18] these unitaries are constructed from the Hamiltonian encoding the optimization problem and a driver Hamiltonian, usually given by single body σ x terms.In our approach the unitaries are defined by their corresponding Hamiltonians from Eq. (8) which also includes exchange terms [see Eq. (7)] as driver terms.For example, the local field term of the problem Hamiltonian given in Eq. (4) corresponds to the unitary Each unitary contains a parameter (here α) which is variationally updated in the QAOA.To simplify the implementation of the unitary corresponding to H exch. and improve the flexibility of this approach, one can partition the exchange terms such that parts that share qubits are applied sequentially, e.g., ) for a side condition including qubits j, k and l.Mixing operators similar to U exch. have also been investigated in Refs.[25,34,35], although in the context of purely linear side conditions on the logical qubits.In contrast to that, this method is applicable to more general side conditions.
For the simulations presented here we use the partitioned unitary with a single parameter for the different parts (i.e., δ = in Eq. (11), details on the parametrization can be found in Appendix G).The final state for a QAOA sequence of length p is then given by The initial state |ψ 0 has to be prepared in the sidecondition-satisfying subspace.This can be achieved by preparing the conditioned qubits in [C] in a computational basis state that fulfills the side conditions, while the unconditioned qubits in [U] are prepared in the σx -eigenstate |+ .Alternatively, one can prepare the conditioned qubits in a Dicke state |D n k , where k excitations are symmetrically distributed over all n conditioned qubits.The preparation of such states requires O(kn) gates [49].To remove any potential bias by the choice of the initial state 1 , the conditioned qubits are initialized in a Dicke state with k chosen to fulfill the corresponding side condition, e.g., where K is the number of physical qubits.For this example, fulfilling a side condition with target c = 2k − n = −1, the Dicke state would be Figure 3 shows a comparison of this approach (denoted exchange) with the fully parallelizable QAOA in the LHZ architecture [36] introduced in [50] (denoted penalty), where each side condition is treated 1 The Hamming distance between a specific computational basis state and the solution of a side condition on n qubits is between 0 and n−1.Thus, starting with a computational basis state can either render the exchange term irrelevant or in the worst case require a sequence-length of p ≥ n − 1 to transfer the excitation to the right place.
is highlighted for cm = −1 (exchange/penalty in orange/blue) and cm = +1 (green/red).The panels in (b) show the probability of measuring the target state and the expectation value cm = σ(1,2) for the variational state during the iterations of the parameter optimization, for the highlighted cases in panel (a).Note that in the exchange protocol cm is constant by definition, while the penalty protocol has an additional constraint to optimize.
by adding an energy penalty to the cost function.We consider the optimization problem in Fig. 1(b) with the same local fields as in Eq. (9), and take into account all possible side conditions in either a row (e.g., σ ) and a few additional side conditions which include 4 or 5 qubits (see Appendix G for a complete list).Here, we explicitly show the performance for different geometries of side conditions for the QAOA because they directly influence the applied gate sequence and the performance.For a fair comparison only target values of c which do not uniquely define the state of the conditioned qubits are chosen as side conditions.Otherwise, the exchange term would have no effect and the problem size for the exchange protocol would effectively be reduced to just the unconditioned qubits.The variational state for the penalty protocol is given by with the driver unitary U x (γ j ) = exp(−iγ j H x ) treating all qubits as being in [U], i.e., we apply the spin flip driver to all physical qubits.The cost function is given by E = ψ|H C + H final + H penalty |ψ , with an energy penalty of the form for the penalty protocol, where c target denotes the value to which the side condition is restricted to.The values of C l in H C and C penalty in Eq. ( 15) are set to 4 and we use a QAOA sequence of length p = 2.The probabilities shown in Fig. 3  We observe that both the exchange-and penaltyprotocol perform comparably well if the ground state of the unconditioned problem also fulfills the side condition (which is the case for the points in Fig. 3(a) with P penalty ≥ 0.3).For the other cases the exchange protocol clearly outperforms the penalty protocol.In some cases (e.g., the red line in Fig. 3(b)) the penalty protocol does not converge to the true solution, even though the side condition is approximately fulfilled.This might be remedied by directly including the energy penalty into the compilation process for the physical Hamiltonian (and thus also the QAOA unitaries), which in turn would require more hardware resources.In-depth benchmarking of the QAOA performance and its hardware requirements in these different approaches will be the topic of future research.

Conclusion
We presented a method to implement and solve optimization problems with additional side conditions in the parity architecture [36,37].The standard approach to implement such side conditions is to embed them as quadratic energy penalties.Recent papers like Ref. [22] or Refs.[23,24] suggest alternative methods to embed pure sum constraints, i.e., i σ (i) z = c, in a potentially more efficient manner.Beyond that, this approach enables the embedding of general equality conditions of the form of sums over arbitrary kbody products of spin variables, leading to an alternative to the penalty method.The method given by Ref. [22] is applicable only for quantum annealing devices based on the Chimera graph.In Refs.[23,24], the alternatives to penalty terms are more general, but their experimental feasibility is uncertain.Other recent works [25,34,35] give an alternative to the penalty method for the quantum alternating operator ansatz, using individual mixing Hamiltonians for each class of optimization problems.Compared to that, in our approach the mixing operators and driver Hamiltonians result from the compilation of a valid parity layout, which means that no mixing terms must be found and the implementation is already given by the encoding step.
We compare the encoding of optimization problems in digital and analog applications and find a considerable improvement compared to standard encoding based on energy penalties.Note that in previous architectures, it has been shown that practically implementing such driver terms remains challenging [39,40].
An interesting future outlook is to study the performance of encoded side conditions in the parity architecture in presence of noise or in finite temperature environments.
[62] Tim Menke, William P. Banner, Thomas R. Bergamaschi z σ (2)  z + J 16 σ (1)  z σ (6)   z + J 14 σ (1)  z σ (4)  z + J 26 σ (2)  z σ (6)   z z σ (5)  z + J 45 σ (4) z σ (5)   z + J 56 σ (5)  z σ (6)   z (16) with the side condition c = σ (1)  z σ (2)  z + σ (2)  z σ (3)  z + σ (2)  z σ (6)   z . ( The σ are logical qubits and the J ij are 2-body interaction strenghts.Each of the products of logical qubits is transformed to one physical qubit σ , such that we have 9 physical qubits in the parity encoding.Each of the interactions maps to a local field J αij in the parity encoding.The products of logical spins in the side condition are given by the three physical qubits σ(1,2) z and σ(2,6) z and the whole side condition in the parity encoding is given by the sum over these physical qubits, i.e., All of the conditioned qubits are present as interaction terms in the logical graph and therefore it is sufficient to find a parity layout for the problem, where all conditioned qubits are connected via neighbors.To find the parity constraints we consider first all closed cycles in the logical graph, which are (σ (3,4)   z , σ(4,5) (σ (2,3)   z The logical problem and side condition in this example have only 2-body terms, which gives us a global spin flip degeneracy (D = 1).We have N = 6 logical qubits and K = 9 parity qubits.This is why we know that we need K − N + D = 9 − 6 + 1 = 4 parity constraints for a valid parity layout.If we construct the generator matrix G and the parity check matrix P with only 3-body and 4-body rows as explained in Ref. [37], we are able to find all combinations of four rows of the parity check matrix, which gives us all the possible ways to find a valid parity layout.From the first four closed cycles [Eqs.( 19)-( 22)] listed above we can construct the whole physical lattice, where each of these closed cycles is represented by a parity constraint, which consist either of three or four physical qubits.Furthermore, the choice leads to a physical lattice, in which the conditioned physical qubits are connected via neighbors.The Hamiltonian in the parity encoding is written as z .
An alternative parity layout in which all conditioned qubits are connected via neighbors can be constructed out of the first two [Eqs.(19), (20)] and the last two [Eqs.(22), (23)] parity constraints.This alternative parity layout is shown in Fig. 13(a).
Note that the example considered in the main text without the side condition belongs to the quadratic unconstrained binary optimization (QUBO) problems, i.e., it includes only 2-body interactions.For an all-to-all connected QUBO problem the parity encoding is equivalent to the so-called LHZ architecture, which was presented in Ref. [36].There the authors showed, that a fully connected QUBO problem of size N requires O(N 2 ) physical qubits in this embedding scheme.In the case of the parity encoding of a QUBO problem with less than all-to-all connectivity the number of needed parity qubits K, including eventually necessary ancilla qubits, can never be bigger than the number of parity qubits which result from an all-to-all connected QUBO problem, since each QUBO problem can always be encoded as a sub-graph of the all-to-all connected graph.This means, that the parity encoding of a QUBO problem requires O(N 2 ) qubits in the worst case.
Transformation for a side condition with additional product terms -If the side condition includes products of logical spins (including single spins), which are not present in the logical Hamiltonian, one has to add more physical qubits and possible ancilla qubits and therefore one needs additional parity constraints, i.e., more physical couplings.Nevertheless, with the help of ancilla qubits it is possible to find a parity encoding for most optimization problems in which the conditioned physical qubits are adjacent.To give an idea on how to do this, an example is presented in Fig. 4. The examples given here are simple, but the method can be extended to more complicated cases.
Transformation of side conditions with the need of ancilla qubits -As a first example we take the same Hamiltonian [see Eq. ( 16)] but with the side condition c = σ (1)  z σ (2)  z σ (3) For this example we have to add the ancilla qubit σ(2) z to ensure a valid encoding.We get the same chip as in Fig. 1 with the two additional physical qubits σ , both with zero local field, and the additional parity constraint consisting of the four physical qubits σ(2,3) z and σ(1,2,3) z .Figure 4 shows the logical problem and the corresponding parity encoding.
Two disjoint side conditions -A simple example for the case of two disjoint (in the parity encoding) side conditions could be the following Hamiltonian, which has single, 2-body and 3-body terms H = J 2 σ (2)  z + J 12 σ (1)  z σ (2)   z + J 15 σ (1)  z σ (5)  z + J 24 σ (2)  z σ (4)   z + J 45 σ (4) z σ (5)  z + J 123 σ (1)  z σ (2)  z σ (3)   z + J 345 σ (3)  z σ (4)  z σ (5)   z (26) with the two side conditions in the logical encoding.The side conditions in the parity encoding are again only sums of single physical qubits Side Condition: σ z σ (3) z σ (2) While the logical side conditions do overlap in the single qubits σ (2) z and σ z , in the parity encoding the side conditions are disjoint, because of the fact that each product of logical qubits transforms to a single parity qubit.In general, as long as the terms of multiple side conditions consist of different products of logical spins, the side conditions in the parity encoding are disjoint.The Hamiltonian given in Eq. ( 26) is presented in Fig. 5(a) as a logical graph.In the parity encoding, the Hamiltonian and the side conditions are both given in the physical graph.Each product of logical qubits in the side conditions which does not exist in the logical problem Hamiltonian needs an extra physical qubit.All physical qubits are composed with parity constraints to a parity layout.The parity constraints again ensure a clear correspondence between logical and physical states.In this example a transformation even without the use of ancilla qubits is possible.
General procedure with side conditions -For any logical Hamiltonian with side conditions we can use the parity transformation as it is described in Ref. [37].We use the concepts of the generator matrix G and parity check matrix P to describe the parity transformation as introduced in Ref. [37].First we set up a new generator matrix G, by adding a column for each product of logical spins which are only given in the side condition.Then we proceed as described in Ref. [37] to find a suitable parity check matrix P and from there a parity layout.In the last two steps it could be necessary to introduce ancilla In the parity encoding, the problem is translated to a Hamiltonian that encodes the unconditioned as well as the conditioned part.The qubits of the conditioned part are connected via adjacent conditioned qubits (yellow and orange).In the parity encoding the side conditions are pure sums over single parity qubits and they do not overlap.
qubits.The only difference in finding a valid parity check matrix P compared to the case without side conditions is that here one has to select rows of P with the extra condition that the qubits included in the side condition can be arranged adjacent in the parity layout.If this is not possible, we have to add ancilla qubits such that this is possible.The parity transformation can also be applied in the presence of side conditions for optimization problems with Hamiltonians represented by hypergraphs (i.e., interactions including more than two qubits).In the parity encoding each hyperedge of degree k is encoded by one physical qubit σ(i1,i2,...,i k ) and with a sufficient number of suitable ancilla qubits one can find a parity layout, in which every side condition is presented by parity qubits, which are arranged next to each other.Note, that the minimal number of ancilla qubits necessary for compiling with side conditions is still an open question and part of ongoing research, even for the case that the underlying optimization problem is a QUBO problem.In some cases, such as a side condition having no or exactly one solution, preprocessing can be used to solve the problem more efficiently.In the following we discuss some special cases of interrelation between the parity constraints and side conditions including further demonstrations of the parity transformation in the presence of side conditions.
Decoding -For the process of decoding a parity encoded state back to a logical qubit state we refer to the corresponding section in Ref. [37].In an ideal device without any noise that procedure can be used for both cases, with and without additional hard side conditions.In the presence of device dependent errors one has to use different decoding strategies.In that case, some of the parity constraints can be violated at the end of the computation, which can lead to contradictions in the decoding process of the logical state.For the case without hard side conditions different error correcting/mitigating decoding strategies have already been proposed, e.g., for quantum annealing devices as explained in Refs.[68,69] and for digital ones using the QAOA as explained recently in Ref. [70].For the method presented here, which encodes additional hard side conditions for both, analog and digital devices, the decoding strategies have to be adapted.If the side conditions are not taken into account, these decoding strategies can lead to unsatisfied side conditions in the decoded state.In the strategy for QAOA presented in Ref.
[70] one could for example only use spanning trees, which cover all conditioned qubits in the parity encoding.For belief propagation, as suggested in Ref.
[69] as a decoding strategy for quantum annealing, one could fix the probabilities of all conditioned qubits to be in their respective state to 1 and never update these probabilities during the iteration of belief propagation.This should give the reader an idea that small changes in the existing decoding strategies for noisy devices can conserve the side conditions.The details and the performance of the decoding strategies which include side conditions in the presence of errors is a part of future research work.

A.1 Interrelation between parity constraints and side conditions
There are four cases in which one can think of interrelations between parity constraints and side conditions.
Arranging conditioned qubits -It can be the case that there is no parity layout for the physical qubits representing the given interaction terms and side conditions where the side conditioned physical qubits are connected via adjacent qubits.In this case one has to add ancilla qubits to obtain a layout in which the side conditioned qubits are adjacent and therefore additional parity constraints are needed.In Fig. 6 we give an example, where we have to introduce at least the two ancilla qubits σ(1,5) Moreover, the two ancilla qubits require two additional parity constraints for a valid layout.

Conditioned qubits that do not appear in the problem
Hamiltonian -As it is explained above in Appendix A, in general new spin products in the side condition lead to additional parity qubits and therefore to additional parity constraints (see Fig. 4).But in the case that a side condition is a single product term, it can be subsumed into the parity con- (2) In the parity encoding, the problem is translated to a Hamiltonian that encodes the unconditioned as well as the conditioned part.The side condition is implemented as exchange term among adjacent conditioned parity qubits (yellow).We need two ancilla qubits (grey), and therefore two additionally parity constraints, to lay out the side conditioned parity qubits as neighbors, although no additional parity qubits for the product terms in the side conditions itself are needed.straints and it is not necessary to introduce additional qubits or to use more parity constraints.For more details we refer to Ref. [37].

Violated parity constraints -
The next cases we want to discuss are potential conflicts between parity constraints and side conditions.The first case is that a side condition can only be fulfilled if one or more parity constraints are violated.The second case is that multiple disjoint side conditions with neighboring parity constraints can only be fulfilled at the same time if one or more parity constraints are violated.With the dynamics presented here, we will start and end up in a system state, which fulfills the side conditions but has at least one violated parity constraint.But both cases are not real conflicts, because in these cases an invalid parity constraint means that the side conditions are not solvable.With classical preprocessing one can exclude these cases before the compilation process.Every side condition over binary variables as given in Eq. ( 2) can be rewritten in a conjunctive normal form (CNF) and checking if a CNF can be satisfied is a boolean satisfiability problem (SAT), which is known to be NP-complete.Since checking if a side condition is satisfiable is NP-complete, classical preprocessing is not an option for every side condition.We want to note, that the method presented here is mainly intended for optimization problems with additional side conditions, where the focus is not on the satisfiability of the side condition itself.In a large amount of these problems the satisfiability of the additional side conditions is presumed or can be easily checked, which for example is the case for the class of scheduling problems [26,32].
To give an example for each of the two cases we take the logical Hamiltonian in Fig. 1 for both examples.
For the first example we think of the side condition − 2 = σ (1)  z σ (2)  z + σ (2)  z σ (3)  z + σ (3)  z σ (4)  z + σ (1)  z σ (4)   z (31) or in the parity encoding This side condition is only fulfilled if three of the physical qubits have eigenvalue -1, which in any case leads to a violated parity constraint.But on the other hand, we note at this point that if a parity layout exists, in which the conditioned parity qubits build exact one existing 3-or 4-body constraint, the corresponding parity constraint can be dropped.This means the side condition leads to fewer physical couplings.
For the second example we can think of the two side conditions −2 = σ (3)  z σ (5)  z + σ (4)  z σ (5)   z , ( z σ (2)  z + σ (2)  z σ (3)  z + σ (1)  z σ (4)   z (34) or in the parity encoding Both side conditions are only fulfilled if one of the involved parity constraints is violated.In Fig. 7 we illustrate both cases.If a side condition is solvable and the annealing process ends up in a parity constraint violating state, the parity constraints strength was chosen too low and has to be increased.

Degenerate groundstates -
The last case of interrelation, is only present if the conditioned problem has a degenerated ground state manifold.In this case, the probabilities of the degenerated ground states are biased due to the combination of the choice of the exchange Hamiltonian and the given parity constraints and the corresponding parity layout.As shown in Ref. [48], the probabilities of degenerated ground states in unconditioned problems are biased by the values of the parity-constraint strengths.In a similar manner, we can show how the combination of parity layout, exchange Hamiltonian and parity constraints influences the ground state populations for problems with side conditions.We will explain it with an example in more detail in Appendix F.

A.2 Overlapping side conditions
If side conditions are not disjoint (see Appendix A) we call them overlapping side conditions.As we show in the example given in Fig. 5, side conditions only overlap in the parity encoding if they contain the same product of logical qubits.Therefore, we again consider the Hamiltonian from Eq. ( 26), but with the First we follow Ref. [17] to bring this inequality into a system of equalities.Here, the expectation values of logical qubits are σ (i) z ∈ {±1} and the sum can take a discrete number m of different values, which depend on γ.Here, for γ < −3 it is m = 0 and no solution exists, for − it is m = 3 and for 3 ≤ γ it is m = 3, but the side condition will not restrict the space of solutions any longer.
We introduce m ancilla qubits σ (j) z with j = N + 1, ..., N + m, which have to fulfill the equalities and The values β i are the discrete values such that = β i exists.These two equalities together replace the inequality.The second equality can be written as which we will use later.Here we show a possible parity encoding with side conditions for the case γ = 0.In this case we have m = 2, β 1 = −3 and β 2 = −1 and we need two logical ancilla qubits to transform the inequality into the two equalities σ (5)  z + σ (6) For the parity encoding we get the four physical qubits σ( z from the optimization problem, the three physical qubits z from the inequality and two physical qubits σ(5) z and σ(6) z from the ancilla qubits to write the inequality in form of two equalities.For a valid parity transformation we need no further ancilla qubits in this case.The physical qubits σ(5) z and σ(6) z included in equality (49) are neighboured and all other conditioned qubits are connected via adjacent qubits in the given parity layout.A valid parity layout for this example is shown in Fig. 8(b).
The two side conditions are overlapping and thus we need an exchange Hamiltonian with higher-body terms, which conserves both side conditions.We have to take into account that the physical qubits in the second side conditions have coefficients g Inequality Condition:  The solution of the unconditioned part is the ground state of the spin model.In addition, a side condition in the form of an inequality on the spins is given (bottom).(b) In the parity encoding, the side conditions are implemented as exchange terms among parity qubits that are part of the first side condition (filled yellow) and the second side condition (colored red), which together represent the inequality side condition.The exchange terms among physical qubits which are not in the overlapping part can be realized by two body exchange terms, as long as they have the same coefficient in the side condition.For this example we need four different exchange terms (four different colors of lines connecting conditioned qubits), two 2-body and two 3-body exchange terms, given in Eq. (60).
lead to a change of 2. We are able to find in total six exchange terms among nearest neighbors, thereof two 2-body terms, two 3-body terms and three 4-body terms.
The terms (57) and (58) can be dropped, because the first side condition (49) only allows one of the qubits z to be in the state with eigenvalue 1, which means applying terms (57) and (58) on states, which fulfill both side conditions will give a zero contribution.The terms (53), ( 54), ( 55) and (56) are enough to reach every state, which fulfills both side conditions.All eigenstates, which fulfill both side conditions have one of the four alignments of the subset

B Annealing protocol
The time dependent protocol used in the numerical examples is given by A(s) = (1 − s) 2 , B(s) = E(s) = Γs(1 − s) and C(s) = D(s) = s, where s = t/t f ∈ [0, 1] and t f is the final annealing time of the annealing process, illustrated in Fig. 9. Therefore, the time-dependent Hamiltonian given in Eq. (8) explicitly written-out is given by The factor Γ has to be chosen suitably.If Γ is too small the energy gap between the conditioned ground state and the next higher conditioned state may close.This means that large annealing times are needed in order to stay in the conditioned ground state during the annealing process.

C Hamiltonian dynamics for multiple disjoint side conditions
The dynamics presented in the main text can be easily extended to multiple disjoint side conditions.The Hamiltonians H final , H C and H x stay unchanged, where [U] runs over all qubits, which are not included in any of the side conditions.For the initial Hamiltonian we can simply separate the sums over the qubits of different side conditions, because they have no overlap.For M disjoint side conditions one can use the initial Hamiltonian (62) where the sum [C k ] runs over all qubits that are included in the k-th side condition.The coefficients η (j) i are chosen such that the side condition j with target c j is satisfied, i.e., for each of the M side conditions with [Cj ] i σ(i) z = +c j , the local fields are chosen to fulfill [Cj ] i η (j) i = − c j .Furthermore, the exchange Hamiltonian can be written as + ...
where [C k ] * denotes the sum over all neighboring pairs of qubits in [C k ].Everything else stays unchanged compared to the dynamics for a single side condition.
If one or more side conditions include qubits that cannot be laid out in neighboring positions, we need ancilla qubits and additional parity constraints to realize a parity layout in which all qubits which are included in the same side condition are adjacent.If we consider the example in the main text with an additionally side condition like c 2 = σ

D Multiple level crossings
The combination of exchange terms and spin-flip terms may lead to multiple level crossings in the instantaneous energy spectrum even if the conditioned ground state is already the ground state of the optimization problem without side conditions.We call it multiple level crossings, when the instantaneous conditioned ground state energy (lowest blue line in Fig. 10) crosses multiple instantaneous energy levels, which do not lie in the subspace of side-conditionsatisfying states (grey lines in Fig. 10).The exchange term enforces conservation of the sum of all spins included in the side condition, making the system stay in the subspace of side-condition-satisfied eigenstates during time-evolution.As the instantaneous ground state does not necessarily lie in this subspace, multiple crossings of the instantaneous energy levels can occur.This means, that if we only consider the instantaneous spectrum of this subspace, we have an energy spectrum without any crossings between the conditioned ground state and the next excited conditioned state in this subspace.

E Adiabatic condition
Here we present an example for a non-adiabatic annealing process for the annealing protocol given in Eq. (61). Figure 11 depicts a problem example with a small minimum energy gap between the conditioned ground state and the next higher conditioned state at s 0.86 in the annealing process.The given example The initial state is given by The time evolution of the system state energy E evol crosses the energy levels of the first and second excited states.
(b) The initial state is given by The time evolution of the system state energy E evol crosses the energy levels of the first, second and third excited states and ends up in the ground state level.For both cases, (a) and (b), the initial state and the unconditioned ground state satisfy the side condition.
is implemented by the same parity layout as shown in Fig. 1, but with the side condition the local fields J 23 = 0.8, J 12 = 0.6, J 26 = 1, J 34 = 0.7, J 14 = 0.8, J 16 = 0.6, J 35 = 0.95, J 45 = 0.7 and J 56 = 0.8 and the exchange Hamiltonian We consider the minimum energy gap ∆ min in the subspace of the conditioned states, i.e., the subspace which is spanned by all eigenstates of H(s) [see Eq. ( 8)] satisfying the side condition (colored lines in Fig. 11).We denote the energies of the subspace of side-condition-satisfying eigenstates as E c i (s), while the energies of the full instantaneous spectrum are denoted as E i .The conditioned ground This figure shows the instantaneous spectrum for a problem instance with a side condition that is satisfied by the second excited state (lowest blue line at t = t f ), i.e., the conditioned ground state with E c 0 (s = 1) = E2(s = 1).The third excited state of the problem Hamiltonian also satisfies the side condition and is therefore the first excited conditioned state with E c 1 (s = 1) = E3(s = 1).Close to s = 0.86 the annealing process becomes diabatic for t f < 4000, because of the small minimum energy gap ∆min between E c 0 (s) and E c 1 (s) at s 0.86.In this case the system ends up in a superposition of the conditioned ground state (second excited state) and the first excited conditioned state (third excited state).(b) The probabilities P for the system to be in the conditioned ground state Ψ | 2 ) (bright blue bullets) for different final annealing times 0 < t f ≤ 4010.For long enough annealing times (i.e., t f > 4010) the system is in the conditioned ground state at the end of the annealing process.
state energy and the first excited conditioned state energies are given by E c 0 (s) and E c 1 (s), respectively.To estimate the computation time t f for this annealing protocol we have to consider the minimum energy gap between E c 0 (s) and E c 1 (s), i.e., ∆ min = min 0≤s≤1 E c 1 (s) − E c 0 (s).This differs slightly from the annealing protocols where the minimum energy gap g min = min 0≤s≤1 E 1 (s) − E 0 (s) of the full instantaneous energy spectrum limits the process velocity.Here, zero energy gaps in the instantaneous energy spectrum during the annealing process are necessary to allow adiabatic level crossings.This results in an adiabatic evolution inside the subspace of the conditioned states.By fine-tuning the value of Γ one can increase the minimum gap ∆ min and therefore reduce the annealing time t f required for adiabaticity.In Fig. 12 the same example as in Fig. 11  Eevol 0.0 0.5 1.0 s min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 min 0.12 (b) = 6 The minimum energy gap is increased to ∆min 0.12 at s 0.89.For higher values of Γ the minimum energy gap does not increase much more and moves towards s = 1.
imize computation times, by optimizing the value of Γ.But this has to be done carefully.If Γ becomes much larger (typically quadratically larger or more) compared to the energy scales of the system without H exch. , it introduces a new energy scale.In practice, this is critical with respect to the programmable interactions and can worsen error rates.We remark at this point that the choice of the initial state also affects the size of the minimum gap.

F Degeneracy
Here we present an example to illustrate how the choice of exchange terms and the parity layout influences the probability distribution in a degenerate ground state manifold for the conditioned problem.We use a problem example given by the logical graph in Fig. 1 and encoded by the local field vector J = (1.0,−0.5, 1.0, −1.0, 0.5, −0.5, −1.0, −1.0, 1.0) T = (J 23 , J 12 , J 26 , J 34 , J     Schrieffer-Wolff transformation as shown in Ref. [48].The Schrieffer-Wolff transformation is not restricted on the lowest energy sector and works for each set of eigenstates, which have eigenenergies well separated from the rest of the spectrum [71].Here we consider a subspace containing the degenerated conditioned ground states, which are well separated from the other eigenstates of the spectrum.We can write the Hamiltonian in the following form ) where H 0 is the unperturbed Hamiltonian and is given by and V is the perturbative term (for s 1) ) .Now we want to determine the effective Hamiltonian for each of the six cases listed above.Depending on the choice of the exchange Hamiltonian we need third, fourth or fifth order perturbation theory.For the exchange Hamiltonian of case (i), (ii), (iv) and (v) third order is enough.For case (vi) we need fourth order and for case we even need the effective Hamiltonian in fifth order in perturbation theory.Up to fourth order in perturbation theory, the explicit expression for the effective Hamiltonian is given in Ref.

Figure 1 :
Figure 1: (a) The standard approach to encode optimization problems on a quantum device is to separate the unconditioned from the conditioned part.The unconditioned part of the optimization problem is encoded as a spin model (top).Each node (circle) represents a logical spin, which can either be up or down.The edges (lines) represent interactions between the spins.The solution of the unconditioned part is the ground state of the spin model.In addition, a side condition on a subset of the spins is given (bottom).(b) In the parity encoding, the problem is translated to a Hamiltonian that encodes the unconditioned as well as the conditioned part.The unconditioned part is encoded in a lattice gauge model, where nodes represent parity variables and interactions are local 3-body (red) or 4-body (blue) terms.The side conditions of the optimization problem are implemented as exchange terms among the conditioned parity qubits (yellow).In the parity encoding this specific side condition needs no extra resources.

z
which are in [C] (yellow) and the rest of the qubits are in [U] (white).If new physical qubits are required for the side condition, generally one has to add parity constraints to integrate the physical qubits into the physical lattice of the parity encoding.

Figure 2 := − 1 = 1 ,
Figure 2:Adiabatic sweep for a system with N = 9 qubits and time s(t) = t/t f with t f = 500.The top row in Fig.2 (a) and (b) shows the instantaneous energy spectrum, where all instantaneous eigenenergies of the time-dependent Hamiltonian in Eq. (8) are given with respect to the ground state energy, ∆E = Ei − E0.The energies of conditioned eigenstates, which lie in the side-condition-satisfying subspace are colored, while all the other ones are grey.The evolution of the system state energy E evol (black dots) with time follows the instantaneous energy levels of the time-dependent Hamiltonian.The bottom row of Fig.2(a) and (b) shows the timedependent expectation value σ(i) z (s) for each spin i, following the systems configuration state evolution in time.For the spins included in the side condition, the expectation values are highlighted, while the unconditioned ones are presented in pale colours.(a) The side condition is given by the sum constraint σ(2,3) z + σ(1,2) z + σ(2,6) z = −1 and the initial state is set to |Ψ (a) (0) = |−1, 1, −1, −1, 1, 1, −1, 1, −1 .The initial state and the unconditioned ground state Ψ (u) gs satisfy the side condition.The energy of the system follows the instantaneous ground state energy.(b) For the side condition given by σ(3,4) z + σ(1,4) z + σ(1,6) z = 1, the conditioned ground state Ψ (c) gs is equal to the eighth excited state of the unconditioned problem.The initial state is set to|Ψ (b) (0) = |−1, 1, 1, 1, −1, 1, −1, 1, −1 ,which satisfies the side condition.Therefore, the energy of the time evolved system state crosses multiple energy levels of the Hamiltonian in Eq.(8).The kinks in the energy spectra (as the one near s = 0.4 and s = 0.8 in (b)) occur when higher-energy states cross the ground state because the energy difference to the instantaneous ground state is shown.These crossings of the instantaneous ground state with states of different magnetization sectors are allowed and even necessary here.

Figure 3 :
Figure 3:Comparison of the QAOA performance using exchange terms and energy penalties to treat side conditions.(a) Scatter plot of the highest reached probabilities to find the lowest-energy state fulfilling the side condition for a given selection of side conditions (see main text) for the exchange protocol versus the penalty protocol.A point (P exchange , P penalty ) represents the maximal probabilities reached for a specific target-state (given by the side condition and the target value of c ) for both protocols, respectively.The side condition cm = σ(1)

Figure 4 :
Figure 4: (a) The unconditioned part of the optimization problem is the same as in Fig. 1(a).In addition to the optimization problem encoded in the logical graph, the side condition is given separately as σ (2) z σ (3) z + σ (1) z σ (2) z σ (3) z = c.(b) In the parity encoding, the encoding of the side condition needs an extra physical qubit for the encoded product σ (1) z σ (2) z σ (3) z , which is not given in the problem Hamiltonian.Additionally, an ancilla qubit σ(2) z (grey) together with the additional 4-body parity constraint σ(2) z σ(1,2,3) z

Figure 5 :
Figure 5: (a) The unconditioned part of the optimization problem is encoded in a hypergraph (top).In addition, two side conditions on the spins are given (bottom).They do overlap in the logical qubits σ (2) z and σ (3) z .(b) In the parity encoding, the problem is translated to a Hamiltonian that encodes the unconditioned as well as the conditioned part.The qubits of the conditioned part are connected via adjacent conditioned qubits (yellow and orange).In the parity encoding the side conditions are pure sums over single parity qubits and they do not overlap.

Figure 6 :
Figure 6: (a) The unconditioned part of the optimization problem is the same as in Fig. 1.The side condition is given separate as σ (1) z σ

z
changes the sum by a factor of 3, flipping σ(6) z gives a change of 1 and all the other ones

Figure 8 :
Figure 8: (a) The unconditioned part of the optimization problem is encoded as a spin model (top).Each node (circle) represents a logical spin, which can either be up or down.The edges (lines) represent interactions between the spins.The solution of the unconditioned part is the ground state of the spin model.In addition, a side condition in the form of an inequality on the spins is given (bottom).(b) In the parity encoding, the side conditions are implemented as exchange terms among parity qubits that are part of the first side condition (filled yellow) and the second side condition (colored red), which together represent the inequality side condition.The exchange terms among physical qubits which are not in the overlapping part can be realized by two body exchange terms, as long as they have the same coefficient in the side condition.For this example we need four different exchange terms (four different colors of lines connecting conditioned qubits), two 2-body and two 3-body exchange terms, given in Eq. (60).
A large Γ introduces a new energy scale and the advantage over the method using penalty terms vanishes.Here we use Γ = 4 for all examples.The strength of the parity constraints is set to C l = −4 and the exchange term constant is set to γ e = 1/2 for all examples.

Figure 9 :
Figure 9: The annealing schedule used for the numerical quantum annealing examples in this work.
z we do not need any ancilla qubits.Possible conflicts between side conditions and parity constraints are further discussed in Appendix A.1.

1 Figure 11 :
Figure11:(a) Non-adiabatic sweep for s = t/t f with t f = 310 and Γ = 4.The system leaves the adiabatic path and the process becomes non-adiabatic at the minimum energy gap ∆min in the subspace of conditioned eigenstates (colored lines).The colored lines are the energies of the instantaneous conditioned eigenstates of H(s) [see Eq. (8)] which satisfy the side condition, in relation to the instantaneous ground state energy E0(s) of H(s), i.e.,∆E c i (s) = E c i (s) − E0(s).This figure shows the instantaneous spectrum for a problem instance with a side condition that is satisfied by the second excited state (lowest blue line at t = t f ), i.e., the conditioned ground state with E c 0 (s = 1) = E2(s = 1).The third excited state of the problem Hamiltonian also satisfies the side condition and is therefore the first excited conditioned state with E c 1 (s = 1) = E3(s = 1).Close to s = 0.86 the annealing process becomes diabatic for t f < 4000, because of the small minimum energy gap ∆min between E c 0 (s) and E c 1 (s) at s 0.86.In this case the system ends up in a superposition of the conditioned ground state (second excited state) and the first excited conditioned state (third excited state).(b) The probabilities P for the system to be in the conditioned ground state Ψ gs (P = | Ψ(t f )|Ψ (c) gs | 2 ) (dark blue bullets) or in the first excited conditioned state Ψ (c) 1 (P = | Ψ(t f )|Ψ (c) 1

Figure 12 :
Figure 12: Instantaneous spectrum for the same example as given in Fig. 11(a) but for an annealing protocol with different values for Γ.The final annealing time t f = 310 is chosen here to be the same as in Fig. 11.(a) Annealing protocol for Γ = 5.The minimum energy gap is increased to ∆min 0.09 at s 0.88.(b) Annealing protocol for Γ = 6.The minimum energy gap is increased to ∆min 0.12 at s 0.89.For higher values of Γ the minimum energy gap does not increase much more and moves towards s = 1.

Figure 13 :
Figure 13: Two different parity layouts for the optimization problem given by the Hamiltonian in Eq. (16) and the side condition −2 = σ(2,3) z + σ(3,5) z + σ(4,5) z + σ(3,4) z .(a) Parity encoding for which the conditioned qubits are layed out in a loop, such that we are able to find in total five different ways to construct the exchange Hamiltonian.The couplings for the five different possibilities of an exchange Hamiltonian are shown as colored lines between conditioned qubits.(b) A second parity layout in which the conditioned qubits are adjacent.In this layout only one valid exchange Hamiltonian exists (salmon colored line).The colors of the six different coupling lines correspond to the colors used for the numerical results in Fig. 14.
Side condition indices C Target c

Figure 15 :
Figure 15: (a) Comparison between using the complete side condition vs. different methods of assigning parameters to the partitioned driver Hamiltonian for p = 2.A point (P partitioned , P complete ) represents the maximal probabilities reached for a specific side condition and value of c for both protocols, respectively.(b) Mean maximal reached probability P for the QAOA using different mixing unitaries for different sequence-lengths p, averaged over all side conditions and values of c .The error bars denote the standard deviation.The points are offset on the x-axis for better visibility.
are defined as P = | ψ|ψ target | 2 , where |ψ target denotes the lowestenergy state fulfilling the side condition.Details on the parameter optimization and a comparison of different ways to partition U exch. are available in Appendix G.
59)Let us call them states of type α i and write them as |φ αi .Then H exch.,1 maps between |φ α2 and |φ α3 , H exch.,2 maps between |φ α2 and |φ α4 , H exch.,3 maps between |φ α1 and |φ α2 and H exch.,4 maps between |φ α1 and |φ α3 .This means that with the exchange Hamiltonian H exch. = H exch.,1 + H exch.,2 Adiabatic sweep for a system with N = 9 qubits.The upper panel shows the instantaneous energy spectrum, where all instantaneous eigenenergies Ei of the time-dependent Hamiltonian H(t) [see Eq. (8)] are given with respect to the ground state energy E0, i.e., ∆E = Ei − E0.As in Fig.2, the colored lines correspond to the energies of the subspace of eigenstates of H(t) satisfying the side conditions.The kinks are level crossings between the energies E0 and E1 in the spectrum.At the level crossing two subspaces meet, that of the conditioned Hamiltonian and that of the full Hamiltonian.The Figures in the bottom row show the corresponding time-dependent expectation values of all expectation values σ(i,j) z(t) for each site (i, j) of the system.The side condition is given by is given, but for annealing processes with higher values for Γ.By increasing Γ we are able to shift the required final annealing time to lower values.One can try to min- 14 , J 16 , J 35 , J 45 , J 56 ) T .The first nine eigenstates of the unconditioned problem Hamiltonian represented as spin configuration sates |ψ n = |n 23 n 12 n 26 n 34 n 14 n 16 n 35 n 45 n 56 with n The probability P (|ψi ) = | Ψ(t f )|ψi | 2 to find the final system state in the state |ψi is given for the two degenerate ground states |ψ6 and |ψ8 (bullet and triangle).It is calculated for final annealing times t f between 0 and 1110 for each of the six valid exchange terms (six different colors).It is clearly visible that the choice of the exchange term (and parity layout) changes the probabilities of the two degenerated ground state.For the given example we chose all parity constraint strengths to be equal C ijk(l) = C = −4.Case (i) and (v) lead to nearly the same result where state |ψ8 is preferred.For Case (iii) and (iv) (state |ψ8 is preferred) the final probabilities are opposite to the case (vi) and (ii) (state |ψ6 is preferred).For the cases (iii) and (vi) the system completely ends up in the states |ψ8 and |ψ6 , respectively.While case (ii) and (vi) prefer state |ψ6 , all the other cases prefer state |ψ8 as solution.It is remarkable that in case (vi) and (iii) a single state is given at the end of the annealing process, instead of a superposition of both degenerated ground states.