Theoretical Overview#

In this tutoral we will take a peek into the inner workings of the Qrisp QAOA module. From learning the main concepts of the algorithm we’ll take a deep dive into the QAOAProblem class, exploring its various components and how they come together to implement the algorithm. From defining quantum parameters to optimizing and measuring the final state, we’ll really get to see how this class functions under the hood.

QAOA in a nutshell#

The Quantum Approximate Optimization Algorithm (QAOA) is a hybrid quantum-classical variational algorithm designed for solving combinatorial optimization problems.

The quantum and classical part work together iteratively: the quantum computer prepares a quantum state and measures it, producing a classical output; this output is then fed into a classical optimization routine which produces new parameters for the quantum part. This process is repeated until the algorithm converges to an optimal or near-optimal solution.

Before even running the algorithm there is a need to define some initial state \(|\psi_0\rangle\), often chosen to be equal superposition state $$|s\rangle=\frac{1}{\sqrt{2^n}}\sum_z|z\rangle, $$ where \(n\) is the number of qubits.

The QAOA operates in a sequence of layers, each consisting of a problem-specific operator and a mixing operator. To be a little more exact, the state \(|\psi_0\rangle\) is then evolved under the action of \(p\) layers of QAOA, where one layer consists of applying the unitary phase separating operator $$U_P(C,\gamma)=e^{-i\gamma C}=\prod_{\alpha=1}^me^{-i\gamma C _{\alpha}}, $$ which applies phase to each computational basis state based on its cost function value; and the unitary mixer operator $$U_M(B,\beta)=e^{-i\beta B}, $$ where \(B\) represents a specific mixer operator that drives the transitions between different states. Because of properties of the unitaries’ eigenvalues, the QAOA parameters are bound to hold values \(\gamma\in\{0, 2\pi\},\) and \(\beta\in\{0,\pi\}\) which are then optimized classically.

After \(p\) layers of QAOA, we can define the angle dependent quantum state $$|\psi_p\rangle=|\boldsymbol\gamma,\boldsymbol\beta\rangle=U_M(B,\beta_p)U_P(C,\gamma_p)\cdots U_M(B,\beta_1)U_P(C,\gamma_1)|s\rangle.$$

The end goal in QAOA is now to optimize the variational parameters \(\gamma_p\) and \(\beta_p\) in order to minimize the expectation value of the cost function with respect to the final state \(\ket{\psi_p}\). This is done using classical optimization techniques.

It’s important to remember that QAOA provides an approximate solution, and its performance depends on factors like problem size and structure, choice of initial state, and number of layers \(p\). Increasing \(p\) generally leads to better solutions but also increases computational cost.

Alternating Operator Ansatz#

QAOA on its own is an efficient tool for exploring complex combinatorial optimization problems. However, as with any tool, there is always room for improvement and expansion. Its potential can be further expanded by introducing a broader range of operators, not just those derived from the time evolution under a fixed local Hamiltonian proposed in the original paper.

Exactly this concept is well illustrated in the paper “From the Quantum Approximate Optimization Algorithm to a Quantum Alternating Operator Ansatz” by Stuart Hadfield and his team. They have taken the foundational principles of the QAOA and extended them, creating an upgraded version that is both more adaptable and easier to implement. The main ideas we use in our implementations are inspired by this work.

Similarly to the original QAOA, we have several key components when implementing the Quantum Alternating Operator Ansatz:

  • COST FUNCTION: the cost function is problem-specific and defines the optimization landscape. In the Quantum Alternating Operator Ansatz, cost functions can be represented by more general families of operators.

  • INITIAL STATE: initial state can be any state over all computational basis states. It is in most cases chosen to be a uniform superposition.

  • PHASE SEPARATOR: this applies a phase to each computational basis state based on its cost function value. In the Quantum Alternating Operator Ansatz, we can use a wider range of operators tailored to each problem instance.

  • MIXER: drives transitions between different states. In the Quantum Alternating Operator Ansatz, mixers can be chosen from a broader set of unitaries, which allows for more efficient implementation and potentially better exploration of the solution space.

In their paper, Hadfield and his colleagues give us some really useful examples of how to formulate different problem instances using these building blocks. The appendix section, in particular, stands out as it provides detailed problem formulations, most of which are now implemented in Qrisp using the QAOAProblem class. The following table provides a detailed overview of the problem instances already implemented within our framework, along with their corresponding mixer type:

PROBLEM INSTANCE

MIXER TYPE

IMPLEMENTED IN QRISP

MaxCut

X mixer

Max-$\ell$-SAT

X mixer

E3Lin2

X mixer

QUBO

X mixer

MaxIndependentSet

Controlled X mixer

MaxClique

Controlled X mixer

MaxSetPacking

Controlled X mixer

MinSetCover

Controlled X mixer

Max-$\kappa$-Colorable Subgraph

XY mixer

Our QAOA journey doesn’t stop here. In the next tutorials we’re going to tackle two fascinating problems: MaxCut and Max-$\kappa$-Colorable Subgraph, showcasing multiple unique features of Qrisp, including the functionality of creating custom QuantumVariable types - get ready to add a splash of QuantumColor to your code.