[MUSIC PLAYING]
MASOUD MOHSENI: Good
evening, everyone.
I'm Masoud Mohseni, research
scientist at Google Quantum AI
Lab.
I would like to thank the
organizers for invitation,
and making this livestream
presentation happening today.
Today I'm going to announce the
launch of TensorFlow Quantum,
which is an open source
framework for a quantum
machine learning.
I would like to mention
that, in this talk,
I do not assume any background
in quantum physics or quantum
computing.
I would like to start with
a famous quote from Richard
Feynman that he made in
1982 that is considered
as the first deep observation on
computational power of quantum
systems.
He said that "Nature
isn't classical, dammit."
So "If you want to make
a simulation of nature,
you better make it
quantum mechanical."
So of course we should note
that machine learning is not
about exactly
simulating systems,
but has the ability to
learn a model of systems,
and predict systems behavior.
So I would like to
rephrase Feynman's quote
as, nature isn't
classical, dammit,
so if you want to make
a model of nature,
or learn a model of
nature, you better
make a quantum mechanical.
So with that in mind, we
developed TensorFlow Quantum
basically as toolbox to
model nature and also
artificial quantum systems.
So what are the main
objectives for TF Quantum?
The first one is the
software framework
for hybrid quantum
classical machine learning
under TensorFlow and Cirq.
And it allows a
researcher to perform fast
prototyping, training,
inference, and testing
of quantum models for
quantum data, which
can reduce the prototyping
time from weeks to hours.
Also it can help
machine learning
and quantum computing researcher
to discover new algorithms
for near-term
devices, or ultimately
for fault-tolerant
quantum computers
once they become available.
So for people who have no
background in quantum physics,
I would like to
make an introduction
to quantum mechanics, quantum
computing, and quantum machine
learning in just one slide.
So are you ready?
So this is the setting
that we want to discuss.
This is known as a
double-slit experiment.
And it's at the heart of
the quantum mechanics.
So let's consider that
you have a ball machine.
If you play tennis,
you know how it works.
You can set it up to
send random balls.
And if you have a ball with two
slits so that some of the balls
cannot go through the slits,
and you have another wall
or a screen that you can detect
where these balls are hitting.
So what are your expectations
of the probability distribution
that balls can hit the screen?
So there are two
possibilities-- balls
going from the top
correspond to orange slit.
And you see a curve, a
bump, corresponding to that.
And there is another one for
if they go through bottom slit.
And the joint or
probability distribution
is just summing
over all two events.
That's all you need to do.
So what happens if the
source for these particles
is quantum mechanical?
So assume, if you have electron
grounds that sends electrons,
or if you have a
laser to send photons,
these are the particle of light.
And if you have a
double slit setting--
and now our slits are
obviously made smaller--
and then you have a screen.
And you want to see where
these particles are hitting.
And now you can
see that there is
going to be an
interference pattern
emerging that is very bizarre.
So here instead of that
Gaussian distribution right
in front of each slit, you
have this interference pattern,
that sometimes even right
in front of this slit,
there is zero chance
of getting a particle.
And so this was very
positive for physicists
back more than 100 years.
Until they realized actually
there was a quick fix to this.
All you need to do
is just generalize
their classical property
distributions to quantum.
And for that, you just
attribute a property amplitude
instead of a property.
And then that's
a complex number.
And so for treatment, you have
to just add them up, and then
square them.
And when you square, there is
a new term appearing. instead
of, like, the properties of
getting through the slit, top
or bottom, there is
interference then.
This is the third term.
And this is related
to the relative phase
between these events.
And you can manipulate these.
And by manipulation
of that, basically you
can do computation.
That's the core idea
[INAUDIBLE] quantum computing.
And how do you do that?
You place a stack of the walls
at various different distances.
And you place the slit at
various different locations.
And you set it up to sample
from a property distribution.
So you create a constructive
interference pattern
to generate distributions
that is the desired outcome.
Now, that basically
is quantum computing.
So congratulations.
You've learned how
quantum computation works.
So let's look at a
specific example that's
pretty interesting.
If you have random walls
separated in different places,
and random slits
located in these walls,
you get a fancy property
distribution that
is known as a Porter-Thomas.
It means that you
have, basically,
a quantum chaotic system.
And sampling from the
distribution of the system
is exponentially
hard classically.
And this was at the heart of
the quantum supremacy experiment
that we announced last year.
Basically, this is the rich
computational setting already.
Of course that particular
setting is not a scalable,
but that's a technical detail.
All I want to say is that
you can basically even set up
a quantum machine
learning now on this.
So how do we do that?
We parameterize
this arrangement.
So we allocate or
attribute parameters
to each slit's
location, and then try
to learn to generate a
desired output property
distribution function,
or iteratively learn
to create a set
of solutions that
are the correct solution
to a computational problem.
And that's at the heart of
the quantum machine learning.
So you just basically
learn all the concepts
I want to introduce
in this talk.
Except this setting
is not scalable.
So the rest of talk is about
scalable implementation,
and how we can code
it over TensorFlow.
So to push the analogy
a little bit further,
you have to think about
generating or engineering
these interference patterns is
like generating sound waves.
It's like you are composing
and then playing music.
And so there are
certain strings.
And the strings
here becomes qubits.
And instead of the note,
you have quantum gates.
Here is like a 2-qubit
gate illustrated here.
And instead of the
musical instruments,
you have this controlled
microwave electronics,
where you can generate
electrical waves that generates
this property distributions
that correspond
to the very nature
of the particles.
So we did this at Google.
So over past five,
six years, we have
developed this
superconducting technologies
that you can fabricate
these qubits at this scale.
And so this is a
particular picture
of a 1D arrangement of this
superconducting [INAUDIBLE]
is that it could be a ring.
And there is a pair
of electrons that--
it's a current in
that qubit that
can go either clockwise
or counterclockwise.
But when it's
quantum mechanical,
it can be in superposition
of both direction,
and goes in both way.
And this is like the
particle going through two
slits at the same time.
And you can control it here
with the electrical gate.
And this has to be
low enough temperature
for this superposition
to happen that's
below a critical temperature
of superconductivity.
That's the reason we place it in
a dilution refrigerator at 100
millikelvin.
So we use that device
with a 53 qubit processor
to set a random quantum
gate, and showing
that it's very hard to
sample them classically.
So let's back up a
little bit and see
what are these quantum bits?
Quantum bits, basically, you
can place and present them
as a vector in a [INAUDIBLE].
So basically if you
consider this as a globe,
if it's a classical
bit, it's either
pointing at north
pole or south pole.
For a quantum bit, it can
be any point on this globe.
So there are certain
properties of classical bits
that you can always--
they always have
a value of 0 or 1.
It can't be copied.
Their state doesn't change.
If they're measured.
And measuring one bit doesn't
affect on measured bits.
And none of them
actually, in general,
works for quantum bits.
So the challenge is
how we can actually
manipulate quantum
information, and how
we can do quantum computation.
So in order to do that, you can
build arbitrary single-qubit
operation by just rotations
around two fixed accesses.
And this can make
a rotation anywhere
in that globe basically.
And to do orbital universal
quantum computation, all
you need to add is to add a
single non-trivial two-qubit
operation, which is
like [INAUDIBLE]..
That means that if
the first bit is 1,
the second one is flipped.
And understanding
quantum circuit
as like composing
music, it's like there
are these different strings
correspond to qubits.
So they're place in a space.
And in time, you plan the kind
of things, operations, you do,
which has various different
single or two-qubit rotation.
At the end, you
just measure them
to create classical
property distributions.
And that always
means, for each bit,
it's either 1 or 0,
like classical bits.
The thing is that these
outcomes are normalized.
So they sum to 1.
So what is the landscape of
near-term quantum computing
today with this
kind of technology?
So basically, right now, to
quantify computational power
of this system, you
have to consider
two index-- one is the number
of qubits, one the quality
of the qubits.
So to have maximum
computational power,
you need to have high-quality
qubits, a lot of them.
So in that shaded purple
area, if you're there,
it means that there-- above
the dashed line, basically,
things are not interesting.
Because although you
have a lot of qubits,
they can be simulated
classically, basically,
because the state of the
quantum computer is localized.
So it does not have
this exponential power
built into it.
So below that dashed line
where, actually, on Sycamore,
we observe this
quantum supremacy,
things becomes interesting.
But to have fault-tolerant
quantum computer,
you need on the order
of millions of qubits,
and tens of millions,
to do like something
like Shor's algorithm, that you
can use it to basically decode
crypto system.
And its for factoring large
numbers, two-prime factors.
But that's kind of
[INAUDIBLE] extreme points.
In near term
quantum devices, you
can actually think about on
the order of tens of thousands
of qubits.
I see there are potential
opportunities to do something
interesting, like
quantum machine learning,
that cannot be classically
done, especially when you want
to analyze or
distill quantum data.
And this is where
TensorFlow Quantum
comes in as a tool box in this
area that was not available.
And we are introducing
it this week.
So how can we machine learning
over these parameterized
quantum circuits?
So to see a particular
analogy, you
have to notice
that when you print
this kind of unitary
operations or random rotations
in a space-time
volume that you have,
this is a kind of continuous
parameterized rotation
which mimics kind of
classical circuits
like deep neural networks that
map certain input to output.
So that's a reason for the
term, quantum neural networks,
that you might have heard.
But how do we create these
parameterized quantum circuits?
Let's look at a
concrete example.
So we use, here, Cirq.
This is a tool box
introduced by a our team
for simulation of
a quantum circuit.
So we import cirq,
we import sympy.
And next we write a
parameterized quantum circuit
for this particular processor
on the right, which is Sycamore.
Which is basically the
Cirq here, in this setting,
is acting as a quantum
computing assembly language.
We will use SymPy for
adding symbolic parameters
to our circuit.
We define a qubit
for our circuit using
the Cirq's GridQuibit
command, which places
a qubit on the corner here.
This command can
takes coordinates
of qubits on the grid.
We place on the corner
at 0, 0 coordinate.
And then we can try to
build a simple model.
What would be that
simple model--
it's a parameterized quantum
circuit with one gate,
using cirq.cirq.
And then it's just a
rotation by an angle theta
about some y-axis of the qubit.
To simulate the
circuit, we actually
need to attribute values
to this symbol data.
This can be done by
Cirq parameter resolver.
And then we pass the
circuit to a Cirq simulator
object that can obtain the
resulting output vector.
So the output is actually a
vector that just spit it out.
Now all we need to do to get the
classical values from this wave
function is to
define a measurement.
Here we choose a
standard policy operator
which measures if
the qubit is 0 or 1.
The expectation value
of the measurement
is obtained by calling the
expectation from wave function
command on the simulator output.
So how can we do
machine learning
on this finite space-time
that we have available?
So that was an introduction
to Cirq to just set up
a parameterized model.
But you have to notice, for
quantum machine learning,
this should upload the data.
Basically we have to
prepare it on the fly.
This is the first
part of a circuit.
This is a 2D array
that we can see
that first part
is like basically
generating the data on the fly.
And second one is the parameter.
Cirq has to try to
learn it iteratively
using measurement outcomes.
So I mentioned quantum data.
One might ask, what are
the possible sources
of quantum data?
Basically, whenever you
have a quantum computer,
the output states of a quantum
computer is quantum data.
So you can use quantum machine
learning for verification,
doing inference
over that output,
and discovering new algorithms.
In particular, for simulation
of chemical systems
or simulation of quantum
many-body systems,
in particular value when
we have this quantum
matter near a quantum
critical point,
the entanglement or
these correlations
diverges exponentially.
And so it becomes very hard to
simulate them at that point.
So what are the other cases?
Our quantum communication
networks, basically,
and quantum repeaters, quantum
receivers, purification unit.
Basically when you have data
and communication networks,
the networks are noisy, and
you have to distill and improve
the quality.
And you can machine learn that.
You can improve
quantum metrology,
which is like sensing
imaging, basically
a high-performance measurement.
Or also control quantum devices.
This is important
for near-term devices
to avoid or mitigate errors.
The simplest possible
case for quantum data
is just for a single qubit.
Basically you can have
two clouds of data.
The blue and orange
correspond to two
vectors pointing at
different directions.
But the things could be noisy.
So when you have a data set,
it could be at any point
near to that direction,
but not exactly there.
So the question is that, if
someone gives you that data,
can you do a binary
classification.
And this is the examples.
The hello world examples, I'm
going to walk through it today.
So as a concrete algorithm-- for
doing quantum machine learning,
there's variational
quantum algorithms.
Basically here we have two
different core processor, a CPU
and QPU, that talk
to each other.
What happens that
QPU, you run it,
you collect some classical
distributional data,
and just pass it to CPU
to come up with better
suggestion for the parameters.
And you do this
iteratively to converge.
And this is basically the
iterative quantum classical
optimization.
But you can do more
interesting stuff.
Why not just combine quantum
classical deep neural networks
to be hybrid models?
Here you use the best of
both models to increase--
develop richer representation
to capture some unknown data.
And also you can
improve generalization.
But how do we do that?
We know already TensorFlow is
one of the most-used machine
learning platforms.
And Cirq is also one of
the widely-used circuit
simulator for quantum circuits.
Can we combine them, and what
are the challenges for that?
Once you start to looking
into this problem,
you realize there are
certain technical hurdles.
For example, quantum
data cannot be imported.
So you have to
generate it on the fly.
And also you need to have
both data on the models are
layers in this quantum circuit.
And you have to
basically have it
ready to be at this highly
non-trivial computational graph
that are dynamic.
So the other hurdle is that
you need to pass this quantum
program to a QPU at one time.
So you cannot just do
computational graph,
do measurements,
and just pass it.
Every time there
is a delay, there
is latency between QPU
and CPU, because QPU
works at a few microseconds,
including measurement.
And there are other issues
with sending batches of jobs
to realize many parallelized
quantum circuits.
And considering
all those hurdles,
we arrived at four
design principles.
First, we have to
support differentiation
of quantum circuits and
hybrid back propagation
if you want to
build hybrid models.
Also, the circuit
batching, which is we
mean that we have to be
able to generate quantum
data on the fly, and train
over so many different quantum
circuits in parallel.
Also there is a issue that we
need to be backend agnostic.
But it means that we should be
able to switch from a simulator
to a real device
with few changes.
So especially for theorists,
so they can try a lot,
and then they can
compare their simulation
against an actual
hardware real output.
So the final principle is
the minimalistic nature
of our approach is that we want
to build a bridge between Cirq
and TF, not necessarily
to reinvent the wheel.
So we don't want to
force the developer
to learn new tool
box that is so much
different from TF and Cirq.
So with that, we arrived at
this software architecture.
It's basically very simple.
We map everything to Tensor.
And then we use this kind of
ops on TensorFlow framework
to calculate classical property
distributions for the output.
So basically here you
can see an example
that a circuit can
become a tensor.
The parameters I've describe
[INAUDIBLE] quantum circuits
is a tensor, or
polyoperators are tensors.
And also we can have,
from some ancestry nodes,
getting some particular
suggestion for the parameter's
value to instantiate that, and
then becomes the operations
that you calculate
the expectations.
And then you can feed
forward it to other nodes
in the computational
[INAUDIBLE]..
So with that, we can look at
the software stack as a whole.
So at the user interface,
there are two sets of data.
Data could be
classical or quantum.
So the TF Quantum now
supports quantum data.
But the interesting thing is
that quantum data, as I said,
it's like either
circuits or operators.
But you can map
everything to tensors,
and then use in
standard TF layer.
TFQ has high-level layers
that you can manipulate them.
So below that, you can see these
TFQ layers and differentiators.
And just below that is that
is the TFQ ops, that they
can run a simulator
like Cirq, or this more
high-performance simulator that
we just launched this week,
known as qsim.
Or you can run it on actual
hardware, which is QPU.
The classical part of the model
can be run on CPU, GPU, or TPU,
as a standard TF, basically,
framework allows you to do.
So to see a particular
concrete suggestion
to understand how this
framework works is
like looking at the pipeline for
a hybrid discriminative model.
Here you can see the interaction
between different parts,
like quantum data
preparation and evaluation
of quantum models.
And then once you
measure it, then the data
becomes classical.
Then you can feed it forward
for further post-processing
by a classical neural network.
And then you can measure
cost on cost function,
and feed it back to
improve the parameter.
Now you can improve
the parameter
of both quantum model and
the classical neural network.
And this is basically the
nature of the hybrid model.
So with that, we are not ready
to do a hello many worlds
example.
So this notion of
many worlds, this
comes from an interpretation
of quantum mechanics known
as many world interpretation.
And I have not necessarily
identified with that.
But this is kind of
an interesting way
of looking the simplest
possible case for analyzing
quantum data.
It would be a binary
classification
for a single qubit.
So how can we do that?
So here, again, as before,
we import Cirq and SymPy,
and place qubit on the grid.
We also import NumPy,
TensorFlow, and TFQ packages.
The first to do is setting
up the labels and parameters
for preparation of
our quantum data.
And then, for simplicity here,
we classify just two data
points, A and B, correspond to
two vectors on the [INAUDIBLE]..
Then we can compare
these vectors to tensors.
And with that, we can have--
we already generated
our quantum data.
Now we need to build
our hybrid classifier.
And in order to do that, we
apply a core TFQ functionality.
And that ables us to
have an easy integration
with TensorFlow.
So the data inputs
to our hybrid model
can be specified using
standard class input object.
The quantum portion
of our model begins
with a parameterized
rotation about the y-axis.
And then our hybrid
model will land
to discriminate to their
states by optimizing the theta
parameter.
To calculate a loss function,
to basically learn this,
we need to convert
the quantum states
into classical information.
We can do this by making a
measurement along the axis.
And we embed our quantum
model and measurement
into a class model.
We use the TFQ PQC layer.
And this layer enhanced from
the TF [INAUDIBLE] layer as--
so it's compatible
with Keras API.
For the last stage
of the classifier,
we attached to basically
[INAUDIBLE] layer
with softmax activation.
And then the layers are
ready to basically use it
automation [INAUDIBLE] to
predict the probabilities
that the input data point is
either from class A or class B.
To train the model, we wrap our
classical and quantum layers
in a Keras model.
The weights in the
dense classical layer
and the parameters
in the quantum models
have both updated
using item optimizer,
with the loss defined with
categorical cross-entropy.
We see that the loss is
quickly driven towards 0
during their training.
Now we can apply this classifier
that we build for distribution
of the quantum data
for the single qubit
that I've mentioned.
So we can give this model
quantum data points perturbed
from training data points to--
to see if this model
can actually generalize.
Because actually, that
example was a bit artificial
in a sense of a
fixed quantum data
point toward fixed
direction, A and B.
Now using the
standard Keras model,
we can predict for
function, and see
that the noisy samples
are categorized
with enough accuracy.
So basically this has
been a very long journey,
and we had a big team to be
able to bring this up to you.
And we would like to thank
our colleague in our team,
in particular the quantum team.
We had contribution
from X, [INAUDIBLE],,
and in particular,
University of Waterloo.
I want to mention a
significant contribution
from Michael, Antonio,
Guillaume, and Trevor
over the past two years.
And we are excited to see
what you can do with this.
And we welcome
your contributions.
So you can dig deeper
by going to the website,
tensorflow.org/quantum.
Also you can look at our
archived paper, which
provides a detailed overview
of the entire framework,
and also a lot of
quantum applications
that you can work the details
in the [INAUDIBLE] app
that are available in
that TF Quantum website.
Thanks a lot for your attention.
[MUSIC PLAYING]
