Accelerating the training of single-layer binary
neural networks using the HHL quantum algorithm
Sonia Lopez Alarcon, Cory Merkel, Martin Hoffnagle, Sabrina Ly
Department of Computer Engineering
Rochester Institute of Technology
Rochester NY, USA
{slaeec, cemeec, mah5414, sjl2178}[rit.edu
Alejandro Pozas-Kerstjens
Institute of Mathematical Sciences
(CSIC-UCM-UC3M-UAM)
Madrid, Spain
physics[alexpozas.com
Abstract—Binary Neural Networks are a promising technique
for implementing efficient deep models with reduced storage and
computational requirements. The training of these is however,
still a compute-intensive problem that grows drastically with the
layer size and data input. At the core of this calculation is the
linear regression problem. The Harrow-Hassidim-Lloyd (HHL)
quantum algorithm has gained relevance thanks to its promise
of providing a quantum state containing the solution of a linear
system of equations. The solution is encoded in superposition at
the output of a quantum circuit. Although this seems to provide
the answer to the linear regression problem for the training
neural networks, it also comes with multiple, difficult-to-avoid
hurdles. This paper shows, however, that useful information can
be extracted from the quantum-mechanical implementation of
HHL, and used to reduce the complexity of finding the solution
on the classical side.
Index Terms—Quantum Computing, Binary Neural Networks,
Quantum Machine learning
I. INTRODUCTION AND MOTIVATION
Machine Learning and in particular deep learning and
neural networks, are almost ubiquitous in today’s world, from
finances to healthcare. The growth of data and the size of the
models, however, place increasing pressure on the computa-
tional resources that support them, and they constantly fall
short of growing expectations and demands.
Although still in very early stages, Quantum Computing
holds some promises of mitigating this issue, even if as
a hybrid model that will partially solve the problem when
combined with classical approaches. Current trends in this
direction include the Quantum Approximate Optimization
Algorithm, QAOA [1]. An optimization problem is at the
core of any neural network training process, with the goal
of finding the weights to be assigned to the nodes of the
network. QAOA attempts to solve this optimization problem
by combining implementing a paramatrizable quantum circuit
for which parameters are adjusted to find the solution within
a predefined cost function. It is possible to implement this
This work is partially supported by the Spanish Ministry of Science and
Innovation MCIN/AEI/ 10.13039/501100011033 (“Severo Ochoa Programme
for Centres of Excellence in R&D” CEX2019-000904-S and grant PID2020-
113523GB-I00), the Spanish Ministry of Economic Affairs and Digital Trans-
formation (project QUANTUM ENIA, as part of the Recovery, Transformation
and Resilience Plan, funded by EU program NextGenerationEU), Comunidad
de Madrid (QUITEMAD-CM P2018/TCS-4342), and the CSIC Quantum
Technologies Platform PTI-001.
approach within the Noisy, Intermediate-Scale Quantum com-
puting era [2], which unfortunately only provides approximate
solutions for, at the moment, very small models. However,
the fact that current quantum computing devices are physical
systems subject to noise can also be exploited for aiding the
training of classical machine learning models [3].
On the other hand, the optimization problem associated with
the training of single-layer neural networks can be approx-
imated as a linear regression problem. The HHL quantum
algorithm [4, 5] was proposed as a potential solution linear
systems of equations. However, plainly using HHL to solve
the training of NN is unfeasible due to a number of reasons
[6], even if the technology progresses to provide sufficient
resources and low noise levels.
One of the hurdles is that HHL provides, at the output of the
quantum circuit, a quantum state that encodes the solution of
the linear system of equations in superposition. Extracting the
value of each of the components of the solution vector requires
in the best case scenario —i.e., the solution being in the +R
field— to perform many measurements in the computational
basis, which allegedly ruins the potential quantum advantage.
The number of measurements required (computed as the
number of runs of the protocol times the number of qubits
measured at each run) to accurately extract the amplitudes
of a superposition state with coefficients in +Ris generally
assumed to be in the order of n, where nis the dimension of
quantum system, or in the particular case of neural network
training, the number of weights. This, however, depends on the
accuracy that is expected of the solution, and the shape of the
outcome probability distribution. If the solution vector is not in
the +Rfield, the situation is even worse, requiring quantum
tomography to extract the amplitudes of the quantum states
in superposition. This problem is discussed in more depth in
Section IV.
It is possible, however, to apply operations to the solution
in superposition. One of such operations is the SWAP test
[7], which can be used to extract the distance between two
quantum states, encoding it in the amplitudes of a single
qubit as will be shown in Section III. In a similar context
[5], the SWAP test has been used in the past to verify the
correctness of proof of concept implementations of HHL.
When the implementation is correct, the distance with the
arXiv:2210.12707v1 [quant-ph] 23 Oct 2022