PreprintPDF Available

Grover Binary Search for Discrete Quantum Optimization


Abstract and Figures

Contemporary quantum algorithms, being efficient theoretically, fail to execute on real QPUs. One reason for these failures is the algorithm's probabilistic nature, which is amplified by hardware implementation imperfections. Grover search is such a probabilistic method, which enables other methods in quantum optimization and machine learning. In this work we improve the theoretical worst case complexity of Grover Adaptive Search by replacing iterations with binary search. We observe in the experiments that our method shows better success rate in general, and is sufficiently better for a specific type of optimization landscapes with plateaus.
Content may be subject to copyright.
Ayaz Baykov, Stanislav Protasov
Innopolis University, Innopolis, Russia
{a.baykov, s.protasov}
Contemporary quantum algorithms, being efficient theoretically, fail to execute on real QPUs. One
reason for these failures is the algorithm’s probabilistic nature, which is amplified by hardware
implementation imperfections. Grover search is such a probabilistic method, which enables other
methods in quantum optimization and machine learning. In this work we improve the theoretical
worst case complexity of Grover Adaptive Search by replacing iterations with binary search. We
observe in the experiments that our method shows better success rate in general, and is sufficiently
better for a specific type of optimization landscapes with plateaus.
Keywords Grover search ·quantum computing ·quantum optimization ·knapsack problem
1 Introduction
Solving optimization problems is one of the most promising areas of quantum computing applications. Typically, we
restate a well-known NP-hard discrete optimization problem using completely different mathematics. This trick allows to
make use of operations, which are proven to be faster when run on a QPU. Such methods are Shor’s algorithm [
], which
converts a factorization problem into a frequency estimation task; quantum version of discrete Fourier transform [
which instead of a straightforward “algorithmic” implementation utilizes unitary property of transformation operator.
And of course, Grover search [
], which instead of naïve iterations benefits from parallel predicate execution for the
argument superposition. Grover’s algorithm, as well as Shor’s algorithm, is not just an algorithm. This is a framework,
which requires a quantum oracle implementation. It can be used for solving multiple problems, if they provide a proper
oracle. Here we concentrate on the application of Grover search to discrete optimization, and we illustrate our findings
with a simplified knapsack packing problem.
2 Previous work
In this paper, we present an improvement for Grover Adaptive Search (GAS) algorithm [
]. Original algorithm
is an iterative hybrid (utilizing both CPU and QPU computations) general-purpose framework for solving discrete
optimization problems. This framework supposes we can convert a problem statement into the following conditions:
Slow(x) = {low < cost(x)} ∧ valid(x)(1)
is a candidate solution among
possible (hereinafter we use
to denote a problem search space cardinality),
is a function to maximize, and
predicate is responsible for problem constraints. E.g. in knapsack packing,
given a set A, for choosing an optimal subset:
N= 2|A|,
valid(x) = weight(x)limit
is then encoded as a quantum oracle. It is used inside Grover search algorithm, which solves the
problem of satisfiability of
. If there exists
value is used to update
until convergence. Let us define the cost
of the unknown optimal solution. In the worst case, lower bound improves
by the constant each iteration, thus the classical (CPU) part of the method will trigger QPU method
O(sol low)
In section 3 we show, how to improve worst case complexity estimation to
O(log( ˜
sol low))
. Here
means the
solution estimation from above. In the discussion section we show the cases where this improvement is practically
3 Methodology
We call our optimization method Grover Binary Search (GBS). The method relies on binary search algorithms, which
sorted objects guarantees
O(log k)
complexity on CPU. It also has a quantum implementation [
] with the same
complexity estimation. Here we propose to use this algorithm instead on iterative search proposed in the original paper.
If we explicitly reproduce the original idea and replace GAS iteration with binary search, we can use a function
. The function must return the number of solutions satisfying the oracle. This function is non-increasing
for variable
, thus it can be used in binary search. It can be implemented with quantum counting method [
], which
is just an application of Quantum Phase Estimation [
]. Unfortunately, this method requires doubled number of qubits,
runs of controlled Grover iteration, plus
] (which uses order of
2 log N
gates). Also, this method
provides an approximation of count value, instead of exact answers.
To overcome these complications we propose to replace the non-decreasing
with another non-decreasing function:
=count(Slow(x)) >0.(3)
In our method, we search for the smallest
, for which solutions count is 0:
[count(Slow(x)) = 0]
. For this
condition both functions
return the same answer. To implement function
we follow standard Grover
search procedure for unknown number of answers, which requires
O(log N)
non-controlled Grover iterations. Any
Grover search answer x, which satisfies Slow(x), means anylow (x) = T rue.
Altogether, our method in the worst case will run
sol low))
(better than is GAS) iterations of binary search,
each of which will run
Grover iterations (same as in GAS). Pseudocode of our method is shown in listing 1.
Algorithm 1: Binary Grover search for optimization problem
Input: P– problem search space
Result: R– solution
low Greedy1(P);
high Greedy2(P); // here we greedily estimate maximum cost(x)
R← ∅;
while i2<|P|do
xGroverSearchi(P, m);// run iGrover iterations to find xP
// in case of knapsack, valid(x) = weight(x)limit
if valid(x)and cost(x)> m then
low cost(x);
high m;
while high low > 1;
return R;
4 Implementation and analysis
We test our solution on a simplified knapsack packing problem: we assign cost equal to weight for the sake of a simpler
input and circuit. This allows to run simulator tests for a bigger search space, while keeping the problem exponentially
hard. In a classical 0/1 problem statement, we would need an additional quantum register for weights, limiting our
simulation opportunities.
In section 1 we mentioned, that Grover search is a generic framework, thus it requires additional implementations.
First, we need to implement a quantum oracle for the problem. In the case of simplified knapsack, our oracle should
implement the condition:
Slow(x) = {low < X
Note that in a classical 0/1 knapsack packing, the oracle should check
instead. In our
implementation we avoid this by setting cost =weight.
We do our implementation and tests using IBM’s Qiskit framework v0.31.0 [
], running on Windows. We use the basic
probabilistic noiseless BasicAer simulator. We do not consider noise and concentrate on probabilistic effects only.
Circuit 1 represents an oracle implementation. We use controlled QFT adders [
] to implement the sum of weights.
Uncontrolled adders together with
, controlled by a data sign qubit, are used for inequalities. This technique
was described in chapter 5 of the book [
is a block of inverse adders to bring
qubits to
the initial state. We add
to lower bound to replace strict inequality
low < cost
with non-strict
0cost (low + 1)
to upper bound to convert
cost limit
cost (limit + 1) <0
. To avoid unnecessary manipulations, the
limit is encoded as low + (limit low) = 5 + 2.
Figure 1: Example oracle implementation for
5+1cost(x)<(5 + 2) + 1
. Controlled addition
operations implement
function (costs of knapsack candidates), while uncontrolled addition set inequality
We run simulator experiment to check the validity of our implementations. Available items are
low = 5
and limit = 7. Thus, solution set is {{3,4},{6}}. In the plot 2 we observe two peaks where they should be.
Figure 2: Results of Grover search algorithm for a prepared oracle.
correspond to {3, 4} knapsack, while
{6} candidate. Both options satisfy oracle conditions.
The main experiment is planned as follows. We test GAS and our GBS methods on random sets with 4..11 items
(which is equivalent to 16..2048 problem search space). Each item’s weight is uniformly sampled from 1..63 integer
Figure 3: Comparison or Grover Adaptive Search (GAS) and proposed method (GBS). Number of QPU circuit launches.
range. Knapsack limit is uniformly chosen from
integer range. We run 32 random experiments for
each problem size. According to the proposed algorithm 1, for
algorithm takes a sum of first
elements which it does not exceed the
, while
for upper bound
takes the
value. Among the
values which differ between the methods, we measure number of times QPU circuit is launched, and the correctness of
given answers.
We present our results of QPU launches in figure 3. We observe two major patterns. First, the median number of
launches for both methods does not grow with the size of the problem. This is a projection of theoretical prediction, that
number of iterations is expected logarithm for GAS and guaranteed logarithmic for GBS, with respect to the upper limit.
In our experiment maximum limit grows linearly with the number of items, and thus logarithmically for problem search
space size. This means here we observe
log log N
tendency, which grows very slow to catch. Second observation is
that GBS launches twice as many quantum circuits. This pattern holds for oracle launch counts as well – this metric is
proportional to the number of utilized quantum gates. This value is essential in practice, while e.g., IonQ QPU pricing
schema is per gate execution [
]. Code profiling showed that our method can spend a lot of launches to prove that
there is no item in the range.
Proposed GBS method inherits the deterministic bisection method, thus incorrect Grover Search is the only source of
mistakes in the result. At the same time non-deterministic convergence procedure of GAS can be an additional source
of mistakes. We observed, that our method has a systematically higher success rate on experimental data (see figure 4).
We think this observation supports deterministic approach.
5 Discussion
We want to highlight, that our experiments are neither a proof of supremacy in precision, nor a justification of worse
gate expenditure. We showed that for a random problem generation with no specific tuning, our method achieves correct
solution with a high probability, and shows expected asymptotic complexity characteristics.
Nevertheless, we want to share two observations derived from experiments. First, both GAS and proposed GBS
methods strongly depend on the lower bound estimation at the first iteration. If constraints on the problem are loose
(in our example
estimation is unsatisfactory), Grover search algorithm behaves extremely bad, as it amplifies the
Figure 4: Success rate of GAS and proposed (GBS) algorithms.
probabilities of incorrect solutions instead. In cases when the number of valid solutions is close to the half of the search
space, Grover search is equivalent to random sampling from the search space. Only a good estimation of a lower bound
can kickstart a method, which uses Grover search inside.
Second, GAS and GBS, probably, best suit different problems. Imagine a problem search space with a plateau of
multiple similar costs and a single optimal solution above the plateu. Iterative method can easily get stuck in this
plateau, doing minor improvements at each iteration, while binary search proceeds if it sees any solution “ahead”, with
higher costs. To support the observation, we composed a synthetic example, which has a very low chance to succeed
with GAS, but works great for GBS: [21, 19, 1, 1, 1, 1, 1, 1, 17] with the limit of 38. We run 50 experiments for each
method, and GBS found correct answer in 66% of launches, while GAS could succeed in only 22% of cases. We
recommend for practical problems use both GAS and GBS methods if the cost function behavior is unknown.
6 Conclusion
In this paper, we present a novel optimization Grover Binary Search method, which combines a brilliant idea of Grover
Adaptive Search with deterministic nature of binary search. New method appears to be asymptotically better, but in
practice it consumes more quantum gates, which is essential in NISQ era. Still, in simulations our method showed
systematically better success rate. Moreover, we could dedicate a separate subset of optimization cost landscapes, which
suit much better for GBS method. We support our findings with the experiment, where with GBS we could achieve
66% of success rate, compared to 22% for GAS.
Additionally, while today’s QPU access is mostly cloud base, we think that it is perspective to design fully-quantum
methods to avoid multiple data encoding-decoding. Binary search has a quantum version, thus it is potentially possible
to build a quantum-only implementation of GBS. This method will be qubit-hungry, but it can be still preferred to
multiple CPU-QPU communication cycles.
Peter W Shor. Algorithms for quantum computation: discrete logarithms and factoring. In Proceedings 35th
annual symposium on foundations of computer science, pages 124–134. Ieee, 1994.
[2] D. Coppersmith. An approximate fourier transform useful in quantum factoring, 2002.
Lov K Grover. A fast quantum mechanical algorithm for database search. In Proceedings of the twenty-eighth
annual ACM symposium on Theory of computing, pages 212–219, 1996.
Austin Gilliam, Stefan Woerner, and Constantin Gonciulea. Grover adaptive search for constrained polynomial
binary optimization. Quantum, 5:428, 2021.
Andrew M. Childs, Andrew J. Landahl, and Pablo A. Parrilo. Quantum algorithms for the ordered search problem
via semidefinite programming. Phys. Rev. A, 75:032335, Mar 2007.
Gilles Brassard, Peter Høyer, and Alain Tapp. Quantum counting. In Kim G. Larsen, Sven Skyum, and Glynn
Winskel, editors, Automata, Languages and Programming, pages 820–831, Berlin, Heidelberg, 1998. Springer
Berlin Heidelberg.
[7] A. Yu. Kitaev. Quantum measurements and the abelian stabilizer problem, 1995.
[8] MD SAJID ANIS et al. Qiskit: An open-source framework for quantum computing, 2021.
[9] Thomas G Draper. Addition on a quantum computer. arXiv preprint quant-ph/0008033, 2000.
Eric R Johnston, Nic Harrigan, and Mercedes Gimeno-Segovia. Programming Quantum Computers: essential
algorithms and code samples. O’Reilly Media, 2019.
IonQ. Google cloud platform: Ionq quantum cloud.
... Despite new developments such as those in Refs. [19,20], GAS remains unmatched in its quadratic speedup for combinatorial optimization [10]. ...
... In total, Eqs. (15), (20), and (21) allow us to simplify quantum dueling to the most contracted form. In Grover algorithm, such a strategy leads to only 2 clusters, allowing us to solve the state vector after an arbitrary number of iterations [4]. ...
Full-text available
Quantum optimization algorithms have long garnered significant attention due to their potential to solve combinatorial optimization problems more efficiently than classical algorithms. Building upon established designs such as Grover adaptive search (GAS) and quantum approximate optimization algorithm (QAOA), in this paper we present a new strategy for quantum combinatorial optimization, which we term quantum dueling. In addition to the register used in other quantum optimization algorithms, we introduce a second register, boosting the Hilbert space. In this space, quantum optimization is simplified to quantum amplitude amplification. We extensively use experimental evidence for a wide range of data to test the ability of quantum dueling under different parameters. Our result suggests that quantum dueling performs well for naive parameters, though such performance is highly dependent on solution distribution. In this case, the evolution of the success probability is highly regular. Thus, there might be ways to approximate the state evolution mathematically. In this paper, we are able to simplify the formulation of quantum computing rather than finding a quantitative solution. However, if quantum dueling can be solved, there will be a systematic approach to locate optimal parameters. In this case, data suggest that quantum dueling seems to reach $O(\sqrt{N})$ and performs well for almost all solution distributions. In retrospect, quantum dueling shares similarities with many variational optimization algorithms, most notably QAOA. This suggests that the strategy of quantum dueling might be transplanted into a Hamiltonian setup. With more research, we might obtain more candidates for quantum optimization.
Full-text available
In this paper we discuss Grover Adaptive Search (GAS) for Constrained Polynomial Binary Optimization (CPBO) problems, and in particular, Quadratic Unconstrained Binary Optimization (QUBO) problems, as a special case. GAS can provide a quadratic speed-up for combinatorial optimization problems compared to brute force search. However, this requires the development of efficient oracles to represent problems and flag states that satisfy certain search criteria. In general, this can be achieved using quantum arithmetic, however, this is expensive in terms of Toffoli gates as well as required ancilla qubits, which can be prohibitive in the near-term. Within this work, we develop a way to construct efficient oracles to solve CPBO problems using GAS algorithms. We demonstrate this approach and the potential speed-up for the portfolio optimization problem, i.e. a QUBO, using simulation and experimental results obtained on real quantum hardware. However, our approach applies to higher-degree polynomial objective functions as well as constrained optimization problems.
We present a polynomial quantum algorithm for the Abelian stabilizer problem which includes both factoring and the discrete logarithm. Thus we extend famous Shor's results [7]. Our method is based on a procedure for measuring an eigenvalue of a unitary operator. Another application of this procedure is a polynomial quantum Fourier transform algorithm for an arbitrary finite Abelian group. The paper also contains a rather detailed introduction to the theory of quantum computation.
One of the most basic computational problems is the task of finding a desired item in an ordered list of N items. While the best classical algorithm for this problem uses log_2 N queries to the list, a quantum computer can solve the problem using a constant factor fewer queries. However, the precise value of this constant is unknown. By characterizing a class of quantum query algorithms for ordered search in terms of a semidefinite program, we find new quantum algorithms for small instances of the ordered search problem. Extending these algorithms to arbitrarily large instances using recursion, we show that there is an exact quantum ordered search algorithm using 4 log_{605} N \approx 0.433 log_2 N queries, which improves upon the previously best known exact algorithm.
We define an approximate version of the Fourier transform on $2^L$ elements, which is computationally attractive in a certain setting, and which may find application to the problem of factoring integers with a quantum computer as is currently under investigation by Peter Shor. (1994 IBM Internal Report)
A fast quantum mechanical algorithm for database search
  • K Lov
  • Grover
Lov K Grover. A fast quantum mechanical algorithm for database search. In Proceedings of the twenty-eighth annual ACM symposium on Theory of computing, pages 212-219, 1996.
Qiskit: An open-source framework for quantum computing
  • Md Sajid Anis
MD SAJID ANIS et al. Qiskit: An open-source framework for quantum computing, 2021.
Programming Quantum Computers: essential algorithms and code samples
  • Nic Eric R Johnston
  • Mercedes Harrigan
  • Gimeno-Segovia
Eric R Johnston, Nic Harrigan, and Mercedes Gimeno-Segovia. Programming Quantum Computers: essential algorithms and code samples. O'Reilly Media, 2019.
Google cloud platform: Ionq quantum cloud
  • Ionq
IonQ. Google cloud platform: Ionq quantum cloud.