Path: blob/main/hybrid-workflows/01_quantum_enhanced_optimization_LABS.ipynb
1128 views
Quantum Enhanced Optimization for Radar and Communications Applications
The Low Autocorrelation Binary Sequences (LABS) is an important and challenging optimization problem with applications related to radar, telecommunications, and other signal related applications. This CUDA-Q Academic module will focus on a clever quantum-enhanced hybrid method developed in a collaboration between Kipu Quantum, University of the Basque Country EHU, and NVIDIA for solving the LABS problem.
Other CUDA-Q Academic modules like Divide and Conquer MaxCut QAOA and Quantum Finance, demonstrate how quantum computing can be used outright to solve optimization problems. This notebook demonstrates a slightly different approach. Rather than considering QPUs as the tool to produce the final answer, it demonstrates how quantum can be used to enhance the effectiveness of leading classical methods.
The benefits of such an approach were highlighted in Scaling advantage with quantum-enhanced memetic tabu search for LABS. This notebook, co-created with the authors of the paper, will allow you to explore the findings of their research and write your own CUDA-Q code that builds a representative quantum-enhanced workflow for solving the LABS problem. Moreover, it will introduce advancements in counteradiabatic optimization techniques on which reduce the quantum resources required to run on a QPU.
Prerequisites: This lab assumes you have a basic knowledge of quantum computing, including operators, gates, etc. For a refresher on some of these topics, explore the Quick start to Quantum series.
In this lab you will:
Understand the LABS problem and its relation ot radar and communication applications.
Solve LABS classically with memetic tabu search and learn about the limitations of such methods.
Code a couteradiabatic algorithm using CUDA-Q to produce approximate solutions to the LABS problem.
Use the CUDA-Q results to seed your tabu search and understand the potential benefits of this approach.
Terminology you will use:
Low autocorrelation of binary sequences (LABS)
counteradiabatic optimization
memetic-tabu search
CUDA-Q Syntax you will use:
cudaq.sample()
@cudaq.kernel
ry(), rx(), rz(), x(), h()
x.ctrl()
The LABS problem and applications
The Low Autocorrelation Binary Sequences (LABS) problem is fundamental to many applications, but originated with applications to radar.
Consider a radar that monitors airport traffic. The radar signal sent to detect incoming planes must have as much range as possible to ensure safe approaches are planned well in advance. The range of a radar signal can be increased by sending a longer pulse. However, in order to differentiate between multiple objects, pulses need to be short to provide high resolution. So, how do you handle situations where you need both?
One solution is a technique called pulse compression. The idea is to send a long signal, but vary the phase at regular intervals such that the resolution is increased. Generally, the initial signal will encode a binary sequence of phase shifts, where each interval corresponds to a signal with a 0 or 180 degree phase shift.
The tricky part is selecting an optimal encoding sequence. When the signal returns, it is fed into a matched filter with the hope that a singular sharp peak will appear, indicating clear detection. The autocorrelation of the original signal, or how similar the signal is to itself, determines if a single peak or a messier signal with sidelobes will be detected. A signal should have high autocorrelation when overlayed on top of itself, but low autocorrelation when shifted with a lag.
Consider the image below. The signal on the left has a crisp single peak while the single on the right produces many undesirable sidelobes which can inhibit clear detection.

So, how do you select a good signal? This is where LABS comes in, defining these questions as a binary optimization problem. Given a binary sequence of length , , the goal is to minimize the following objective function.
Where is defined as.
So, each computes how similar the original signal is to the shifted one for each offset value . To explore this more, try the interactive widget linked here. See if you can select a very good and very poor sequence and see the difference for the case of .
Classical Solution of the LABS problem
The LABS problem is tricky to solve for a few reasons. First, the configuration space grows exponentially. Second, underlying symmetries of the problem result in many degeneracies in the optimization landscape severely inhibiting local search methods.
Exercise 1:
Using the widget above, try to find some of the symmetries for the LABS problem. That is, for a fixed bitstring length, can you find patterns to produce the same energy with different pulse patterns.
The best known performance for a classical optimization technique is Memetic Tabu search (MTS) which exhibits a scaling of . The MTS algorithm is depicted below. It begins with a randomly selected population of bitstrings and finds the best solution from them. Then, a child is selected by sampling directly from or combining multiple bitstrings from the population. The child is mutated with probability and then input to a tabu search, which performs a modified greedy local search starting from the child bitstring. If the result is better than the best in the population, it is updated as the new leader and randomly replaces a bitstring in the population.

