1. Ain Shams University Faculty of Engineering Computer and
Systems Engineering Department Modeling a Quantum Computer A Thesis
Submitted in partial fulfillment for the requirements of the degree
of Master of Science in Electrical Engineering Submitted by:
Mostafa Mohamed Mohamed Elhoushi B.Sc. of Electrical Engineering
(Computer and Systems Engineering Department) Ain Shams University,
2007. Supervised by: Dr. Mohamed Watheq El-Kharashi Dr. Hatem
Elsayed Hany ElRefaei Cairo 2011
2. i Abstract The objective of the thesis is to model a hybrid
quantum processor capable of executing quantum algorithms. The
hybrid quantum processor has a co-processor architecture, in which
a quantum processing module is embedded within a classical
MIPS-R2000 processor. The model is designed and simulated using
VHDL. A quantum assembly language (QASM) and its assembler are
developed to allow programmers to describe quantum circuits. The
models architecture is designed to execute the instructions of the
QASM language. Assembly languages containing both quantum QASM
instructions as well as classical MIPS instructions are also
executable on this model. In addition to that, quantum C++ classes
and functions are developed to allow programmers to describe
quantum algorithms using C++ and simulate them on the proposed
model. Unlike previous work on modeling pre-specified quantum
circuits using VHDL, the proposed work is considered a general
purpose model capable of modeling arbitrary quantum circuits and
algorithms. The QASM language on its own succeeded in simulating
pure quantum circuits which only contain quantum gates, such as:
EPR creation circuit, Toffoli gate circuit, and quantum Fourier
transform circuit. The quantum teleportation circuit, which
contains classical components as well as quantum gates, was
simulated using a C/C++ program containing quantum functions or
macros, which was compiled to a hybrid assembly language containing
both QASM and MIPS instructions. The proposed model can execute
programs written in other high-level quantum programming languages,
if compilers are developed to translate such languages into the
proposed low-level QASM language.
3. iii Acknowledgments First and foremost, I would like to
thank my supervisors Dr. Mohamed Watheq El-Kharashi and Dr. Hatem
Elrefaei for giving me this opportunity to work with them. This
thesis would not have happened if not for their guidance and
patience. I am also indebted to Dr. Adeeb El Ghonaimy for
introducing the field of quantum computation to our department and
encouraging researchers in our faculty to explore this field. I am
also indebted to Eng. Ahmed Allam for his friendship and
encouragement at starting the thesis. I would like to thank Eng.
Hazem Said for reviewing the thesis paper. His comments provided
considerable polish to the final draft. I would also like to thank
my external examiners, Dr. Ayman Wahba and Dr. Zaky Abdul Majeed,
for being part of the examining committee and for reviewing the
thesis. Finally, I would like to thank my family. My parents have
been my support throughout my life and my wife had always been
backing me and providing me the environment to go ahead with the
thesis. Thank you. Mostafa Mohamed Mohamed Elhoushi Computer and
Systems Engineering Department Faculty of Engineering Ain Shams
University Cairo, Egypt 2011
4. v Statement This thesis is submitted to Ain Shams University
for the degree of Master of Science in Electrical Engineering
(Computer and Systems). The work included in this thesis was
carried out by the author at Computer and Systems Engineering
Department, Ain Shams University. No part of this thesis has been
submitted for a degree or qualification at any other university or
institute. Date : 27/12/2011 Signature: Name : Mostafa Mohamed
Mohamed Elhoushi
5. vii Contents
Abstract...............................................................................................................................................i
Acknowledgments...........................................................................................................................iii
Statement...........................................................................................................................................v
Contents
..........................................................................................................................................vii
List of Tables
...................................................................................................................................xi
List of
Figures................................................................................................................................xiii
List of Code
Listings......................................................................................................................xv
List of
Abbreviations...................................................................................................................xvii
Chapter 1 Introduction
..............................................................................................................1
1.1. Quantum Computation versus Classical
Computation...................................................2
1.2.
Motivation.............................................................................................................................4
1.3. Thesis
Contribution.............................................................................................................5
1.4. Thesis
Organization.............................................................................................................5
Chapter 2 Quantum Computation Background
.....................................................................8
2.1. Quantum Mechanics
Concepts..........................................................................................8
2.1.1. Double-Slit
Experiment...............................................................................................8
2.1.2. Schrdingers
Cat........................................................................................................10
2.2. Quantum
Bit.......................................................................................................................11
2.2.1. Multiple
Qubits...........................................................................................................12
2.2.2. Qubit Measurement
...................................................................................................14
2.3. Quantum
Gates..................................................................................................................14
2.3.1. Universal Quantum Gate Sets
..................................................................................18
2.4. Quantum
Circuits...............................................................................................................19
2.4.1. EPR Creation Circuit
.................................................................................................20
2.4.2. Quantum Fourier Transform
Circuit.......................................................................21
6. viii 2.5. Quantum
Algorithms.........................................................................................................22
2.5.1. Deutsch-Jozsa
Algorithm..........................................................................................22
2.5.2. Quantum
Teleportation.............................................................................................25
2.5.3. Superdense
Coding.....................................................................................................27
2.5.4. Grovers Search Algorithm
.......................................................................................29
2.6. Quantum Computation
Models.......................................................................................31
2.7. Quantum Computing
Languages.....................................................................................32
2.7.1. Imperative Quantum Programming
Languages.....................................................33
2.7.2. Functional Quantum Programming Languages
.....................................................34 Chapter 3
Quantum Processing Module and Integration
...................................................35 3.1. Quantum
Processor...........................................................................................................35
3.1.1. QASM Language
Specification.................................................................................36
3.1.2. qALU
Architecture.....................................................................................................38
3.1.3. QASM
Assembler.......................................................................................................40
3.1.4. Quantum Program
Example.....................................................................................43
3.2. MIPS
R2000........................................................................................................................46
3.2.1. MIPS R2000 Assembly Language
Specification.....................................................46
3.2.2. MIPS R2000 Architecture
.........................................................................................51
3.2.3. MIPS R2000 Compiler and
Assembler....................................................................55
3.2.4. MIPS R2000 Program Example
...............................................................................57
3.3. MIPS-Q
...............................................................................................................................60
3.3.1. MIPS-Q Language Specification
..............................................................................62
3.3.2. MIPS-Q
Architecture.................................................................................................63
3.3.3. MIPS-Q
Assembler....................................................................................................64
3.3.4. Hybrid Quantum/Classical Program Example
......................................................65 Chapter 4
QASM Language
....................................................................................................84
4.1. Examples of QASM
Programs.........................................................................................84
4.1.1. EPR Creation Circuit
.................................................................................................84
8. x B.2. Complex Matrices and
Operations................................................................................125
B.3. Quantum
Gate..................................................................................................................128
B.3.1. Quantum Gate Matrix
Generation.........................................................................130
B.3.1.1.1. Single-Qubit Gate Matrix Generation
...........................................................130
B.3.1.2. Double-Qubit Gate Matrix
Generation.........................................................131
B.4. Quantum
Measurement...................................................................................................133
B.5. Quantum Initialization
....................................................................................................135
B.6. QASM
Instructions..........................................................................................................135
B.7. Quantum ALU
.................................................................................................................136
B.8. Quantum
Processor.........................................................................................................140
References
.....................................................................................................................................142
List of Publications
......................................................................................................................148
......................................................................................................................................
9. xi List of Tables Table 1: QASM instruction
set.....................................................................................................37
Table 2: Values of Q and C registers after executing each
instruction of QASM example.44 Table 3: MIPS R2000 instruction
formats.
.................................................................................46
Table 4: MIPS R2000 instruction
set...........................................................................................47
Table 5: MIPS register set.
............................................................................................................51
Table 6: Signals from the control
unit.........................................................................................55
Table 7: Additional MIPS-Q instruction
set...............................................................................62
Table 8: Format of additional MIPS-Q instruction
set.............................................................62
Table 9: Additional signals from control unit after adding quantum
processing module....64 Table 10: Values of Q and C registers, and
a and b variables after executing each statement of hybrid C
example.
...............................................................................................66
Table 11: Truth table of function showing whether number of 1 bits
in an integer are odd.
..............................................................................................................................................89
Table 12: Optical implementation of QASM instruction set.
................................................121
10. xiii List of Figures Figure 1: Differences between a
deterministic process, a randomized process, and a quantum process.
.........................................................................................................................3
Figure 2: Double-slit experiment illustrating the wave behavior of
light. ................................9 Figure 3: Double-slit
experiment using large particles and the expected intensity on the
screen.............................................................................................................................................9
Figure 4: Schrdingers
cat............................................................................................................11
Figure 5: Quantum NOT
gate......................................................................................................15
Figure 6: Quantum Hadamard gate.
............................................................................................16
Figure 7: Quantum controlled-NOT
gate...................................................................................17
Figure 8: Quantum Toffoli gate.
..................................................................................................17
Figure 9: Summary of main quantum gates.
...............................................................................18
Figure 10: CNOT gate implementation using universal gate
set.............................................19 Figure 11:
Toffoli gate implementation using universal gate set.
............................................19 Figure 12: Quantum
circuit example.
..........................................................................................19
Figure 13: EPR creation circuit and its input/output truth table.
...........................................20 Figure 14: Quantum
circuit representation of the quantum Fourier
transform....................22 Figure 15: The Deutsch-Jozsa
Algorithm's quantum
circuit....................................................23
Figure 16: Quantum teleportation circuit.
..................................................................................25
Figure 17: Superdense coding
circuit...........................................................................................27
Figure 18: Quantum circuit implementation of
.................................................................30
Figure 20: QRAM
model...............................................................................................................32
Figure 21: Model of the quantum processor containing: classical
instruction memory, quantum ALU, quantum register, and classical
register........................................................36
Figure 22: Format of QASM instruction.
...................................................................................37
Figure 23: Internal structure of qALU.
.......................................................................................39
Figure 24: Model of a quantum
gate............................................................................................40
Figure 25: Simulation waveform of QASM example.
...............................................................45
Figure 26: Architecture of MIPS-R2000
processor...................................................................52
Figure 27: Internal structure of MIPS R2000
processor...........................................................53
Figure 28: Internal Bus State
machine.........................................................................................54
Figure 29: Simulation waveform of C
example..........................................................................59
Figure 30: Flowchart of compilation and execution of hybrid
quantum/classical program.
......................................................................................................................................................61
Figure 31: Architecture of
MIPS-Q.............................................................................................63
11. xiv Figure 32: Simulation waveform of hybrid C example.
............................................................82
Figure 33: Applying EPR creation circuit and measuring the qubits
......................................84 Figure 34: Simulation
results of EPR creation circuit.
..............................................................85
Figure 35: Toffoli gate (above) and its circuit implementation
using the proposed gate set
(below).........................................................................................................................................86
Figure 36: Simulation results of Toffoli gate circuit.
.................................................................86
Figure 37: Four-bit quantum Fourier transform
circuit............................................................87
Figure 38: Simulation results of 4-qubit quantum Fourier transform
circuit.........................88 Figure 39: Deutsch-Jozsa
algorithm circuit with .....................................88
Figure 40: Quantum circuit to implement transformation:
.................90 Figure 41: Simulation results of Deutsch-Jozsa
algorithm circuit with .
......................................................................................................................................................91
Figure 42: Quantum teleportation circuit.
..................................................................................98
Figure 43: Superdense conding circuit.
.......................................................................................99
Figure 44: Grovers algorithm circuit.
.......................................................................................102
Figure 45: Comparison of the proposed work with related work.
........................................110 Figure 46: Electric and
magnetic field components of an electromagnetic wave.
..............113 Figure 47: Photon polarization
encoding..................................................................................115
Figure 48: Converting between photon polarization and photon path
encoding. ..............115 Figure 49: Photon path
encoding...............................................................................................116
Figure 50: Setup for heralded photons with parametric fluorescence
(PDC)......................117 Figure 51: Generation of photon
pairs in an atomic cascade
transition...............................117 Figure 52: Polarizing
beam splitter
............................................................................................118
Figure 53: Relation between optical axis and horizontal and
vertical planes for an oriented
waveplate...................................................................................................................................119
Figure 54: Conditional sign flip using the Kerr
effect.............................................................121
Figure 55: VHDL model of a quantum gate.
...........................................................................129
Figure 56: Two equivalent diagrams of applying a gate on a single
qubit which is part of quantum
register.......................................................................................................................131
Figure 57: Two equivalent diagrams of applying a 2-qubit gate on 2
qubits which are part of a quantum
register...............................................................................................................132
Figure 58: Timing diagram of quantum gate
signals................................................................139
12. xv List of Code Listings Listing 1: QASM assembler in
Perl..............................................................................................40
Listing 2: Example of QASM
program.......................................................................................43
Listing 3: Machine code of QASM program
example...............................................................45
Listing 4: Example of C
program.................................................................................................57
Listing 5: Assembly code of C program example.
.....................................................................57
Listing 6: Machine code of MIPS assembly program
example................................................58 Listing
7: Example of hybrid C program.
...................................................................................65
Listing 8: Assembly code of hybrid C program
example..........................................................67
Listing 9: Machine code of hybrid assembly program
example...............................................76 Listing
10: QASM program to implement EPR creation circuit.
............................................85 Listing 11: QASM
program to implement Toffoli gate.
...........................................................86
Listing 12: QASM program to implement 4-qubit quantum Fourier
transform...................87 Listing 13: QASM program to
implement Deutsch-Jozsa algorithm with
................................................................................................................................90
Listing 14: Quantum macro definitions.
.....................................................................................93
Listing 15: Quantum functions
definitions.................................................................................94
Listing 16: Qubit class definition.
.............................................................................................96
Listing 17: C/C++ program to implement quantum teleportation
circuit using macros. ...98 Listing 18: C/C++ function to implement
quantum teleportation circuit. ...........................98
Listing 19: C++ program to implement quantum teleportation circuit
using Qubit class.
......................................................................................................................................................99
Listing 20: C/C++ program to implement superdense coding circuit
using macros.........100 Listing 21: C/C++ function to implement
superdense coding circuit.................................100
Listing 22: C++ program to implement superdense coding circuit
using Qubit class....101 Listing 23: C/C++ program to implement
Grovers algorithm using macros....................102 Listing 24:
C/C++ function to implement Grovers
algorithm............................................104 Listing
25: C++ program to implement Grovers algorithm using Qubit
class...............106 Listing 26: Definition of complex data type
in VHDL.......................................................123
Listing 27: VHDL data types to represent vectors of complex
numbers.............................123 Listing 28: VHDL Resolution
function for complex vector data
type.................................124 Listing 29: VHDL
representation of a qubit vector
................................................................124
Listing 30: VHDL definitions of memory length
constants...................................................124
Listing 31: VHDL function to obtain complex conjugate of a
function..............................125 Listing 32: VHDL function
for matrix tensor
product...........................................................125
13. xvi Listing 33: tensor_indexed function with first argument
being part of a large matrix.
....................................................................................................................................................126
Listing 34: tensor_indexed function with second argument being part
of a large
matrix.........................................................................................................................................126
Listing 35: tensor_indexed function with both arguments being part
of large
matrices......................................................................................................................................127
Listing 36: tensor_indexed function with both arguments and result
being part of large
matrices............................................................................................................................127
Listing 37: Entity interface of quantum gate.
...........................................................................129
Listing 38: Process in quantum gate to update qubit value.
...................................................130 Listing 39:
Pseudocode for generating rotation matrix for a 2-qubit gate whose
addresses differ by more than one.
.........................................................................................................132
Listing 40: Entity interface of quantum measurement
component.......................................133 Listing 41:
Architecture of quantum measurement
component............................................133 Listing
42: Entity interface of qubit initialization component
...............................................135 Listing 43:
Architecture of qubit initialization component
....................................................135 Listing 44:
VHDL representation of QASM opcodes.
...........................................................136
Listing 45: VHDL representation of QASM instruction structure.
......................................136 Listing 46: Entity
interface of
qALU.........................................................................................136
Listing 47: Internal signals and components of qALU.
..........................................................136
Listing 48: qALU
processes........................................................................................................139
Listing 49: Entity interface of quantum processor.
.................................................................140
Listing 50: Architecture of quantum
processor........................................................................140
14. xvii List of Abbreviations ALU Arithmetic and Logic Unit
ASIC Application Specific Integrated Circuit CISC Complex
Instruction Set Computers CNOT Controlled NOT CPU Central
Processing Unit cQPL communication capable QPL EPR
EinsteinPodolskyRosen FPGA Field Programmable Gate Array GCL
Guarded Command Language HDL Hardware Description Language MIPS
Microprocessor without Interlocked Pipeline Stages MIPS-Q MIPS with
Quantum module MUX Multiplexer NMR Nuclear Magnetic Resonance PBS
Polarizing Beam Splitter PC Program Counter PDC Parametric Down
Conversion qALU quantum ALU QASM Quantum Assembly QCL Quantum
Computer Language qGCL quantum GCL
15. xviii QPL Quantum Programming Language QRAM Quantum Random
Access Machine RISC Reduced Instruction Set Computers VHDL Very
high speed integrated circuit Hardware Description Language
16. 1 Chapter 1 Introduction Towards the end of the 20th
century, performance improvements in transistor technology seemed
to meet a bottleneck and Moores law became apparent that it will
not be in effect forever. The main bottleneck in speed improvement
is the heating effect arising from frequency scaling while the main
bottleneck in size improvement is the appearance of quantum effects
resulting from nanoscaling. Several new technologies are now being
researched to replace semiconductor-based computers totally or
partially: photonics, DNA computing, and quantum computing. Some of
these new technologies have already had opportunities in the
commercial domain, not just the academic domain. The focus of this
thesis is on the simulation of a quantum computer. Quantum
computing employs quantum mechanics and takes advantage of its 2
main properties: superposition and entanglement to provide
efficiency improvements in certain types of computation problems
such as data searching, factorization, and encryption. The idea of
employing quantum mechanics in computation was first proposed by
Richard Feynman in 1982, when he pointed out that it is impossible
to simulate quantum mechanics efficiently using classical
computation, and mentioned that a computer which employs quantum
mechanics may efficiently simulate quantum mechanics computation
[1]. This was followed by a proposal by David Deutsch in 1985 of a
quantum Turing machine [2]. The first person to propose an
algorithm to solve a real-life problem on a quantum computer more
efficiently than on a classical computer was Peter Shor, who
proposed in 1994 his famous factorization algorithm [3]. Other
quantum algorithms include: Grovers fast database search [4],
adiabatic solution of optimization problems [5], precise clock
synchronization [6], quantum key distribution [7]; and recently,
Gauss sums [8] and Pells equation [9]. Shors algorithm sparked work
in 3 main fields in quantum computation: searching for new quantum
algorithms outperforming their classical counterparts in solving
other problems, developing models and concepts for quantum
computers, quantum compilers, and quantum programming languages,
and implementing quantum computers or quantum circuits physically.
A variety of different physical systems are being considered to be
used as quantum computers and each of them have their own
advantages and disadvantages and it is not known until now which
technology is the most feasible [10]. Some of the approaches being
considered are:
17. 2 Optical waveguide circuits [11], Ion trap technology
[12], Nuclear Magnetic Resonance (NMR) [13], Quantum dots [14], and
Superconducting electronics [15]. A brief explanation of optical
technology is given in Appendix A. As physical implementation of
quantum systems faces some difficulties, other efforts concentrate
on designing frameworks and simulating them to be ready for
implementation when such difficulties are solved in the future.
Previous work has concentrated on simulating quantum algorithms
separately. However, we here target modeling a general-purpose
quantum computer which can simulate arbitrary quantum algorithms.
The resulting simulation model has the same interface of a physical
quantum computer, although the internal structure maybe different.
1.1. Quantum Computation versus Classical Computation The three
main properties which distinguish quantum computation from
classical computation are: Superposition: While a classical bit is
represented using either 0 or 1, a quantum bit, or qubit, is
represented as a superposition of both 0 and 1 and it collapses to
either 0 or 1, each with a specific probability, after measurement
[16], Entanglement: Two qubits maybe entangled such that if one
qubit is measured then the value of the other qubit is known
without measurement, and Interference: An operation may occur on a
qubit to increase or decrease, or even omit, the probability
amplitudes of its measurement result. Although these concepts seem
to be strange, several quantum algorithms have been developed which
take advantage of these properties, e.g., Deutsch-Jozsa algorithm
[17], Grovers search algorithm [4], and Shors factorization
algorithm [3]. While classical computation is deterministic,
quantum computation is probabilistic. The result of quantum
computation cannot be known previously. We can only know the
probability distribution of the possible results of quantum
computation. Again, this seems to be a disadvantage of quantum
computation; however the developed quantum algorithms in literature
have either made turnarounds around this fact (such as Deutsch
algorithm) or
18. 3 remained its probabilistic nature and need to be run
several times to obtain the correct solution (such as Shors
algorithm). An analogy to help us imagine quantum computation is a
coin tossing [18]. A qubit can be regarded as a weighted coin that
is flipping in the air. We do not know whether the state of the
coin is heads or tails while it is in the air (analogous to
superposition), however we may consider bombarding it with another
object to modify the probability distribution of heads or tails
(analogous to quantum gate operations). Catching the coin while it
is in the air using our hand at any time shall collapse the coin to
either heads or tails and the coin loses its superposition property
(analogous to qubit measurement). However, a tossed coin does not
flip forever in the air and gravity shall cause it to collapse to
the ground on either its heads or tails side (analogous to
decoherence of qubits, which is explained in Section 6.2). However,
it is important to note that a quantum process is not a randomized
process. As shown in Figure 1, a randomized process has a certain
unknown value throughout the process, and measuring the value of a
bit at the beginning and then applying the operations is equivalent
to applying the operations first and then measuring it at the end.
However, in a quantum process, a qubit actually has both values at
the same time and it actually follows all the possible paths, and
measuring the qubit value at the beginning and applying the
operations is not equivalent to measuring it at the end. See
Section 2.1 Quantum Mechanics for more elaboration on this concept.
Deterministic process Randomized Process Quantum Process start
state end state time transition probability transition amplitude
Figure 1: Differences between a deterministic process, a randomized
process, and a quantum process.
19. 4 As there are gates in classical computation which change
the value of a classical bit, there are quantum gates which change
the state of a qubit. While a classical gate usually has an input
and output with the input value not changed after the output value
is obtained, a quantum gate actually deals with the same qubit(s)
and change their values over time. See Section 2.3 Quantum Gates
for more details. 1.2. Motivation Until now, how quantum computers
will really look like is not yet agreed upon. There have been
several proposals for a quantum processor architecture [2] as well
as many proposals for quantum programming languages [19]. Many of
these programming languages are actually to be compiled to produce
a quantum circuit rather than instructions for a general- purpose
quantum computer. Some researchers are not interested in a
general-purpose quantum computer and are happy to have
special-purposed quantum devices to implement certain useful
algorithms. For example, researchers at the University of Bristol
have reported that they have implemented part of Shor's algorithm
on a single chip [20]. Others are ambitious to have a general
purpose computer which is fully quantum while some propose a hybrid
processor [21], which is in general classical but only uses quantum
computation when it is useful or necessary. In this thesis, we are
going towards the second proposal. We believe that representing
data as qubits is theoretically not useful in most computations
because qubits are in superposition states and the results of an
algorithm is probabilistic. However, this superposition nature of
qubits is only useful in certain cases, such as the algorithms
mentioned above. So there is no advantage to devise ways to
implement classical operations, such as addition, subtraction,
bitwise and, etc. using quantum gates. While there are research
efforts in implementing such quantum circuits physically, other
efforts alongside target designing and simulating quantum
processors which can execute arbitrary quantum algorithms. This
thesis is concerned with designing and simulating a quantum ALU
using VHDL in a manner which maybe later mapped to a physical
implementation. As physical implementation of quantum systems faces
some difficulties, it is sensible for other efforts to concentrate
on designing frameworks and simulating them to be ready for
implementation when such difficulties are solved in the
future.
20. 5 1.3. Thesis Contribution The objective of designing a
quantum processor is to have a general-purpose quantum module
capable of executing arbitrary number of gates in an arbitrary
order, and therefore capable of executing arbitrary quantum
algorithms. Using the resulting processor, a quantum algorithm is
to be described using instructions of the Quantum Assembly (QASM)
language [22]. The instructions are then interpreted into classical
instructions to be loaded into a classical instruction memory
within the processor. The instructions are executed sequentially by
decoding each instruction and applying the required quantum
operation on the required qubits. This concept of manipulating
quantum operations using classical signals is known as the Quantum
Random Access Machine (QRAM) model [23]. In this thesis, we shall
model a quantum processor using a hardware description language
(HDL) and the resulting module can be considered as a
general-purpose quantum circuit. The proposed module is then
integrated, as a quantum module, within a classical MIPS processor
to form MIPS-Q. Therefore, a program containing both classical and
quantum parts maybe executed on this hybrid processor. As a result,
a program written in a language such as the Q Language [21], which
contains both classical and quantum parts, may have a compiler to
generate the classical and quantum assembly instructions to be
executed on a single hybrid quantum processor. 1.4. Thesis
Organization The rest of the thesis is organized as follows:
Chapter 2 provides a detailed background of quantum computation.
Chapter 3 presents the proposed QASM language. It provides its
instruction set and provides program examples illustrating its
capability of describing quantum circuits or algorithms. Chapter 4
shows how we integrate the proposed QASM language with a classical
high-level language, C++, and provides C++ example programs
illustrating the functionality of describing more complex quantum
algorithms using a high-level language. Chapter 5 describes the
internal model of the proposed quantum processing module and
explains how it has been integrated into a classical MIPS processor
to form the hybrid quantum processor: MIPS-Q. Chapter 6 summarizes
the thesis and presents the conclusion of the thesis. Directions
for future work are also suggested.
21. 6 Appendix A describes how the various QASM instructions
can be implemented physically using the optical physical
implementation method. Appendix B documents the HDL code of the
simulation model of the quantum processing module and explains its
various internal components.
22. 8 Chapter 2 Quantum Computation Background In this chapter,
we shall provide a brief background to quantum computation. We
shall start with an introduction to quantum mechanics concepts
which is the basis of quantum computation. We then introduce
quantum bits, quantum gates, and quantum circuits. Explanation of
the main quantum algorithms found in the literature is provided.
Finally, we discuss the various models of quantum computation and
the various quantum programming languages found in literature. 2.1.
Quantum Mechanics Concepts Quantum mechanics is a framework which
was developed at the beginning of the 20th century which is
concerned with providing a mathematical description of dual
particle-wave interaction and behavior of matter and energy.
Although some of its concepts are non- intuitive, it proved to be
successful in explaining experimental results which classical
mechanics failed to explain. Quantum mechanics describes a state of
a system via a mathematical structure known as the wave function.
Rather than describing the value of a property of a state, a wave
function encapsulates the probability of physical variable having a
certain value if it is measured. The evolution of a wave function
of a system from an initial state to a new state can be described
either by Schrdingers equation (a partial differential equation) or
by the Dirac notation (that uses the bra and the ket notations)
[24]. However, researchers in quantum computation prefer to
describe quantum state using the latter method in line with linear
algebra as will be shown in Section 2.2. 2.1.1. Double-Slit
Experiment One experiment which illustrates an example where
quantum mechanics succeeds in interpreting a physical phenomenon
while classical mechanics fails, is the double-slit experiment. As
shown in Figure 2, a light source emits light on a wall with 2
holes. Light diffracts after passing through each hole and when it
hits the screen interference patterns between light waves
diffracted from each hole are seen. Therefore, a detector moving
across the screen shall measure increasing and decreasing
intensities of light, which illustrates the wave behavior of
light.
23. 9 DETECTOR Interference of Waves WAVE SOURCE Wall Screen A
B P Wave Intensity x Figure 2: Double-slit experiment illustrating
the wave behavior of light. However, if we emit particles, lets say
marbles, rather than light, we expect them to hit the screen at the
middle with high probability and at the ends with lower
probabilities, as shown in Figure 3. MOVABLE DETECTOR Do Particles
Show Interference? PARTICLE GUN Wall Screen A B P Particle Density
x Figure 3: Double-slit experiment using large particles and the
expected intensity on the screen. If we emit light as discrete
short pulses, one pulse at a time with each pulse infinitesimally
short, then we consider such short pulses as photons and since
photons are considered
24. 10 particles, we expect the behavior shown in Figure 3.
However, experimentally the interference patterns in Figure 2 are
observed. This means that each photon passed through both slits at
the same time as if it was a wave. However, if we place a detector
at one of the slits to detect whether a photon passes through it or
not, the result is changed to the particle density pattern in
Figure 3, not the interference pattern of Figure 2. This experiment
can be repeated using electron beams and similar results are
observed: a single electron or photon seems to act as a wave with
its position spanning over an area and not concentrated at a
certain point. However, if there is an attempt to measure the
position of an electron or photon, the wave collapses to a certain
point and no longer it acts as a wave, i.e., measurement of a
quantum state alters its behavior. In this experiment, we may
describe the state of the photon as: , where is the wave function
which we shall explain in more detail in Section 2.2. Note that the
square of each coefficient, i.e. , gives the probability of the
measurement result from the corresponding path. The concept of
representing the state as a combination of two states is known as
superposition. 2.1.2. Schrdingers Cat To try to illustrate the
superposition principle, Erwin Schrdinger proposed the thought
experiment widely known as Schrdingers Cat [25]. In this
experiment, a cat is isolated within a box containing a radioactive
substance, a Geiger counter (device which detects radioactivity), a
hammer, and a flask containing a poison. The radioactive substance
has equal probabilities of decaying or not decaying. If the
radioactive substance decays, the Geiger counter detects radiation
and releases the hammer, which in turn breaks the flask and spills
the poison, which in turn causes the cat to die. Therefore, as long
as the box is closed, there is a 50% probability that the cat is
alive and a 50% probability that the cat is dead.
25. 11 GEIGER COUNTER RADIOACTIVE SUBSTANCE HAMMER POISON
WINDOW (for an observer) Figure 4: Schrdingers cat. There have been
several interpretations of the superposition concept: Copenhagen
Interpretation [26]: The cat is both dead and alive and it
collapses to one of the two states when we observe it. Ensemble (or
Statistical) Interpretation [27]: The wave function cannot be
interpreted as a description of a single cat but is an abstract
mathematical, statistical quantity that applies to a group of
similar cats. Therefore, if we have a group of Schrdingers cats
each within the box, then each cat is either dead or alive, but the
wave function tells us that a proportion of the cats are alive and
the rest are dead. Many-worlds Interpretation [28]: We have many
worlds or many universes and they keep on splitting each time a
quantum state collapses. So during Schrdingers cat experiment, the
universe splits into two universes: one universe where the the cat
is alive and one universe where the cat is dead but both universes
have no interaction between them. Transactional Interpretation
[29]: When a quantum state collapses, a message is sent back from
the future to the past. For example, if you see the cat is dead,
the message is sent back to the radioactive substance to decay.
2.2. Quantum Bit A qubit can be represented in vector form using a
wave function, :
26. 12 where is the probability that when the qubit is measured
it collapses to 0 and is the probability that when it is measured
it collapses to 1. According to probability theory, the condition ,
which is known as the normalization condition, must always hold
true. The concept of representing a state using a wave function
that has probabilities of having different values is known as
superposition. The representation above is known as the Dirac
bra-ket notation. A ket vector is an element in a
finite-dimensional complex space known as the Hilbert space, , [16]
represented as . The corresponding bra vector is the complex
conjugate of the ket vector, , and is an element of the dual space
. A qubit can also be represented in vector form as: From the
simulation point of view, a simulator may represent a qubit using
complex array containing two numbers: one to represent and one to
represent . 2.2.1. Multiple Qubits A quantum state, in a general
form, consists of several qubits. As an example, a 2-qubit system
can be represented as [16]: where represents tensor product
operation. This means that the probability of measuring both qubits
to be, for example, is . Again, the normalization condition must
hold true: . The 2-qubit system may also be represented in vector
form as: In its general form, an -qubit state maybe represented by
the tensor product of each qubit [16]:
27. 13 This can also be represented in vector form as:
Generally, an -qubit system requires a vector representation of
elements. The resulting state space is a vector. An -qubit system
which can be represented as the tensor product of qubits is known
as a pure system. From the simulation point of view, a simulator
may represent this system using a complex array. However, a quantum
system may undergo operations to become an entangled state. An
entangled state is an -qubit system which cannot be represented as
a tensor product of qubits. For example, the following is a
two-qubit entangled state: Note that in this example, the value of
the 2 qubits are either or . Therefore, if the first qubit is
measured to be a certain value, then the second qubit is known to
have the same value without measuring it, i.e. the 2 qubits are
entangled. A simulator dealing with an -qubit entangled state has
to work with a state space of complex numbers. Note that this is
one reason why quantum computation is more efficient than classical
computation: one quantum computation operation involving qubits
needs complex numbers to be simulated on a classical computer in
the general case to handle entangled qubits, but needs only complex
numbers in the special case when all qubits are non-entangled,
while a classical operation on one classical bit simply needs bits
to simulate it on a classical computer. Therefore, in the general
case, whether a multi-qubit system is pure or mixed, an -qubit
system is represented as: such that , where each represents the
bitstring from 0 to .
28. 14 2.2.2. Qubit Measurement Considering a 2-qubit example,
and if we measure one of the qubits, lets say the first qubit, then
the probability of measuring the first qubit to be 0 is . Then if
the result is 0, the post- measurement quantum state is: The
post-measurement state has been obtained by following two steps: 1.
include only the coefficients of bitstrings having the first bit
equal to 0 and omit the others, then 2. re-normalize the state by
dividing all coefficients by the probability of the first qubit
measurement to be 0, so that the normalization condition remains.
Considering the general case, the above two steps still hold, but
to describe them mathematically it is better to use projective
measurements as explained in [30]. 2.3. Quantum Gates Operations
are applied to qubits by quantum gates. A quantum gate manipulates
the qubit vector representation, i.e., it changes the probabilities
of the possible outcomes of the qubit measurements. A physical
example of a quantum gate, considering photon polarization
implementation of qubits, is a waveplate, which changes the
polarization of photons (see Section A.5). Mathematically, a
quantum gate maybe simulated using matrix representation. In
general, quantum gate, , changes a quantum state of one or more
qubits, , to . To apply on an -qubit state, we simply multiply the
matrix representation of gate with the vector representation of
state :
29. 15 Since a qubit before and after a transformation, i.e.,
both and , must obey the normalization condition, then must be a
normalized matrix, i.e., , where is the complex conjugate of .
Therefore, the inverse of any quantum gate, , i.e., the gate which
returns back to , is . For example, the quantum NOT is a 1-qubit
quantum gate, which inverses the value of a qubit: Lets demonstrate
the operation of a quantum NOT gate on a single qubit, as shown in
Figure 5: Figure 5: Quantum NOT gate. Another example of 1-qubit
gate is the Hadamard gate, . It converts and states to
superposition states having equal probabilities of collapsing to or
: Demonstrating the operation of a Hadamard gate on a single qubit,
as shown in Figure 6:
30. 16 Figure 6: Quantum Hadamard gate. Note that denotes and
denotes . The Hadamard gate illustrates to us the interference
concept. Let us consider the following two states: From the
measurement point of view, both states are identical since they
have equal probabilities of collapsing to or after measurement.
However, if we apply the Hadamard operation to each state: we find
that each state converted either to state having 100% probability
of collapsing to after measurement or 100% probability of
collapsing to after measurement. This phenomenon is known as
interference: the probability amplitudes have been added. The
Hadamard operation on caused positive interference (i.e.,
probability amplitudes added constructively) with respect to state
and negative interference (i.e., probability amplitudes added
destructively) with respect to state ; and vice-versa concerning
the Hadamard operation on . An example of an algorithm which
employs the quantum interference concept is the Deutsch-Jozsa
algorithm (see Section 2.5.1). An example of 2-qubit gate is the
controlled-NOT (CNOT) gate is shown in Figure 7. The first qubit,
the control qubit connected to the black dot of the CNOT gate,
remains unchanged while the second qubit, the target qubit
connected to the XOR symbol of the CNOT gate, is XORed with the
first qubit:
31. 17 Figure 7: Quantum controlled-NOT gate. An example of a
3-qubit gate is the quantum Toffoli gate, shown in Figure 8. It is
considered the quantum controlled-NAND gate where the third qubit
is inverted if and only if both the first and second qubits are set
to : Figure 8: Quantum Toffoli gate. Some quantum gates may have a
parameter to determine its operation. For example, considering
photon polarization implementation of qubits (see Appendix A), a
wave plate with the angle of its optical axis equivalent to , where
is an integer, keeps the coefficient of a photon as it is and
multiplies the coefficient of by . The matrix representation of
such a gate is: .
32. 18 Figure 9 shows a summary of a group of quantum gates:
quantum NOT gate, , , , Hadamard gate, , phase gate, ,
controlled-NOT gate, CNOT, and controlled phase gate, . Figure 9:
Summary of main quantum gates. 2.3.1. Universal Quantum Gate Sets
Just as we have in classical computation a universal gate set (AND,
OR, and NOT), which can form the building blocks of an arbitrary
classical gate; it can be shown that there are several universal
quantum gate sets which can arbitrarily represent a quantum gate
but up to a certain precision [31]. One such set is . Figure 10 and
Figure 11 show two
33. 19 examples of transforming CNOT and Toffoli gates into
circuits containing gates of the universal gate set. Figure 10:
CNOT gate implementation using universal gate set Figure 11:
Toffoli gate implementation using universal gate set. 2.4. Quantum
Circuits A quantum circuit is an interconnection of quantum gates
which perform a group of quantum operations on a group of qubits.
For example, Figure 12 shows 3 qubits, , and undergo operations by
gates , , and over time. Time flow is represented by the wires
interconnecting the gates from left to right. Figure 12: Quantum
circuit example. The effective gate representing 2 gates in
sequential order has a matrix representation equivalent to the
matrix product of each gates matrix. The effective gate
representing 2 gates acting on 2 different qubits at the same time
has a matrix representation equivalent to the tensor product of
each gates matrix.
34. 20 We shall illustrate this by obtaining the effective
gate, , of the above circuit. First the effective gate matrix of
the operations of the first stage of the circuit, i.e., operations
and , is the tensor product of and because the 2 gates apply on
different qubits at the same time: In the second stage of the
circuit, gate is applied to qubits and and no operation is applied
to qubit . No operation can actually be represented by the identity
matrix, . Therefore the effective gate matrix of the second stage
is: In the third stage, gate is applied to qubit while no
operations are applied to qubits and . Therefore the effective gate
matrix of the third stage is: Finally, the effective gate matrix of
the whole circuit is simply obtained by multiplying the matrices of
all stages together: 2.4.1. EPR Creation Circuit The EPR creation
circuit, shown in Figure 13, is used to set qubits into an
entangled state. It has been named after the founders of the
quantum entangled state principle: Einstein, Podolsky, and Rosen
[16]. The circuit simply deals with 2 qubits: the first qubit
undergoes a Hadamard transformation to convert it from or state
into a superposition state, and then the second qubit undergoes a
CNOT operation controlled by the first qubit. In Out Figure 13: EPR
creation circuit and its input/output truth table. The table in
Figure 13 shows the input/output relation of the circuit. The
output states:
35. 21 are known as the Bell states, or sometimes the EPR
states or EPR pairs. The mnemonic notation , , and maybe understood
via the equations: where is the negation of . 2.4.2. Quantum
Fourier Transform Circuit The quantum Fourier transform is the
quantum counterpart of the discrete Fourier transform and is a part
of several quantum algorithms, e.g., phase estimation part of
Shor's algorithm. While classical discrete Fourier transform acts
on a vector of complex numbers, , to transform it into another
vector, , as follows: where and , the quantum Fourier transform
acts on an -qubit quantum state, , having , and transforms it into
quantum state, , using the same transformation: This can also be
expressed as:
36. 22 It can also be expressed using a matrix representation
as: The circuit which implements the quantum Fourier transform is
shown in Figure 14. Figure 14: Quantum circuit representation of
the quantum Fourier transform. 2.5. Quantum Algorithms In classical
computation, an algorithm is a step-by-step procedure which can be
executed on a classical computer. Similarly, a quantum algorithm is
a step-by-step procedure which can be executed on a quantum
computer. The quantum computer maybe modeled as a quantum circuit,
as shown in the previous section, can be modeled as a QRAM, or as a
quantum Turing machine (see Section 2.6). We shall explain in the
following sub-sections some of the well-known quantum algorithms
which solve problems more efficiently than their classical
counterparts. 2.5.1. Deutsch-Jozsa Algorithm The DeutschJozsa
algorithm was proposed by David Deutsch and Richard Jozsa in 1992
[17]. Although the problem it solves has almost no practical use,
it is a useful example which illustrates parallelism capabilities
of quantum computation in solving a problem more efficiently than
classical computation.
37. 23 The quantum circuit which implements Deutsch-Jozsa
algorithm is shown in Figure 15. The advantage this algorithm has
is the ability to evaluate function for more than one input
simultaneously, using one instance of the module which evaluates
the function. This is something which cannot be done using
classical computation where simultaneous evaluation of several
inputs of a function needs several hardware evaluators of the
function to run in parallel. The algorithm uses the fact that the
possible values of a group of qubits interfere with one another, in
such a way as to give us some global information about the function
over more than one input. Figure 15: The Deutsch-Jozsa Algorithm's
quantum circuit. In Deutsch-Jozsa algorithm, we are given a binary
function, , which returns either 0 or 1 for any given -bit integer
: . We are also given that the function is either constant (returns
0 or 1 for all inputs of ) or balanced (returns 0 for half of the
possible inputs and returns 1 for the other half). Using classical
computation, we need to evaluate for at least values of to
determine whether it is balanced or constant. However,
Deutsch-Jozsa algorithm determines whether the function is balanced
or constant using only one evaluation. We shall now explain the
algorithm. We start with ( +1)-qubits: the first qubits,
representing initialized to and the last qubit initialized to :
where represents a state of qubits each in state . We then apply
the Hadamard transformation to all of the qubits:
38. 24 where represents gates acting on a -qubit state. We have
a module, , which implements the following transformation: .
Applying to the qubits we obtain: Since that, by definition, for
any , is either 0 or 1, we can re-write the quantum state as:
Ignoring the last qubit and applying the Hadamard operation to the
first qubits, we obtain:
39. 25 where is the sum of the bitwise product of bitstrings
and . After that we measure all of the qubits. The probability that
all qubits collapse to , i.e., replace with 0, is , which evaluates
to 1 if is constant (constructive interference) and evaluates to 0
if is balanced (destructive interference). We have determined
whether the function is constant or balanced by applying only once
and measuring the output only once! 2.5.2. Quantum Teleportation In
quantum teleportation, a quantum state is transferred from one
qubit in one location to another qubit in another location, without
the qubit itself being physically transmitted between the two
locations. It is useful for cases where qubits cannot physically
transfer from one location to another via a medium. The idea was
first published by Charles Bennett et al. in 1993 [32]. Its first
experimental implementation was done by a group in Innsbruck in
1997 [33] and has later been shown to work over distances of up to
16 kilometers . Figure 16 shows the circuit which implements
quantum teleportation. Figure 16: Quantum teleportation circuit.
Suppose we have two partners: Alice and Bob. Suppose they met each
other and generated an entangled qubit pair. After that, they
separate and each one of them takes one of the entangled qubits.
Late on, Alice has a qubit, , and wants to send it to Bob. Alice
entangles her qubit with her share of the entangled qubit pair and
then measures both of the qubits. Alice then sends the measurement
results classically to Bob. According to the measurement results,
Bob performs certain operations upon his remaining qubit to convert
it to be identical to Alices original qubit.
40. 26 At the beginning, we have Alices qubit, , and the
entangled pair, (see Section 4.1.1). The quantum state of the whole
system is represented as: Alice applies the CNOT gate upon the
received qubit controlled by her qubit: Alice then applies the
Hadamard gate upon her qubit: Re-grouping terms: Alice measures the
values of the two qubits at her hand. According to each possible
measurement outcome, the state of the system can be either:
Therefore:
41. 27 If both qubits are measured to be 00, then and we
therefore do not need any transformation. If the qubits are
measured to be 01, then and we therefore need to apply the gate on
the third qubit. If the qubits are measured to be 10, then and we
therefore need to apply the gate on the third qubit. If the qubits
are measured to be 11, then and we therefore need to apply the gate
followed by the gate on the third qubit. To generalize, if the
measurement result of the first qubit is denoted as and the
measurement result of the second qubit is denoted as then we can
retain our original qubit, , by applying the following operation on
: . 2.5.3. Superdense Coding Superdense coding is another quantum
circuit which illustrates quantum computation capabilities of
performing non-intuitive tasks: it sends the values of two
classical bits by sending only one qubit [34]. The circuit involves
two parties: Alice and Bob, each sharing one qubit of an entangled
pair. As shown in Figure 17, Alice applies some operations to her
qubit according to the values of the two classical bits she wants
to send. She then sends the qubit to Bob who then applies the and
gates to the qubits to retrieve the values of the classical bits.
Figure 17: Superdense coding circuit. At the beginning, the quantum
state, , of the system is:
42. 28 Noting that consists of two entangled qubits, one with
Alice and one with Bob. According to the values of the classical
bits, and , which we want to transmit, Alice modifies its qubit so
that undergoes one of the following transformations: if =0 and =0,
then if =1 and =0, then if =0 and =1, then if =1 and =1, then Alice
then sends her qubit to Bob. Bob applies the gate first: if =0 and
=0, then if =1 and =0, then if =0 and =1, then if =1 and =1, then
Bob then applies the gate to the first qubit: if =0 and =0, then if
=1 and =0, then if =0 and =1, then if =1 and =1, then
43. 29 Therefore, we can realize that the final state of is
equivalent to . Hence, after measurement, we retain the classical
bits and . 2.5.4. Grovers Search Algorithm The time or number of
steps needed to sequentially search for a certain number within an
ordered set of numbers is in the worst case equal to , where is the
number of elements in the sequence. In computer science, we
describe the computation complexity of such a basic search as .
However, there are search algorithms which may speed up search
within an ordered set of numbers. For example, the binary search
algorithm has a computation complexity of . On the other hand,
searching in an unordered set of numbers has a computation
complexity of , and there are no classical algorithms to optimize
searching in unordered number sets. One counterintuitive algorithm
in quantum computation, is Grovers algorithm, which can search an
unordered set of numbers with computation complexity [4]. Grovers
algorithm deals with a function : . The function, may be any
function which maps an -integer value to 0 or 1 and it does not
have any constraints, unlike Deutsch-Jozsa algorithm. Therefore,
Grovers algorithm maybe considered a generalized form of
Deutsch-Jozsa algorithm. The search problem the algorithm aims to
solve is to find the values of for which . To describe Grovers
algorithm, we need to define the following mappings on -qubit
strings: and for each . can be implemented using a circuit similar
to the one used in Deutsch-Jozsa algorithm with the help of
ancillary qubits, as shown in Figure 18. is the same as it is in
Deutsch-Jozsa algorithm and implements the transformation: .
44. 30 Figure 18: Quantum circuit implementation of . can be
implemented using a circuit which is almost identical to that of ,
except using the following transformation instead of : Its
implementation is as shown in Figure 19. All the qubits are first
inverted, and successive Toffoli gates are used to AND success
qubits and XOR the AND result with ancillary qubits. After XORing
with the qubit, Toffoli gates are used in the reverse orders to
retain the value of to each ancillary qubit, and the qubits are
re-inverted to retain their values. Grovers algorithm is simply
described as follows: 1. Initialize -qubit register, , to . Then
perform on . 2. Apply the transformation to , -times, where: and 3.
Measure and output the result.
45. 31 Figure 19: Quantum circuit implementation of . 2.6.
Quantum Computation Models At the early history of classical
computation, theoretical efforts were made to provide models of
classical computers and simulate solving problems using such
models. The most famous example is the Turing machine [35] which
was developed by Alan Turing in 1936 and later the Harvard
architecture in 1944 and von Neumann architecture [36] in 1945.
Although at the time of proposing these models, the technology and
physical implementation of classical computers were still at their
infancy, the models remain until today the theoretical basis of
classical computation. The mentioned models maybe proven
mathematically to be equivalent to each other and can also be
proven to be equivalent to modern computer architectures although
the latter is more efficient [16]. Quantum computation is following
the same steps of classical computation. Although the different
technologies of quantum computation are still in their infancies,
there are
46. 32 theoretical efforts in developing models to execute and
simulate quantum algorithms. Developing quantum computation models
is necessary for describing known quantum algorithms and for
developing new quantum algorithms. Developing quantum computation
models is also essential for designing quantum computers and
determining the required quantum components for physical
implementation. The first model is the quantum circuit model
(explained in more detail in Section 2.4). It is simply an
interconnection of quantum gates, analogous to a classical logical
circuit which is an interconnection of logical gates. Quantum
circuits usually have measurement operations at the end. Quantum
circuits can only be used to execute a pre-specified algorithm.
Knill proposed the QRAM model in 1996 [23]. Unlike the quantum
circuit model, it can model a general purpose quantum machine
capable of executing an algorithm defined at runtime. As shown in
Figure 20, the model consists of a quantum device, acting as the
slave, controlled by a classical computer, acting as the master.
The quantum device contains a number of individually addressable
quantum bits. The classical computer controls the quantum device
via classical instructions such as apply unitary transformation to
qubits and or measure qubit . The quantum device only sends
classical data to the classical computer as a result to a
measurement instruction. Classical hardware and software Code for
elementary quantum operations Results of measurements Quantum
resources (local and shared) Master Slave Logical representation of
quantum resources Physical implementation of quantum resources `
Figure 20: QRAM model. The third model which is rather theoretical
is the quantum Turing machine or the universal quantum computer
[2]. Here, measurements are never performed, and the entire
operation of the machine, which consists of a tape, head, and
finite control, is assumed to be unitary. The tape consists of
instructions and the head reads the instructions to control a
quantum device. This model is theoretically equivalent to the
previous two models [37] and is used in complexity theory rather
than in practical implementation. 2.7. Quantum Computing Languages
Quantum computing languages have been developed for several
reasons:
47. 33 to provide descriptions of quantum algorithms, to
simulate the execution of quantum algorithms on classical machines,
to be translated into machine code instructions to be executed on a
quantum computer, and to provide a paradigm or framework to think
in quantum in order to develop new quantum algorithms. There have
been many quantum programming languages whose syntax and semantics
have been proposed in literature [19]. Simulators have been
developed for some of these languages. 2.7.1. Imperative Quantum
Programming Languages An imperative programming language is a
language which allows instructions to update global variables. Most
of the classical languages we deal with (C, C++, Java, etc.) are
imperative. Early proposed quantum programming languages were
imperative. Examples of imperative quantum programming languages
are: Quantum pseudocode: proposed by Knill [23]. It is considered
an incomplete and informal language. However, it provides a set of
conventions for quantum instructions which later languages built
upon. Moreover, it is executable on the QRAM model. Quantum
Computing Language (QCL): proposed by mer [38]. It is considered a
complete formal language with semantics similar to the C language.
The basic built- in data type is qreg, which is an array of qubits.
It has built-in operations and allows the programmer to define his
operations. It has a simulation library which allows viewing the
quantum state representation of the system at any time during the
execution of a program. Q Language: proposed by Bettelli et al.
[21]. It is simply a library of classes and functions to be used
within a C++ program. It has the advantage of separating classical
and quantum parts so that classical parts are executed on a
classical processor and quantum parts are executed on a quantum
processor. Quantum Guarded Command Language (qGCL): proposed by
Zuliani [39], [40]. It is analogous to classical Guarded Command
Language, proposed by Djikstra [41], which provides statements to
prove the correctness of a program before executing it. Quantum
imperative languages can be directly executed using a machine
employing the QRAM virtual hardware model. Quantum states are
typically realized as arrays of qubits, and
48. 34 checks are needed at run-time to detect error
conditions, e.g., out-of-bounds checks for array accesses, and
distinctness checks to ensure when applying a binary quantum
operation to two qubits and . 2.7.2. Functional Quantum Programming
Languages Functional programming languages depend on functions
transforming inputs to outputs without updating global variables.
In classical computation, functional programming languages are used
for academic research rather than commercial use. Examples of
classical functional programming languages are Haskell, Erlang, and
Scheme. Data types used in functional languages (e.g., lists,
recursive types, etc.) are more compliable to compile time analysis
than data types in imperative languages (e.g., arrays). As a
result, compile-time analysis may reduce many run-time checks. In
quantum computation, functional languages have been proposed after
imperative languages. Examples of quantum functional languages
include: Quantum Programming Language (QPL) and communication
capable QPL (cQPL): proposed by Selinger [42]. They contain
commands for initializing, manipulating and measuring qubits as
well as classical computation features. cQPL is an extension to QPL
to support modeling quantum communication protocols. Quantum Lambda
Calculus: proposed by Tonder [43]. It is an extension to classical
lambda calculus [44], which is a formal system for problem solving,
with a type system based on Girards linear logic [45]. This
language is pure quantum, i.e., it does not support neither
classical data types nor measurements of qubits. Quantum functional
programming languages are useful in providing a paradigm unique to
quantum computing to help programmers think in quantum, unlike
quantum imperative languages which help programmers think in the
same way as classical computation but using qubits.
49. 35 Chapter 3 Quantum Processing Module and Integration In
this chapter, we shall discuss the internal structure of the
quantum processing module and how it can be used along with an
instruction memory to form a quantum processor. This processor can
only execute quantum algorithms which contain no classical
instructions (i.e., no if conditions, while loops, arithmetic
operations, etc.). After that, we shall explain how we integrated
this quantum processing module into a classical MIPS-R2000
processor to form MIPS-Q: a hybrid quantum computer. This chapter
shall concentrate on the model which can be later mapped to a
simulation model or to a real physical implementation. Appendix B
shows the details of providing a simulation model of the quantum
processor using VHDL. 3.1. Quantum Processor The quantum processor
follows the QRAM model (see Section 2.6), i.e. classical
instructions are used to control quantum operations. As shown in
Figure 21, it consists of: a classical instruction memory: contains
instructions, a quantum register, Q: contains N qubits, a classical
register, C: contains N classical bits each representing the
measurement result of each quantum bit of quantum register, Q, and
a qALU: executes the instructions. Instructions are structured in
the QASM format, as explained in Section 3.1.1, and are read from
the classical instruction memory and loaded into the instruction
register of the qALU, which then executes the instruction. We can
classify each instruction according to its effect on registers Q
and C: a) Qubit preparation instruction: prepares or initializes a
qubit to either or . The only instruction in this category is q
(see Table 1). It only effects the Q register since it initializes
one of the qubits to a certain value. b) Quantum gate instructions:
updates one or two qubit values by applying a gate operation on
them. The instructions in this category are X, Z, Y, H, Rk, CRk,
CNOT and SWAP (see Table 1). They only affect the Q register since
they update one or two of the qubits to a certain value.
50. 36 c) Quantum measurement instruction: measures the value
of a qubit. The only instruction in this category is MEASURE (see
Table 1). It affects both the Q register and the C register. The Q
register is updated since the qubit value collapses to either or
according to the measurement result. The C register is updated
because its classical bit corresponding to the measured qubit is
set to either 0 or 1 according to the measurement result.
qopcodeqaddress1qaddress2 qALU Q Instruction 1 Instruction 2
Instruction 3 . . . Instruction m PC Address Instruction memory / /
/ / parameter / q2q0 q1 q(N-1) C c2c0 c1 c(N-1) instructionregister
.... Figure 21: Model of the quantum processor containing:
classical instruction memory, quantum ALU, quantum register, and
classical register. 3.1.1. QASM Language Specification As shown in
Figure 22, each QASM instruction constitutes of the following
fields: qopcode: defining the required quantum operation,
parameter: used by some quantum gates to set a value of a matrix
coefficient of the matrix representation of the gate, number1: to
determine which qubit to apply the gate upon, and number2: used by
some quantum gates to determine the second qubit to apply the gate
upon.
51. 37 The sizes of the fields have been chosen to be
equivalent to the sizes of similar fields of the MIPS instruction
set (see Section 3.2.1) so that the QASM language may be integrated
with the MIPS assembly language to form a hybrid quantum
instruction set. qopcode parameter number1 number2 /-------6
bits-----/--------5 bits-------/---------5 bits------/-------5
bits--------/ Figure 22: Format of QASM instruction. Table 1 shows
the QASM instruction set, which the proposed quantum processor
model supports. The gates supported in this instruction have been
summarized in Figure 9. Note that we have also implemented the
inverse of the and gates, i.e., the and gates respectively, using
the same instruction but with a negative parameter. Appendix A
shows how the instruction set maybe implemented using the optical
physical implementation technology, which is being currently
researched. Table 1: QASM instruction set. Instruction Meaning q
val, num If val=0 qubit num to . If val=1 set qubit num to . X num
Apply gate to qubit num. Z num Apply gate to qubit num. Y num Apply
gate to qubit num. H num Apply gate to qubit num. Rk param, num If
param>=0 then apply gate with =param to qubit num. If param=0
then apply gate with =param to qubit num1 controlled by qubit num2.
If param 0b110000, I => 0b110001, X => 0b110010, Z =>
0b110011, Y => 0b110100, H => 0b110101, Rk => 0b110110,
CNOT => 0b110111, CRk => 0b111000, SWAP => 0b111001,
MEASURE => 0b111010 ); # # Main... # printf "- QASM Assembler -
Mostafa Elhoushi (2011-04-16)nn"; open(my $in, "