Explore QAOA Qiskit for quantum optimization. Understand the core workflow, from setting up the cost Hamiltonian and ansatz circuit to using primitives like Sampler and Estimator for finding solutions.
One well-known hybrid quantum-classical technique created especially to find approximations for combinatorial optimization issues is the Quantum Approximate Optimization technique (QAOA). In order to address issues that are computationally difficult for traditional computers, it combines a quantum circuit to process quantum states with a classical optimization procedure to fine-tune parameters.
Core Concept and Relation to VQE
One well-known technique for solving issues where precise answers are hard to come by is QAOA. Its fundamental structure is an expansion of the optimisation framework of the Variational Quantum Eigensolver (VQE). A significant difference, though, is that QAOA uses its own unique and “fine-tuned” ansatz, whereas VQE permits a range of quantum circuit designs (ansatzes). Since the ground state of a problem-specific Hamiltonian is the best solution to the initial optimisation problem, QAOA’s main objective is to approach this state.
Problem Encoding
Coding the classical optimization issue into a Hamiltonian is a crucial first step in using QAOA. The problem’s cost function is accurately represented by this Hamiltonian. For example, it is possible to create challenges such as the Max-Cut problem, which aims to maximise the edges connecting two sets of vertices in a graph.
First, a minimisation of a function of binary variables (0 or 1 for each node) is used to explain such classical problems. A Quadratic Unconstrained Binary Optimisation (QUBO) problem can then be created from this. Pauli Z matrices are used in place of the binary variables in the QUBO formulation in order to bridge this to the quantum domain. The outcome of this transformation is a Hamiltonian for the cost function. Certain terms of this Hamiltonian, such as some linear terms being zero, may simplify for situations like Max-Cut. The optimal solution to the initial classical problem is then found by searching for this cost Hamiltonian’s lowest energy state, or ground state.
Also Read About Discrete-Time Quantum Walks (DTQW): Applications In Quantum
Ansatz Structure
The integer parameter p, also known as reps, defines the quantum circuit, or ansatz, that QAOA uses. This parameter directly affects how well the method approximates the ideal solution and establishes the depth or number of layers in the ansatz. Problem Hamiltonians and mixer Hamiltonians are layered alternately to create the QAOA ansatz.
- Problem Hamiltonian layers: These layers incorporate the specifics of the problem into the quantum state by applying phase gates that are based on the problem’s cost function.
- Mixer Hamiltonian layers: Global X rotations are commonly involved in mixer Hamiltonian layers. In order to allow the quantum circuit to investigate the varied solution space, they are intended to introduce superposition. For limited optimization situations, where the mixer aids in limiting the development of the quantum state to a feasible subspace, a bespoke mixer Hamiltonian can also be supplied.
Known as gamma and beta angles, these alternating layers are governed by conventionally optimisable parameters. To establish the initial values for these parameters during the optimisation process, an initial_point can be supplied.
Hybrid Optimization Loop
In an iterative loop, QAOA functions as a hybrid algorithm that seamlessly blends quantum and classical computation.
- Quantum Circuit Execution: A starting set of gamma and beta parameters is used to prepare and run the parameterised QAOA circuit on a quantum computer or simulator.
- Measurement and Cost Assessment: Following execution, the quantum state is subjected to measurements. An expectation value of the cost function the “cost” that must be minimized is calculated using the results.
- Classical Optimisation: This cost value is fed into a classical optimiser like COBYLA. The gamma and beta parameters are then routinely updated with the goal of lowering the cost in later iterations. Until a halting requirement is satisfied or the cost function converges, this cycle keeps going.
QAOA Qiskit Implementation and Workflow
The QAOA class is provided by IBM’s open-source quantum computing framework Qiskit and is normally located in qiskit_algorithms. Users can define the quantum circuit and do optimization using this class. The optimizer (a classical optimizer), mixer (for a custom mixer Hamiltonian), initial_state (an optional initial quantum circuit), reps (the integer p parameter for ansatz depth), and initial_point (for initial parameter values) are important factors when initializing a QAOA object.
There are multiple steps in the basic workflow for using Qiskit to solve an optimisation problem using QAOA:
Map Classical Inputs to a Quantum Problem
The first step is to map classical inputs to a quantum problem, which means that the classical problem (such a graph) must be converted into a QUBO problem, an operator cost Hamiltonian, and ansatz parameterised quantum circuit.
Also Read About What Is Quantum Parallelism, How It Works & It Principles
Optimize Problem for Quantum Hardware Execution
A procedure known as transpilation is used to optimise the abstract quantum circuit for a particular quantum processing unit (QPU). Initial qubit mapping, unrolling instructions to the native set of the hardware, routing interacting qubits, and putting error suppression strategies into practice are all steps in the transpilation process.
Use Qiskit Primitives
The iterative optimisation loop is carried out by utilising Qiskit Runtime primitives such as Sampler (which obtains probability distributions of bitstring measurements) and Estimator (which computes expectation values of the cost function). A cost function wrapper for the estimator is frequently used in conjunction with the traditional minimise function from SciPy.
Post-process and Return Result
A sampler is used to run the quantum circuit one final time with the ideal parameters after they have been determined. Following an analysis of the bitstring distribution that results, the bitstring with the highest probability or lowest cost is chosen as the original problem’s solution.
Outlook and Applications
QAOA can be applied to a number of optimization problems, such as portfolio optimization and Max-Cut. Even though noise limits the ability of contemporary quantum computers to routinely outperform classical machines in combinatorial optimization, continued algorithm development and hardware improvements hold great promise. With more powerful quantum devices, researchers are actively testing quantum heuristics like QAOA on problems of ever-increasing magnitude.
Also Raed About Quantum Interference Explained: A Wave Like Interaction