Radecka - FPGA Emulation of Quantum Circuits
Radecka - FPGA Emulation of Quantum Circuits
Abstract— Quantum computing offers immense speedup in tems, it is advantageous to have a hardware emulator which
performing tasks such as data encryption and searching. The approximates quantum effects, but mimics the parallel nature
quantum algorithms can be modeled using classical computing of quantum computation more closely than software-based
devices, however classical computer simulations cannot deal
efficiently with the parallelism present in quantum algorithms. simulators.
The quantum circuit model for quantum algorithms is sufficient Quantum circuits are one convenient way of describing
to describe the known quantum algorithms. Using analogies quantum algorithms. Such circuits comprise of analogues to
between quantum and digital circuits, we design the emulator of digital bits and gates. These components can be emulated
quantum algorithms in FPGAs that allows efficient experimen-
in existing FPGAs, which can map inherently parallel com-
tation with new quantum algorithms. This paper concentrates
on new techniques for modeling quantum circuits, including the putational tasks more efficiently than software simulations.
entanglement and probabilistic computing realization, as well as For this reason, we investigate the design of quantum circuit
the critical issues in the required precision of computing. emulators by classical circuits, and devise an FPGA-based
quantum circuit emulator. Using quantum circuit primitives,
I. I NTRODUCTION the construction of new quantum algorithms becomes intuitive
There is an increased interest in quantum computing and and similar to the common software library approaches.
algorithms [5]. Many quantum algorithms outperform their The paper is organized as follows. In Section II, we provide
classical counterparts through parallelism that is impossible in the background on quantum computation. In Section III, we
classical computing. Quantum algorithms use physical effects give details of our quantum circuit emulation system, followed
like entanglement and super-position to achieve the speedup. by several case studies and performance analysis in Section IV.
These effects are hard to replicate at large scale and lead
to reliability and precision issues, as well as to the need to II. BACKGROUND
employ suitable quantum measurement procedures [1]. Nev-
ertheless, some of the quantum effects have been successfully In this section, we provide a brief review of the concepts
used in practical applications such as data encryption and com- in quantum computing that have implications to the design of
munication [5]. Further, several quantum-computing systems a quantum circuit emulator.
are being developed [7]. IBM has developed a small-scale
A. Probabilistic vs. Deterministic Computing
quantum machine that is able to execute the celebrated Shor’s
algorithms for factoring numbers. However, creating larger One of the major distinctions of quantum computing is
and more practical quantum computers is still not possible, that it is probabilistic and that quantum algorithms have to
as knowledge about building quantum systems is still in its deal with the reality of measurement errors. Surprisingly,
infancy. To develop quantum algorithms, simulation models this difference often gets overlooked when modeling quantum
nevertheless suffice. circuits and most modeling approaches still try to make the
Feynman noted that a quantum computer can be modeled simulations fit within the deterministic mode of computation.
efficiently only by another quantum machine. In absence Deterministic circuits present a computation model where
of large-scale quantum machines, quantum algorithms are results of the computation can be obtained without any mea-
currently being simulated by classical computers. Modeling surement error. A classical (non-quantum) probabilistic circuit
of quantum processes in software is the arduous task that is runs a series of inputs through the network of gates and outputs
currently facilitated mostly by quantum computing libraries the bits according to the probability distribution induced by the
[3], [11], [12]. The challenge here comes from the need for given network. Hence, in probabilistic computing the result
using approximations of quantum processes, as their exact of computation cannot be determined correctly every time a
representation in classical computing is not possible. Even by measurement of the result is made. Consequently, there is
using approximations, it is estimated that a single simulation a probability of an error in measuring probabilistic circuit
run over a 20-bit quantum system requires a day of computing outputs, and the computation has to be performed a sufficient
time on modern computers [8]. For developing quantum sys- number of times to make the expected error acceptable. In
this paper, we address both modes of modeling by FPGA is a key design issue. The second goal is to emulate the
emulators. parallelism in quantum computing using FPGAs. Finally, it
is desired that the modeling tool be simple to use and that the
B. Quantum Information Representation construction of the model does not require significant effort
The second major difference to classical computing arises from the developer.
from the types of signal values required to perform computing.
While the basic information units for classical circuits are 0 Import quantum
and 1, quantum computing uses complex numbers as bearers of circuit package to
design
information. Hence, representing a single quantum information
unit might require a large number of classical bits, depending
on the precision required. Construct quantum circuit
More formally, the states of the quantum system belong to using gates provided
a vector space over complex numbers in which there exists
an inner product of vectors. Such a vector space is usually
referred to as the Hilbert Space H. For our purposes, it suffices Synthesize circuit on FPGA
Simulate circuit using VHDL for hardware emulation of
to say that the quantum states are depicted as vectors of simulation tools the quantum circuit
complex numbers.
In denoting these vectors, commonly used is the Dirac bra-
ket notation. Elements of H are ”ket” vectors given by |xi ∈ Fig. 1. Modeling quantum circuits using the VHDL quantum gate library
H. A corresponding ”bra” vector hx| is an element of the
dual space H ∗ of all operators on the vector space that act on The overall design process is illustrated in Figure 1. Quan-
vectors and produce scalar values. tum circuits are constructed from the quantum gate com-
ponents provided in the library that we have created. The
C. Quantum Bits correctness of the circuit can be verified either by software
The basic units of quantum information can be viewed as simulation or by FPGA emulation. We thus, have a technique
simple two-state systems, such as magnetic spin of plus/minus for modeling quantum ciruits using VHDL and then synthe-
one half. The state of a spin is given as a continuous quantity sizing the circuit in hardware to achieve performance needed
represented by two real numbers. It is exactly this continuity to make the whole process more practical.
in spin representation that contributes to the ability of storing We next show how the fundamental constructs of quantum
the infinite classical information by a single quantum system. circuits and the rules governing quantum computation are
Quantum bits defined this way are commonly referred to as simulated by classical technology.
qubits. Qubits can be realized by means such as NMR and
trapped ion interactions. α real α imaginary
Binary qubits have two computational base states denoted Sign Decimal
N bit Mantissa
Sign Decimal
N bit Mantissa
Bit bit Bit bit
as |0i and |1i. Unlike classical bits, quantum bits are in a
linear superposition of the basis states |0i and |1i. β real β imaginary
Sign Decimal Sign Decimal
N bit Mantissa N bit Mantissa
|ψi = α|0i + β|1i (1) Bit bit Bit bit
where α and β are complex coefficients related as Fig. 2. Fixed-point quantum bit representation
Quantum Quantum
1 0 0 0 State
Register
State
Register
0 1 0 0 Qubit N
Nc = 0 0 0 1
Quantum
Gate
Quantum
Gate
0 0 1 0 Clock
In simple terms, if |ηi = |0i, then |ψi is inverted, hence Fig. 6. Emulated quantum circuit overview
the name CNOT. This operation is well-defined for any linear
superposition of states, unlike binary NOT gates which only To construct network of quantum gates, we insert interme-
convert 0 to 1, and vice-versa. diate registers to hold the qubit values after each gate. These
5) Z-Gate: The Z-gate is a single-qubit gate that inverts the quantum state registers (QSRs) essentially represent the state
phase of the qubit in 1i basis. of the entire quantum system at any given stage of evolution.
1 0 The gates are important as they synchronize the data flow in
Z=
0 −1 the system, which is important for large circuits.
That is,
Z|ψi = α|0i − β|1i
Quantum Quantum
The Z-gate does not introduce any error as it simply flips State State
Register Register
the sign bits for the complex beta value. 00> real 00> real
The data in Table I was obtained by computing the absolute 00> complex Quantum 00> complex
error in the output of each gate using 16-bit mantissa length Qubit 1 01> real Gate 01> real
for gate coefficients and the inputs. The input to each gate unentangled Quantum 01> complex 01> complex
Gate
was chosen to be |ψi = √12 |0i + √12 |1i. From experiment it Qubit 2 causing 10> real 10> real
unentangled entangle 10> complex 10> complex
was found that the error is maximum when the qubit is in a ment
Quantum
11> real Gate 11> real
superposition state.
11> complex 11> complex
TABLE I
√ √
A BSOLUTE E RROR ON Q UBIT IN STATE |ψi = 1/ 2|0i + 1/ 2|1i Fig. 7. Emulation of quantum evolution of an entangled system
State
Detection
Probabilities Quantum Qubit n
measurement State H Rn −1 Rn
simulator Detected
Input from
emulated
Qubit n-1
quantum H Rn −2 Rn −1
circuit
Qubit 2
Fig. 8. Emulation of probabilistic quantum computing H R2
Qubit 1
H
F. Emulation of Quantum Measurements and Probabilistic
Computing
Fig. 9. A N-qubit QFT Circuit
Quantum measurements and the probabilistic nature of
quantum algorithms are currently supported directly by a
combination of hardware and software means. Due to the com- B. Quantum Fourier Transform
plexity of quantum measurement algorithms (which are being The quantum Fourier transform (QFT) [5], [6], [2] is an
investigated and developed in parallel), software simulation of important quantum algorithm as it plays a key role in phase
quantum measurements is currently employed [1]. We however estimation, order-finding and factoring algorithms. A N qubit
foresee the posibility of emulating quantum measurement in QFT circuit is depicted in Figure 9. The QFT algorithm
hardware once their algorithms become developed and stable. achieves exponential speedup compared even to FFT, which
To perform the measurement in hardware, it suffices that by itself is one of the most important nontrivial algorithms.
the probabilities for detecting each state are pre-computed in The entire QFT circuit is constructed from one or two input
software and stored in hardware. The probabilities can then quantum gates. The QFT comprises of Hadamard gates and
be used as weights to emulate the random state detection in the controlled-Rj . The Rj transform is defined as follows
hardware.
1 0
IV. Q UANTUM C IRCUIT C ASE S TUDIES Rj = j
0 e2πi/2
A. Emulator Mapping Results
The Rj gate is similar to the phase-shift gate so the
The techniques presented in this paper offer the means for controlled-Rj is implemented using controlled phase-shift
quantum circuit emulations in FPGAs by including quantum gates. We implemented a 3-qubit QFT circuit using our library.
gate library and entanglement components, like most quan-
tum software simulators [11]. No changes to standard FPGA C. Grover’s Search Algorithm
mapping and the overall design flow are required. The Grover’s search algorithm [5], [6], [9] is yet another
Table II depicts the logic cell usage for the quantum gates illustration of quantum algorithms significantly outperforming
in the library and that of the quantum circuits described above. classical
√ algorithms. The algorithm performs searches in is
The device chosen were Altera Stratix EP1S80F1020C. The O( N ) time, rather than classically possible O(N ), for a
simulation tool used is ModelSim and Leonardo Spectrum was database with N entries. The Grover’s search algorithm circuit
used to obtain synthesis results. The mantissa length for the for 4 element data base is depicted in Figure 10. The oracle
qubit was chosen to be 16 bits. gate is itself a “black box” quantum circuit that queries the
As the number of qubits increases, the circuit size grows database for the search key. The oracle gate can be constructed
exponentially due to entanglement effects. However, from the using the quantum gates provided in the library. In this circuit,
emulation results we can observe that fairly large circuits can entanglement can occur depending on the query result from
the oracle gate. The circuit in Figure 10 was implemented V. C ONCLUSIONS AND F UTURE W ORK
using our library. We presented the issues in the design and the operation of
a quantum circuit emulator based on FPGAs and developed
Qubit 1 H H X X H a platform for the development of quantum circuits. The
emulator allows the construction of fairly complex quantum
Qubit 2 Oracle
H H X H H X H circuits from the component library in a simple way. At the
Gate
Qubit 3 same time, it emulates the parallelism present in quantum
H H computers by constructing parallel evolution paths for each
quantum bit on the FPGA. We show that FPGA emulations are
Fig. 10. Grover’s search algorithm for a 4 element database advantageous, as it is difficult to efficiently emulate the parallel
evolution of the quantum system in software. The emulator
Emulation data for the algorithms is provided in Table III. is also scalable and has the potential of emulating complex
Both of the algorithms were synthesized on the Altera Stratix quantum circuits. This emulator can also incorporate further
EP1S80F1020C chip using 16-bit mantissas. quantum computing concepts like quantum error-correction,
fault-tolerant quantum computing and quantum measurement
TABLE III
techniques. These would be especially helpful in developing
Q UANTUM C IRCUIT P ERFORMANCE
practical systems for quantum computers.
Other uses of the quantum emulator can be for the anal-
Circuit LC Usage Clock Speed
(16-bit mantissa) ysis, optimization and approximation of quantum Fourier
3-qubit Quantum Fourier Transform 5076 82.1 MHz transforms, which are critical for most spectacular quantum
Grover’s Search 12636 82.1 MHz algorithms. We plan to further explore the development of
quantum/reversible gate libraries and specialized architectures
for emulation of quantum algorithms [8] and [15].
D. Comparison to software simulation Finally, we plan to undertake a study and optimization of
The hardware emulation of quantum circuits has significant quantum measurement algorithms using this emulator, which
advantages over software simulators. First, the evolution of is currently not practical by software simulations.
each quantum bit can occur in parallel. Software simulators R EFERENCES
have to sequentially simulate the evolution of each quantum
[1] A.U. Khalid, Z. Zilic, K. Radecka; Quantum State Detection using
bit. Efforts are being made to create parallel software sim- Frames, Int. workshop on Post-Binary ULSI Systems, May 2004
ulators [4] but they cannot acheive the parallelism available [2] Z. Zilic and K. Radecka, The Role of Super-fast Transforms in Speeding
through emulating quantum circuits using FPGA. up Quantum Computations, Proceeding of the 32nd IEEE International
Symposium on Multiple-Valued Logic (ISMVL02), 2002
Secondly, by using QSRs, we can pipeline the quantum [3] ”Libquantum”, Online Quantum Library Documentation,
circuit. This introduces latency to the design but provides the http://www.enyo.de/libquantum/
ability to emulate quantum circuits for multiple inputs very [4] Kevin M. Obenland and Alvin M. Despain, Parallel Quantum Computer
Simulation, UGC 1998
efficiently. This is not possible in software and the algorithm [5] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum
has to be executed in its entirety for each new input. Information, Cambridge Univ. Press, 2000
[6] Gruska, Jozef; Quantum Computing, Cambridge Univ. Press, 1999
In order to compare the performance of the FPGA emulator [7] M. Steffen, L. M. K. Vandersypen and I.L. Chuang, Toward Quantum
to software, we found the average time required to execute the Computation: A Five-Qubit Quantum Processor, IEEE Micro, Vol. 27,
above algorithms in software using [3]. The test was performed No. 1, pp. 24-34, 2001
[8] J.P. Hayes and I.L. Markov, Simulation, Synthesis and Testing of Quantum
on a 2 GHz Pentium IV machine running Redhat Linux. Circuits, DARPA QuIST annual research review, Beverly Hills, CA, June
The FPGA emulation of the same algorithms was performed 2003
using 16-bit mantissas to represent gate coefficients and in- [9] V.V. Shende, A.K. Prasad, I.L. Markov and J.P. Hayes, Synthesis of
Reversible Logic Circuits, IEEE Transactions. on CAD, vol 22(6), June
puts. The benchmark results are presented in Table IV. The 2003
FPGA emulator performs significantly better than the software [10] G.F. Viamontes, M. Rajagopalan, I. L. Markov and J.P. Hayes, Gate-
simulator. For larger circuits, the disparity in performance is Level Simulation of Quantum Circuits, ASPDAC, January 2003
[11] QCL - A Programming Language for Quantum Computers, Quantum
even greater because the sequential software simulation of the Computing Library Online, http://tph.tuwien.ac.at/ oemer/qcl.html
qubits’ evolution becomes a more constricting bottleneck. [12] D. Greves, ”QDD : A Quantum Computer Emulation Library”,
http://thegreves.com/david/QDD/qdd.html
TABLE IV [13] P. W. Shor, ”Polynomial Time Algorithms for Prime Factorization and
B ENCHMARKS Discrete Logarithm”, SIAM Journal of Computing, 26(5), 1484-1509,
1997.
[14] H. M. Wiseman, Quantum Trajectories and Quantum Measurement
Circuit Libquantum FPGA Emulator Theory, Quantum Semiclass 1996
(seconds) (seconds) [15] M. Fujishima, K. Saito, M. Onouchi, H. Hoh; High-speed processor for
Quantum Fourier Transform 40 × 10−6 61 × 10−9 quantum-computing emulation and its applications, IEEE International
Grover’s Search 90 × 10−6 84 × 10−9 Symposium on Circuits and Systems, Volume: 4, 25-28 May 2003