Such an approach is fast, parallelizable, and allows for exploration with improved searching of the solution landscape.
Exercise 2:
Before exploring any quantum approach, get a sense for how MTS works by coding it yourself based on the figure above. Complete the TODO's below. Note that two functions are provided for you. `labs_utils` will perform the tabu search given a provided bitstring. `labs_plotting` will plot the energies of your final population and will optionally take as second data set when we later compare to a quantum enhanced result. The image below also defines the combine and mutate procedures you will need from the paper.

Building a Quantum Enhanced Workflow
Despite the effectiveness of MTS, it still exhibits exponential scaling behavior and becomes intractable for large . Quantum computing provides a potential alternative method for solving the LABS problem because the properties of entanglement, interference, and superpositon may allow for a better global search. Recent demonstrations have even produced evidence that the quantum approximate optimization algorithm (QAOA) can be used to reduce the scaling of the LABS problem to for between 28 and 40 with quantum minimum finding.
However, current quantum hardware limitations restrict solution to problems of greater than about , meaning that it will be some time before quantum approaches can outperform the classical state of the art. It should also be noted that standard QAOA can struggle with LABS and require many layers to converge the parameters if other tricks are not employed.
The authors of Scaling advantage with quantum-enhanced memetic tabu search for LABS cleverly explored an alternate path that combines quantum and classical approaches and might be able to provide a more near-term benefit. Instead of expecting the quantum computer to solve the problem entirely, they asked how a quantum approach might enhance MTS.
The basic idea is that a quantum optimization routine could run first and the resulting state be sampled to produce a better population for MTS. Many such heuristics for defining the initial population are possible, but the rest of this notebook will explore their methodology, help you to build the workflow yourself, and allow you to analyze the benefits of their approach.
The first step of quantum enhanced MTS (QE-MTS) is to prepare a circuit with CUDA-Q that approximates the ground state of the Hamiltonian corresponding to the LABS problem. You could do this with any optimization algorithm such as QAOA or using an adiabatic approach. (See the Quantum Portfolio Optimization CUDA-Q Academic lab for a detailed comparison of these two common approaches.)
The authors of this work opted for an adiabatic approach (More on why later). Recall that the goal of an adiabatic optimization is to begin with a Hamiltonian that has an easily prepared ground state (). Then, the adiabatic Hamiltonian can be constructed as , where is a function of time and is the Hamiltonian representing a qubit encoding of the LABS problem.
The authors also selected which has an easily prepared ground state of .
The challenge for implementing the optimization procedure becomes selection of an operator that will quickly and accurately evolve to the ground state of . One approach is to use a so-called auxiliary countradiabatic (CD) term , which corrects diabatic transitions that jump out of the ground state during the evolution. The figure below demonstrates the benefit of using a CD correction.

An operator called the adiabatic gauge potential is the ideal choice for the CD term as it suppresses all possible diabatic transitions, resulting in the following total system to evolve.
is derrived from (see paper for details) as it contains information about underlying physics of the problem.
There is a problem though. The term cannot be efficiently expressed exactly and needs to be approximated. It also turns out that in the so called impulse regime, where the adiabatic evolution is very fast, dominates , meaning that the final implementation corresponds to the operator where is a first order approximation of (see equation 7 in the paper).
A final step is to use Trotterization to define the quantum circuit to apply . The details for this derivation are shown in the appendix of the paper. and result from equation B3 is shown below.
It turns out that this implementation is more efficient than QAOA in terms of gate count. The authors calculated that for , QAOA would require 1.4 million entangling gates while the CD approach derived here requires only 236 thousand entangling gates.
Exercise 3:
At first glance, this equation might looks quite complicated. However, observe the structure and note two "blocks" of terms. Can you spot them?
They are 2 qubit terms that look like or .
As well as 4 qubit terms that look like , , , or .
Thankfully the authors derive a pair of circuit implementations for the two and four qubit terms respectively, shown in the figures below.
Using CUDA-Q, write a kernel for each which will be used later to construct the full implementation.
Hint: Remember that the adjoint of a rotation gate is the same as rotating in the opposite direction.
Hint: You may also want to define a CUDA-Q kernel for an R gate.
Hint: Implementing a circuit from a paper is a great place where AI can help accelerate your work. If you have access to a coding assistant, feel free to use it here.

