PreprintPDF Available

# Grover Binary Search for Discrete Quantum Optimization

Authors:

## 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.
GROVER BINARY SEARCH FOR DISCRETE QUANTUM
OPTIMIZATION
Ayaz Baykov, Stanislav Protasov
Innopolis University, Innopolis, Russia
{a.baykov, s.protasov}@innopolis.university
ABS TRACT
Contemporary quantum algorithms, being efﬁcient theoretically, fail to execute on real QPUs. One
reason for these failures is the algorithm’s probabilistic nature, which is ampliﬁed 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 sufﬁciently
better for a speciﬁc 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 [
1
], which
converts a factorization problem into a frequency estimation task; quantum version of discrete Fourier transform [
2
],
which instead of a straightforward “algorithmic” implementation utilizes unitary property of transformation operator.
And of course, Grover search [
3
], which instead of naïve iterations beneﬁts 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 ﬁndings
with a simpliﬁed knapsack packing problem.
2 Previous work
In this paper, we present an improvement for Grover Adaptive Search (GAS) algorithm [
4
]. 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)
where
x
is a candidate solution among
N
possible (hereinafter we use
N
to denote a problem search space cardinality),
cost
is a function to maximize, and
valid
predicate is responsible for problem constraints. E.g. in knapsack packing,
given a set A, for choosing an optimal subset:
xA,
N= 2|A|,
valid(x) = weight(x)limit
(2)
Predicate
Slow(x)
is then encoded as a quantum oracle. It is used inside Grover search algorithm, which solves the
problem of satisﬁability of
Slow(x)
. If there exists
x
satisfying
Slow(x)
,
cost(x)
value is used to update
low
boundary
until convergence. Let us deﬁne the cost
sol
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)
times.
In section 3 we show, how to improve worst case complexity estimation to
O(log( ˜
sol low))
. Here
˜
sol
means the
solution estimation from above. In the discussion section we show the cases where this improvement is practically
important.
3 Methodology
We call our optimization method Grover Binary Search (GBS). The method relies on binary search algorithms, which
for
k
sorted objects guarantees
O(log k)
complexity on CPU. It also has a quantum implementation [
5
] 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
count(Slow(x))
. The function must return the number of solutions satisfying the oracle. This function is non-increasing
for variable
low
, thus it can be used in binary search. It can be implemented with quantum counting method [
6
], which
is just an application of Quantum Phase Estimation [
7
]. Unfortunately, this method requires doubled number of qubits,
O(log(N))
runs of controlled Grover iteration, plus
QF T
[
2
] (which uses order of
2 log N
gates). Also, this method
To overcome these complications we propose to replace the non-decreasing
count
with another non-decreasing function:
anylow(x)def
=count(Slow(x)) >0.(3)
In our method, we search for the smallest
low
, for which solutions count is 0:
argmin
low
[count(Slow(x)) = 0]
. For this
condition both functions
count
and
any
return the same answer. To implement function
any
search procedure for unknown number of answers, which requires
O(log N)
non-controlled Grover iterations. Any
Grover search answer x, which satisﬁes Slow(x), means anylow (x) = T rue.
Altogether, our method in the worst case will run
O(log2(˜
sol low))
(better than is GAS) iterations of binary search,
each of which will run
O(log(N))
Grover iterations (same as in GAS). Pseudocode of our method is shown in listing 1.
2
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← ∅;
do
i1;
while i2<|P|do
m=low+high
2;
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);
Rx;
i1;
else
ii2;
end
end
high m;
while high low > 1;
return R;
4 Implementation and analysis
We test our solution on a simpliﬁed 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 simpliﬁed knapsack, our oracle should
implement the condition:
Slow(x) = {low < X
itemx
cost(item)limit}.(4)
Note that in a classical 0/1 knapsack packing, the oracle should check
Pitemxweight(item)limit
implementation we avoid this by setting cost =weight.
We do our implementation and tests using IBM’s Qiskit framework v0.31.0 [
8
], running on Windows. We use the basic
probabilistic noiseless BasicAer simulator. We do not consider noise and concentrate on probabilistic effects only.
3
Circuit 1 represents an oracle implementation. We use controlled QFT adders [
9
] to implement the sum of weights.
CN OT
, controlled by a data sign qubit, are used for inequalities. This technique
was described in chapter 5 of the book [
10
].
Uncomputing
is a block of inverse adders to bring
data
and
key
qubits to
+1
to lower bound to replace strict inequality
low < cost
with non-strict
0cost (low + 1)
,
and
+1
to upper bound to convert
cost limit
into
cost (limit + 1) <0
. To avoid unnecessary manipulations, the
limit is encoded as low + (limit low) = 5 + 2.
Figure 1: Example oracle implementation for
S5(x)
condition:
5+1cost(x)<(5 + 2) + 1
operations implement
cost(x)
function (costs of knapsack candidates), while uncontrolled addition set inequality
boundaries.
We run simulator experiment to check the validity of our implementations. Available items are
{6,3,5,4}
,
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.
0101
correspond to {3, 4} knapsack, while
1000
is
{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
4
Figure 3: Comparison or Grover Adaptive Search (GAS) and proposed method (GBS). Number of QPU circuit launches.
range. Knapsack limit is uniformly chosen from
[Pitems
4,Pitems]
integer range. We run 32 random experiments for
each problem size. According to the proposed algorithm 1, for
low
estimation
Greedy1
algorithm takes a sum of ﬁrst
elements which it does not exceed the
limit
, while
Greedy2
for upper bound
high
takes the
limit
value. Among the
values which differ between the methods, we measure number of times QPU circuit is launched, and the correctness of
We present our results of QPU launches in ﬁgure 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 [
11
]. Code proﬁling 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 ﬁgure 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 justiﬁcation of worse
gate expenditure. We showed that for a random problem generation with no speciﬁc 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 ﬁrst iteration. If constraints on the problem are loose
(in our example
low
estimation is unsatisfactory), Grover search algorithm behaves extremely bad, as it ampliﬁes the
5
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 ﬁndings 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.
6
References
[1]
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.
[3]
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.
[4]
Austin Gilliam, Stefan Woerner, and Constantin Gonciulea. Grover adaptive search for constrained polynomial
binary optimization. Quantum, 5:428, 2021.
[5]
Andrew M. Childs, Andrew J. Landahl, and Pablo A. Parrilo. Quantum algorithms for the ordered search problem
via semideﬁnite programming. Phys. Rev. A, 75:032335, Mar 2007.
[6]
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.
[10]
Eric R Johnston, Nic Harrigan, and Mercedes Gimeno-Segovia. Programming Quantum Computers: essential
algorithms and code samples. O’Reilly Media, 2019.
[11]
public/ionq.
7
... 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]. ...
Preprint
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.
Article
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.
Article
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.
Article
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.
Article
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