Sample
Sample
DING • CHONG
Synthesis Lectures on
Computer Architecture
Quantum Computer Systems
Research for Noisy Intermediate-Scale Quantum Computers
Yongshan Ding, University of Chicago
This book targets computer scientists and engineers who are familiar with concepts in
classical computer systems but are curious to learn the general architecture of quantum
computing systems. It gives a concise presentation of this new paradigm of computing from
a computer systems’ point of view without assuming any background in quantum mechanics.
As such, it is divided into two parts. The first part of the book provides a gentle overview on
the fundamental principles of the quantum theory and their implications for computing. The
second part is devoted to state-of-the-art research in designing practical quantum programs,
building a scalable software systems stack, and controlling quantum hardware components.
Most chapters end with a summary and an outlook for future directions. This book celebrates
the remarkable progress that scientists across disciplines have made in the past decades
and reveals what roles computer scientists and engineers can play to enable practical-scale
quantum computing.
About SYNTHESIS
This volume is a printed version of a work that appears in the Synthesis
Digital Library of Engineering and Computer Science. Synthesis
Synthesis Lectures on
Computer Architecture
store.morganclaypool.com
Natalie Enright Jerger & Margaret Martonosi, Series Editors
Quantum Computer Systems
Research for Noisy Intermediate-Scale
Quantum Computers
Synthesis Lectures on
Computer Architecture
Editors
Natalie Enright Jerger, University of Toronto
Margaret Martonosi, Princeton University
Founding Editor Emeritus
Mark D. Hill, University of Wisconsin, Madison
Synthesis Lectures on Computer Architecture publishes 50- to 100-page publications on topics
pertaining to the science and art of designing, analyzing, selecting and interconnecting hardware
components to create computers that meet functional, performance and cost goals. The scope will
largely follow the purview of premier computer architecture conferences, such as ISCA, HPCA,
MICRO, and ASPLOS.
Analyzing Analytics
Rajesh Bordawekar, Bob Blainey, and Ruchir Puri
2015
Customizable Computing
Yu-Ting Chen, Jason Cong, Michael Gill, Glenn Reinman, and Bingjun Xiao
2015
Die-stacking Architecture
Yuan Xie and Jishen Zhao
2015
Shared-Memory Synchronization
Michael L. Scott
2013
Multithreading Architecture
Mario Nemirovsky and Dean M. Tullsen
2013
Performance Analysis and Tuning for General Purpose Graphics Processing Units
(GPGPU)
Hyesoon Kim, Richard Vuduc, Sara Baghsorkhi, Jee Choi, and Wen-mei Hwu
2012
On-Chip Networks
Natalie Enright Jerger and Li-Shiuan Peh
2009
The Memory System: You Can’t Avoid It, You Can’t Ignore It, You Can’t Fake It
Bruce Jacob
2009
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means—electronic, mechanical, photocopy, recording, or any other except for brief quotations
in printed reviews, without the prior permission of the publisher.
DOI 10.2200/S01014ED1V01Y202005CAC051
Lecture #51
Series Editors: Natalie Enright Jerger, University of Toronto
Margaret Martonosi, Princeton University
Founding Editor Emeritus: Mark D. Hill, University of Wisconsin, Madison
Series ISSN
Print 1935-3235 Electronic 1935-3243
Cover Photo: A Noisy Intermediate-Scale Quantum (NISQ) Machine from David Schuster’s laboratory at the
University of Chicago.
Quantum Computer Systems
Research for Noisy Intermediate-Scale
Quantum Computers
Yongshan Ding
University of Chicago
Frederic T. Chong
University of Chicago
M
&C Morgan & cLaypool publishers
ABSTRACT
This book targets computer scientists and engineers who are familiar with concepts in classi-
cal computer systems but are curious to learn the general architecture of quantum computing
systems. It gives a concise presentation of this new paradigm of computing from a computer
systems’ point of view without assuming any background in quantum mechanics. As such, it is
divided into two parts. The first part of the book provides a gentle overview on the fundamental
principles of the quantum theory and their implications for computing. The second part is de-
voted to state-of-the-art research in designing practical quantum programs, building a scalable
software systems stack, and controlling quantum hardware components. Most chapters end with
a summary and an outlook for future directions. This book celebrates the remarkable progress
that scientists across disciplines have made in the past decades and reveals what roles computer
scientists and engineers can play to enable practical-scale quantum computing.
KEYWORDS
quantum computing, computer architecture, quantum compilation, quantum pro-
gramming languages, quantum algorithms, noise mitigation, error correction, qubit
implementations, classical simulation
xi
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Preface
Quantum computing is at a historic time in its development and there is a great need for research
in quantum computer systems. This book stems from a course we co-taught in 2018 and the re-
search efforts of the EPiQC NSF Expedition in Computing and others. Our goal is to provide
a broad overview of some of the emerging research areas in the development of practical com-
puting systems based upon emerging noisy intermediate-scale quantum hardware. It is our hope
that this book will encourage other researchers in the computer systems community to pursue
some of these directions and help accelerate real-world applications of quantum computing.
Despite the impressive capability of today’s digital computers, there are still some compu-
tational tasks that are beyond their reach. Remarkably, some of those tasks seem to be relatively
easy with a quantum computer. Over the past four decades or so, our understanding of the
theoretical power of quantum and skills in quantum engineering has advanced significantly.
Small-scale prototypes of progammable quantum computers are emerging from academic and
industry labs around the world. This is undoubtedly an exciting time, as we may be soon fortunate
enough to be among the first to witness the application of quantum computers on problems that
are unfeasible for today’s classical computers. What has been truly remarkable is that the field
of quantum information science has brought scientists together across disciplines—physicists,
electrical engineers, computer architects, and theorists, just to name a few.
Looking back at the historical progress in digital computers, we remark upon the three
major milestones that led to the integration of millions of computational units that make up the
computing power in today’s computers: low-cost integrated circuit technology, efficient archi-
tectural design, and interconnected software ecosystem. It is not too unrealistic to assume that
the evolution of quantum computers will follow a similar trajectory; we are starting to see some
innovations in hardware, software, and architecture designs that have the potential to scale up
well. The progress and prospect of the new paradigm of computing has motivated us to write
this Synthesis Lecture, which hopefully can bring together more and more computer scientists
and engineers to join the expedition to practical-scale quantum computation.
This introduction to quantum computer systems should primarily appeal to computer sys-
tems researchers, software engineers, and electrical engineers. The focus of this book is on sys-
tems research for noisy intermediate-scale quantum (NISQ) computers, highlighting the recent
progress and addressing the near-term challenges for realizing the computational power of QC
systems.
xvi PREFACE
Reading This Book
The aim of this book is to provide computer systems researchers and engineers with an introduc-
tory guide to the general principles and challenges in designing practical quantum computing
systems. Compared to its predecessor in the series, Quantum Computing for Computer Archi-
tects by Metodi, Faruque, and Chong [1], this book targets near-term progress and prospects of
quantum computing. Throughout the book, we emphasize how computer systems researchers
can contributes to the exciting emerging field. As such, the structure of this book is as follows.
Chapter 2 reviews the central concepts in quantum computation, compares and contrasts with
those of classical computation, and discusses the leading technologies for implementing qubits.
Chapter 3 summarizes the general features in quantum algorithms and reviews some of the
important NISQ applications.
The second part of the book starts in Chapter 4 with an overview of the quantum ar-
chitectural vertical stack and the cross-cutting themes that enable synergy among the different
disciplines in the field. The rest of the book illuminates the opportunities in quantum com-
puter systems research, broadly split into five tracks: (i) Chapter 5 describes existing quantum
programming languages and techniques for debugging and verification; (ii) Chapter 6 intro-
duces important quantum compilation methods including circuit optimization and synthesis;
(iii) Chapter 7 dives into low-level quantum controls, pulse generation, and calibration; (iv) a
number of noise mitigation and error correction techniques are reviewed in Chapter 8; (v) Chap-
ter 9 discusses different methods in classical simulations of quantum circuits and their implica-
tions; and (vi) a summary of progress and prospects of quantum computer systems research can
be found in Chapter 10.
The reader is encouraged to start with the Summary and Outlook section in some chap-
ters for a quick overview of fundamental concepts, highlights of state-of-the-art research, and
discussions of future directions.
Acknowledgments
Our views in the book are strongly informed by ideas formed from discussions with Yuri Alex-
eev, Kenneth Brown, Chris Chamberland, Isaac Chuang, Andrew Cross, Bill Fefferman, Diana
Franklin, Alexey Gorshkov, Hartmut Haeffner, Danielle Harlow, Aram Harrow, Henry Hoff-
man, Andrew Houck, Ali Javadi-Abhari, Jungsang Kim, Peter J. Love, Margaret Martonosi,
Akimasa Miyake, Chris Monroe, William Oliver, John Reppy, David Schuster, Peter Shor,
Martin Suchara, members of the EPiQC Project (Enabling Practical-scale Quantum Com-
putation, an NSF Expedition in Computing), and members of the STAQ Project (Software-
Tailored Architecture for Quantum co-design). Thanks are extended to the students who took
the 2018 course on quantum computer systems for their helpful lecture scribing notes: Anil
Bilgin, Xiaofeng Dong, Shankar G. Menon, Jean Salac, and Lefan Zhang, among others.
Thanks to Morgan & Claypool Publishers for making the publication this book possi-
ble. Many thanks to Michael Morgan, who invited us to write on the subject, for his patience
and encouragement. Thanks also to our Synthesis Lecture series editors Natalie Enright Jerger
and Margaret Martonosi, who shepherded this project to its final product. YD and FTC are
grateful to Frank Mueller and the anonymous reviewers for providing in-depth comments and
suggestions on the original manuscript. Thanks to Sara Kreiman for her thorough copyedit of
the book.
YD has learned a tremendous amount from his advisor FTC, and is very grateful for
FTC’s mentorship in quantum information science research and education. YD also thanks
Ryan O’Donnell, who first introduced him to the field of quantum computation and informa-
tion. YD worked on this book while visiting the Massachusetts Institute of Technology. YD es-
pecially thanks Isaac Chuang, Aram Harrow, and Peter Shor for the many inspiring discussions
during his visit. YD thanks all of his colleagues, friends, and relatives for their encouragement
and support in writing and finishing the book, especially Meizi Liu, and YD’s parents, Genlin
Ding and Shuowen Feng.
Finally, YD and FTC gratefully acknowledge the support from the National Science
Foundation, specifically by EPiQC, an NSF Expedition in Computing, under grants CCF-
1730449, in part by STAQ, under grant NSF Phy-1818914, and in part by DOE grants DE-
SC0020289 and DE-SC0020331.
List of Notations
The nomenclature and notations used in this book may be unfamiliar to many readers and may
have different meanings in a different context. We devote this section to clarifying some of the
conventions this book uses to prevent confusion.
Systems Terminology
• Analog quantum computing (AQC) is a model of quantum computation such that the
state of a quantum system is evolved smoothly.
• Host processor is an abstraction that refers to the classical computer that controls the
processes in quantum computer systems.
• The basis of a qubit is a set of linearly independent vectors that span the Hilbert space.
The two most common bases for single qubits are the computational basis (z basis):
1 0
fj0i ; j1ig ; ;
0 1
• A cluster state is a quantum state defined by a graph, where the nodes in the graph are
qubits initialized to jCi state, and the edges are controlled-Z gates between the qubits.
ŒM ij D ŒM j i :
p
• An EPR pair refers to two qubits in the quantum state jepri D .j00i C j11i/= 2:
• The common mapping is j0i for ground energy state, and j1i for first excited energy state.
In the context of the physical implementation of a qubit, the computational basis cor-
responds to the discrete energy levels.
• An identity matrix I is a matrix with 1 along the diagonal and 0 everywhere else.
n
!1=p
X
p
jjxjjp D jxi j :
i D1
• e M and exp.M / are notations for matrix exponential, which is defined as:
1
X 1 k
eM D M :
kŠ
kD0
• A probability distribution refers to a finite set of non-negative real numbers pi that sums
P
to 1: pi 0 and i pi D 1:
• A quantum channel is a linear mapping from one mixed state to another mixed state
! E ./:
• Quantum states are represented by (column) vectors in the Hilbert space using Dirac’s
ket vector notation:
˛
j iD :
ˇ
• The system, or wave function, of a qubit can be written as a linear combination of basis
states.
PART I
Building Blocks
3
CHAPTER 1
Introduction
Just 40 years ago, the connection between computer science and quantum mechanics was made.
For the first time, scientists thought to build a device to realize information processing and com-
putation using the extraordinary theory that governs the particles and nuclei that constitute our
universe. Since then, we find ourselves time and again amazed by the potential computing power
offered by quantum mechanics as we understand more and more about it. Some problems that
are previously thought to be intractable now have efficient solutions with a quantum computer.
This potential advantage stems from the unconventional approach that a quantum computer
uses to store and process information. Unlike traditional digital computers that represent two
states of a bit with the on and off states of a transistor switch, a quantum computer exploits its
internal states through special quantum mechanical properties such as superposition and entan-
glement. For example, a quantum bit (qubit) lives in a combination of the 0 and 1 states at the
same time. Astonishingly, these peculiar properties offer new perspectives to solving difficult
computational tasks. This chapter is dedicated to a high-level overview of the rise of quantum
computing and its disruptive impacts. More importantly, we highlight the computer scientists’
role in the endeavor to take quantum computing to practice sooner.
“If you want to make a simulation of nature, you’d better make it quantum mechanical,
and by golly it’s a wonderful problem, because it doesn’t look so easy.”
4 1. INTRODUCTION
The idea of quantum computation was made rigorous by pioneers including David
Deutsch [6, 7] and David Albert [8]. Since then, the development of quantum computing has
profoundly altered how physicists and chemists think about and use quantum mechanics. For in-
stance, by inventing new ways of encoding a quantum many-body system as qubits on a quantum
computer, we gain insights on the best quantum model for describing the electronic structure
of the system. It gives rise to interdisciplinary fields like quantum computational chemistry. As
recent experimental breakthroughs and theoretical milestones in quantum simulation are made,
we can no longer talk about how to study a quantum system without bringing quantum com-
putation to the table.
Mail Memory
(Data and Instructions) Instructions
QPU
System Controller
Figure 1.1: A QPU (quantum processor unit) and how it interacts with classical computers.
possibly conditioned on the outcomes of previous measured qubits. The key observation here
is that each measurement equivalently accomplishes a quantum gate due to gate teleportation.
The output of the computation is the measurement bit-string outcome and the remaining state
of the qubits that are not measured. It is shown that this is a universal quantum computation
model.
Our focus of the book is on the gate-based model; we present the other models of com-
putation here for completeness, but details of the models are out of the scope of this book.
Figure 1.2: Architectural designs of classical vs. quantum computers. The abstraction layers for
1950s classical computing, today’s classical computing, and quantum computing are compared.
puter. In fact, classical processing and classical control play vital roles in quantum computing.
On one hand, a quantum algorithm generally involves classical pre- or post-processing. On the
other hand, efficient classical controls are needed for running the algorithm on hardware. As
such, a better way of regarding the QC hardware is as a co-processor or an accelerator, that is a
QPU, as opposed to direct replacements of classical computers.
Figure 1.3: Quantum computation is one of the promising technologies made for harnessing
the power of quantum systems.
The control complexity becomes overwhelming as the number of qubits scale up, necessitating
system-level automation to guarantee the successful execution of quantum programs [33]. As
such, classical computers are needed to control and assist the quantum processor. Quantum
computers are generally viewed as co-processors or accelerators of classical computers, as shown
in Figure 1.1.
To some extent, the quantum computer architecture illustrated above arguably resembles
in-memory processing or reconfigurable computing architectures. As shown in Figure 1.1, inside
a QPU, quantum data are implemented by physical (quantum mechanical) objects such as atoms
while quantum gates are control signals such as lasers acting on the data—this “gates-go-to-data”
model of computation motivates a control unit close to the quantum data and an interface that
talks frequently with the quantum memory and the classical memory.
Figure 1.4: Status of qubit technologies [57–67]. Also drawn the gap between algorithms and
realistic machines. Breaking abstractions via software-hardware co-design will be key in closing
this gap for NISQ computers, hence the overarching theme of this book.
The key to quantum computation is that every additional qubit doubles the computational
space in which the quantum machines operate. However, this extraordinary computing power
is far from fully realized with today’s technology, as the quantum machines will have high error
rates for some time to come. Ideally in the long term, we would use the remarkable theory of
quantum error correction codes to support error-free quantum computations. The idea of error
correction is to use redundancy encoding, i.e., grouping many physical qubits to represent a sin-
gle, fault-tolerant qubit. As a consequence, a 100 qubit machine can only support, for example,
3–5 usable logical qubits. Until qubit resources become much larger, another practical approach
would be to explore error-tolerant algorithms and use lightweight error-mitigation techniques
in the near term. So NISQ machines imply living with errors and exploring the effects of noise
on the performance and correctness of quantum algorithms.
CHAPTER 2
Boolean Circuits
A number of classical models of computation are developed to describe the components of a
computer necessary to compute a mathematical function. Some familiar ones include the Turing
machine model (sequential description), the lambda calculus model (functional description), etc. In
this section, we choose to review the Boolean circuit model of computation, which is considered
the easiest to extend to the theory of quantum computing. These models, although expressing
computability and complexity from different perspectives, are in fact equivalent. Specifically,
every function computable by an n input Boolean circuit is also computable by a Turing ma-
14 2. THINK QUANTUMLY ABOUT COMPUTING
x1
x2 f (x1, x2) = x1 ⊕ x2
Figure 2.1: A Boolean circuit implementing the XOR function using a NAND gate, an OR gate,
and an AND gate. Lines are wires that transmit signals, and shaped boxes are gates. Signals are
copied/duplicated where wires split into two.
chine of length-n inputs, and vice versa. The size of a circuit, defined by the number of gates it
uses, is closely related to the running time of a Turing machine.
In a classical digital computer (under the Boolean circuit model), information is stored
and manipulated in bits—strings of zeros and ones, such as 10011101. The two states of each
bit in the string are represented in the computer by a two-level system, such as charge (1) or no
charge (0) in a memory cell (for storing) and high (1) or low (0) voltage signal in a circuit wire
(for transmitting).
In the “bra-ket” notation invented by Paul Dirac in 1939, the state of a bit is denoted by the
symbol, ji. So, the two-level system can be written as j0i and j1i, or j"i and j#i, or jchargei and
jno chargei, etc. The above length-8 bit string can thus be written as j1i j0i j0i j1i j1i j1i j0i j1i,
or j10011101i for short. Why is this called the “bra-ket” notation? In fact, ji is called the “ket”
symbol and hj is called the “bra” symbol, and together they form a bracket hji. Later, we will
see in the linear algebra representation of quantum bits, they correspond to column vectors and
row vectors, respectively. For now, the reader may regard this notation as pure symbolism—its
advantages will be clear once we discuss operations of quantum bits.
Any computation can be realized as a circuit of Boolean logic gates. For example, the follow-
ing is a circuit diagram for computing the XOR function of two input bits: f .x1 ; x2 / D x1 ˚ x2
(Figure 2.1).
In this classical Boolean circuit, lines are “wires” that transmit signals, and boxes are “gates”
that transform the signals. Signals are copied/duplicated at places where wires split into two. The
above shows one possible implementation of the XOR function with AND, OR, and NAND
gates. It is well known that the NAND gate, along with duplication of wires and use of ancilla
bits (i.e., ancillary input bits typically initialized to 0), is universal for computation. In other
words, any Boolean function is computable by “wiring together” a number of NAND gates.
The Boolean circuit model is a useful theoretical tool for analyzing what functions can be
efficiently implemented. It is also a convenient tool for computer architects and electrical engi-
neers as it is close to the physical realization of today’s computers. The von Neumann architecture
is one example of a design of modern computers.
2.1. BITS VS. QUBITS 15
von Neumann
Architecture
Registers
Memory Unit
Reversible Computation
The study of reversible computing originally arises from the motivation to improve the com-
putational energy efficiency in the 1960s and 1970s led by Laundauer [73] and Bennet [74].
Quantum computers transform quantum bits reversibly (except for initialization and measure-
ment). The connection between reversible computation and quantum mechanics was discovered
by Benioff in the 1980s [2]. As a result, QC benefits a great deal from the study of reversible
computing, and vice versa. Later, we will see the roles of reversible computing in quantum cir-
cuits.
According to the second law of thermodynamics, an irreversible bit operation, such as the
OR gate, must dissipate energy, typically in the form of heat. Specifically, suppose the output
of an OR gate is j1i. We cannot infer what the inputs were—they could be anything from j01i,
j10i, or j11i. The von Neumann–Landauer limit states that kT ln.2/ energy is dissipated per ir-
reversible bit operation. However, some bit operations are theoretically (logically) “reversible”—
in the sense of that the output state uniquely determines the input state of the operation. For
example, the NOT gate is reversible. Flipping the state of a bit from j0i to j1i, or vice versa,
does not create or erase information from the system. To some extent, reversible also means
time-reversible—the transformation done by a reversible circuit can be reverted by applying the
inverse transformation (which always exists).
One could imagine a computer can be built consisting solely of reversible operations. In
analogy to the NAND gate being universal for Boolean logic, is there a reversible gate set that
is universal? The answer is yes. To illustrate this, we introduce three example reversible gates:
the NOT gate, the CNOT (controlled-not) gate, and the Toffoli (controlled-controlled-not)
gate, all of which are self-inverse (i.e., applying the gate twice returns the bits to their original
state). Their Boolean circuit notations and truth-tables can be found in Table 2.1. Specifically,
the NOT gate negates the state of the input bits. The CNOT gate is a conditional gate—the
state of the target bit x2 is flipped if the control bit x1 is j1i. It is the reversible version of the
XOR gate. The Toffoli gate has two control bits, x1 and x2 , and one target bit x3 . Similarly, the
target bit is flipped if both the control bits are j1i. It is particularly handy as it can be used to
simulate the NAND gate and the DUPE gate (with the use of ancillas), and thus is a universal
reversible gate.
More formally, we note that the Toffoli gate is universal, in that any (possibly non-
reversible) Boolean logic can be simulated with a circuit consisting solely of Toffoli gates, given
2.1. BITS VS. QUBITS 17
Table 2.1: Reversible logic gates. The truth table of reversible logic gates shows the permutation
of bits. Toffoli is universal reversible computation.
that ancilla inputs and garbage outputs are allowed. Proof of this theorem is omitted here. As
such, a generic reversible circuit has the form shown in Figure 2.3.
In this circuit, a Boolean function f W f0; 1gn 7! f0; 1gm is computed reversibly using only
Toffoli gates. All ancilla inputs are initialized to j1i (if needed, j0i ancilla can be produced as
well, because a Toffoli gate on j111i gives j110i). All garbage bits will be discarded at the end
of the circuit.
One cannot overemphasize the above theorem’s implication to quantum computing—as
noted before, a quantum computer transforms quantum bits reversibly, so this theorem implies
that any Boolean circuit can be transformed into a reversible one, and then a quantum one by
implementing a quantum Toffoli gate and replacing each bit with a quantum bit. Reversible
circuit synthesis is a useful tool in designing quantum circuits.
18 2. THINK QUANTUMLY ABOUT COMPUTING
x1 f (x)1
x2 Output
…
Input
f (x)m
…
xn Toffoli Gates
|1
Garbage
Ancilla
…
|1
Figure 2.3: A generic reversible circuit for implementing a possibly irreversible function f W
f0; 1gn ! f0; 1gm .
Randomized Computation
So far, we have not discussed one familiar ingredient to the computation that appears commonly
in classical computing—randomness. Many natural processes exhibit unpredictable behavior,
and we should be able to take advantage of this unpredictability in computation and algorithms.
The notion of probabilistic computation seems realistic and necessary. On one hand, the physi-
cal world contains randomness, as commonly seen in quantum mechanics. On the other hand,
we can propose several computational problems that we do not yet know how to solve efficiently
without randomness. If BPP=P, however (i.e., the complexity class bounded-error probabilistic
polynomial time is equivalent to the class deterministic polynomial time), as some believe, then
randomness is unnecessary and we can simulate randomized algorithms as efficiently with de-
terministic ones. Nonetheless, randomness is still an essential tool in modeling and analyzing
the physical world. We can find many examples where randomness is useful: in economics, it is
well known that Nash equilibrium always exists if players can have probabilistic strategies, and
in cryptography, a secret key typically relies on the uncertainty in itself.
Randomness as a resource is typically used in computation in the following two forms:
(i) an algorithm can take random inputs; and (ii) an algorithm is allowed to make random
choices. As such, we introduce the notion of random bits and coin flips, again in the “bra-ket”
and circuit notations.
Suppose x1 is a random bit, and the state of x1 is j0i with probability 12 and j1i with
probability 21 , denoted as:
1 1
jx1 i D j0i C j1i :
2 2
For now, this notation may look strange and cumbersome, but the benefit of writing the
state of a bit this way will become clear when we generalize to the quantum setting. The state is
called a probability distribution of j0i and j1i. To describe a general n-bit probabilistic system,
2.1. BITS VS. QUBITS 19
we write down the underlying state of the system as:
X
pb jbi ;
b2f0;1gn
where b is any possible length-n bit-string, and pb is called the probability of b . By basic prin-
ciples of probability, all pb values must be non-negative and summing to 1.
In reality, the physical system is in one of those possible state. When we execute a ran-
domized algorithm, we expect to observe (sample) the outcome at the end. From the observer’s
perspective, the values of the random bits are uncertain (hidden) until they are observed. Once
some of the random bits in the system are observed, then the state of the system (to the observer’s
knowledge) is changed to reflect what was just learned, following laws of conditional probability.
For example, a random system can be described with:
1 1 5
jx1 x2 i D j00i C j01i C j10i C 0 j11i :
8 4 8
Now suppose it is observed that the first bit is j0i (the probability of this scenario is
PrŒx1 D 0 D 81 C 14 D 38 ). The state of the system after the observation is then conditioned
on our observation:
1=8 1=4 1 2
jx1 x2 i .given x1 D 0/ D j00i C j01i D j00i C j01i :
3=8 3=8 3 3
Here the bit-strings inconsistent with the outcome are eliminated, and the remaining ones
are renormalized.
In a randomized algorithm, we typically allow that (i) it is correct with high probability,
or (ii) it does not always run in desired time. Some of the uncertainty comes from its ability
to make decisions based on the outcome of a coin flip. Now suppose we have implemented a
conditional-coin-flip gate, named CCOIN: CCOIN . When the input bit is j0i, CCOIN
does nothing. When the input is j1i, CCOIN tosses a fair coin:
(
j0i 7! j0i ;
CCOIN D
j1i 7! 21 j0i C 21 j1i :
Suppose we have a random program that reads: (1) Initialize a bit to x1 D j1i. (2) Flip a
fair coin if x1 is j1i and write result to x1 . (3) Repeat step 2. In terms of a circuit, the program
looks like:
x1 W j1i CCOIN CCOIN
One is interested in observing the outcome at the end of the program. Let’s analyze the
circuit step by step. After the first CCOIN gate, jx1 i is set to j0i and j1i with equal probability
(i.e., jx1 i D 12 j0i C 12 j1i). After the second CCOIN gate, the state becomes jx1 i D 12 j0i C
1 1
. j0i C 12 j1i/ D 34 j0i C 14 j1i. It is convenient to write the above process in a state transition
2 2
diagram:
Ccoin-diagram
20 2. THINK QUANTUMLY ABOUT COMPUTING
1 1
1 |0⟩ |0⟩
2
2
|1⟩ 1 1
|0⟩ 3 1
2 4 |0⟩ + |1⟩
4 4
1
|1⟩
2
1 1
2 |1⟩
4
The following is a slightly larger circuit, where a CNOT gate correlates the two bits.
x1 W j1i CCOIN
x2 W j1i CCOIN
The system is initialized in j11i. After the first CCOIN gate, the system is put into a ran-
dom state: 12 j01i C 12 j11i. The CNOT gate then transforms the system to 12 j01i C 21 j10i, cor-
relating the two bits. And finally after the second CCOIN gate: jx1 x2 i D 12 . 12 j00i C 21 j01i/ C
1
2
j10i D 41 j00i C 14 j01i C 12 j10i. Again with a state transition diagram:
Ccoin-diagram2
1 1
|00⟩
2 4
1
1 |01⟩ |01⟩
2 1 1 1 1 1
|01⟩ |00⟩ + |01⟩ + |10⟩
2 4 4 4 2
|11⟩
1 1 1 1
|11⟩ |10⟩ |10⟩
2 2
where the coefficient ˛b is called the amplitude (as opposed to probability) of the basis bit-string
b . Just like probabilities, the amplitudes have two constraints: (i) they can take any complex
P
numbers; and (ii) their sum of squared values is 1: b2f0;1gn j˛b j2 D 1. In the context of qubits,
the probability distribution across bit-strings is called the superposition of all bit-strings; the cor-
relation between bits is called entanglement of qubits. It is important to note that these are not
renamings of the same concepts1 —as random bits and quantum bits are fundamentally differ-
ent objects. Despite the striking parallelism between the two, we should always be wary of the
subtleties that differentiate them when analyzing a random circuit vs. a quantum circuit.
To measure (observe) the outcome of a qubit, we follow almost exactly what we did with
a random bit. For an n-qubit system, if we measure all qubits at the end of a circuit,2 then from
P
j i D b2f0;1gn ˛b jbi, we observe the bit-string jbi with probability j˛b j2 . Upon measure-
ment, the state of the system “collapses” to the single classical definite value: Meas.j i/ D jbi,
and can no longer revert to the superposition as it was before. For example, the superposition
state j i D p1 j0i C p1 j1i yields, upon measurement, either outcome with equal probability:
2 2
PrŒMeas.j i/ D j0i D PrŒMeas.j i/ D j1i D 12 .
One operation that is of fundamental importance to quantum computation is called the
Hadamard transformation, a single-qubit quantum gate denoted as H in the circuit model:
8
<j0i 7! p1 j0i C p1 j1i ;
2 2
HD
:j1i 7! p1 j0i p1 j1i :
2 2
It turns out that allowing Hadamard gates in a reversible circuit (consisting of Toffoli gates)
extends the circuit model over to any functions allowed to be computed on qubits (up to global
phase). For this reason, H gate together with Toffoli gate are universal for quantum computation.
Note that it does not mean that Nature allows only Hadamard and Toffoli transformations
on qubits—as we will see in later sections, the laws of quantum mechanics allow a class of
transformations, called unitary transformations.
One would argue that any interesting quantum mechanics phenomenon can be explained
by interference. Unlike probability values that are always non-negative, amplitudes (as being pos-
sibly negative) can either accumulate and cancel. When two amplitudes accumulate, we say they
1 Many believed that quantum mechanics has deterministic explanations, notably by the argument from EPR paradox (by
Einstein, Podolsky, and Rosen in 1935 [75]) and other hidden-variable theories which try to equalize statistical correlation
with entanglement. But later in 1964, John Bell famously showed Bell’s theorem [76] that disproved the existence of local
hidden variables of some types.
2 This is a reasonable assumption by the law of deferred measurement.
22 2. THINK QUANTUMLY ABOUT COMPUTING
interfere constructively; when they cancel each other out, we say they interfere destructively. The
example circuit below illustrates this phenomenon:
x1 W j0i H H
As usual, let’s analyze the circuit step by step. After the first H gate, jx1 i is set to
a superposition state jx1 i D p12 j0i C p12 j1i). After the second H gate, the state becomes
jx1 i D p1 . p1 j0i C p1 j1i/ C p1 . p1 j0i p1 j1i/ D j0i. Note that in this circuit, amplitudes
2 2 2 2 2 2
of j1i cancel each other out (destructively interfere), while those of j0i accumulate (constructively
interfere).
Again we track the state of the qubits as the circuit runs (from left to right), using a tran-
sition diagram. In the context of qubit states, the diagram is called the Feynman Path diagram,
hadamard-diagram
named after physicist Richard Feynman:
1 1
|0⟩
2 2
1 |0⟩
2 1 1
|1⟩
2 2
|0⟩ |0⟩
1 1
|0⟩
1 2 2
2 |1⟩
1 1
|1⟩ −
2 2
In this diagram, the state of the qubits also evolves from left to right.