There are a few additional items we need to consider before completing the final implementation of the entire circuit. One simplification we can make is that for our problem the terms are all 1 and any terms are 0, and are only there for generalizations of this model.
The remaining challenge is derivation of the angles that are used to apply each of the circuits you defined above. These are obtained from two terms and .
The defines an annealing schedule and is generally a Sin function which slowly "turns on" the problem Hamiltonian. For computing our angles, we need the derivative of .
The term is a bit trickier and is the solution to a set of differential equations which minimize the distance between and . The result is
Where and are defined in equations 16 and 17 of the paper and essentially depend on the structure of the optimization problem. Curious learners can look at the functions in labs_utils.py to see how these are computed, based on the problem size and specific time step in the Trotter process.
Exercise 4:
The `compute_theta` function below requires all indices of the two and four body terms. These will be used again in our main kernel to apply the respective gates. Use the products in the formula below to finish the function in the cell below. Save them as `G2` and `G4` where each is a list of list of indices defining the two and four term interactions. As you are translating an equation to a set of loops, this is a great opportunity to use an AI coding assistant.
Exercise 5:
You are now ready to construct the entire circuit and run the counteradiabatic optimization procedure. The final kernel needs to apply Equation 15 for a specified total evolution time and the `n_steps` number of Trotter steps. It must also take as input, the indices for the two and four body terms and the thetas to be applied each step, as these cannot be computed within a CUDA-Q kernel.
Use cudaq.sample to extract the samples we want. You will need to post-process these to the appropriate format for input to the MTS population.
Generating Quantum Enhanced Results
Recall that the point of this lab is to demonstrate the potential benefits of running a quantum subroutine as a preprocessing step for classical optimization of a challenging problem like LABS. you now have all of the tools you need to try this for yourself.
Exercise 6:
Use your CUDA-Q code to prepare an initial population for your memetic search algorithm and see if you can improve the results relative to a random initial population. If you have a GPU available, try to run a larger problem size of at least . Feel free to explore other problem sizes too. You can still run the cell below with a CPU, but change the sequence length to something small like .
The results clearly show that a population sampled from CUDA-Q results in an improved distribution and a lower energy final result. This is exactly the goal of quantum enhanced optimization. To not necessarily solve the problem, but improve the effectiveness of state-of-the-art classical approaches.
A few major caveats need to be mentioned here. First, We are comparing a quantum generated population to a random sample. It is quite likely that other classical or quantum heuristics could be used to produce an initial population that might even beat the counteradiabatic method you used, so we cannot make any claims that this is the best.
Recall that the point of the counteradiabatic approach derived in the paper is that it is more efficient in terms of two-qubit gates relative to QAOA. The benefits of this regime would only truly come into play in a setting (e.g. larger problem instance) where it is too difficult to produce a good initial population with any know classical heuristic, and the counteradiabatic approach is more efficiently run on a QPU compared to alternatives.
We should also note that we are comparing a single sample of each approach. Maybe the quantum sample got lucky or the randomly generated population was unlucky and a more rigorous comparison would need to repeat the analysis many times to draw any confidently conclusions.
The authors of the paper discuss all of these considerations, but propose an analysis that is quite interesting related to the scaling of the technique. Rather than run large simulations ourselves, examine their results below.

The authors computed replicate median (median of solving the problem repeated with same setup) time to solutions (excluding time to sample from QPU) for problem sizes to . Two interesting conclusions can be drawn from this. First, standard memetic tabu search (MTS) is generally faster than quantum enhanced (QE) MTS. But there are two promising trends. For larger problems, the QE-MTS experiments occasionally have excellent performance with times to solution much smaller than all of the MTS data points. These outliers indicate there are certain instances where QE-MTS could provide much faster time-to-solution.
More importantly, if a line of best fit is calculated using the median of each set of medians, the slope of the QE-MTS line is smaller than the MTS! This seems to indicate that QE solution of this problem scales which is better than the best known classical heuristic () and the best known quantum approach (QAOA - ).
For problems of size of or greater, the authors anticipate that QE-MTS could be a promising technique and produce good initial populations that are difficult to obtain classically.
The study reinforces the potential of hybrid workflows enhanced by quantum data such that a classical routine is still the primary solver, but quantum computers make it much more effective. Future work can explore improvements to both the quantum and classical sides, such as including GPU accelerated memetic search on the classical side.