# Pyquil Easy, Hybrid Quantum Programming | Scipy 2018 | Guenevere Prawiroatmodjo

Gates which I will explain later which use quantum entanglement to entangle two qubits.

And the hybrid comes into play where we actually start interacting with this qpu so.

This is a very new field we are actually creating this field as we speak right now and to interact with the computer it’s not something that people have done before so typically how do you translate a quantum program into the classical world is to do a measurement and to create a quantum program you actually define circuits so this is the interface that we provide with quill this is an example quill program so this would be executing an X pulse.

Or and not on cubed 0 ahead of Mardon cubed 1 and a z rotation on cubed 1 and a C naught which is a conditional not so this is.
Entangling gate which I’ll explain later how that exactly works what that.

Means is that if cubed one is in the excited state so in in one state then it flips qubits 0 and if it’s in the ground state then it doesn’t do anything so this is.

This creates in this quantum entanglement and and importantly we have this hybrid classical quantum interaction here where you measure.

The quantum state and save it into a classical register so you can assign classical registers to the outcome of quantum measurements there’s a cute little animation of our stack it looks sort of like a totem but I’ll just explain in.

Steps what what all of these layers mean so on the top of the stack is is our our pikeville library so you see.

This cute little snake here this creates quill programs then when you send it to our api gets translated into a pulse program which does these quantum.

Rotations again sends you to qpu this gets translated into quantum operations which then can read out so as i said you only measure the z-axis so you only get zeros and ones.

Back this you can then take the average of and save into a classical register and that gets sent back to the user so we’ll do a little demo I will create a program that rolls a die so I create a quantum die eight-sided to create this die I will use three cubits so 3 bits basically to encode the.

Numbers 1 to 8 so I basically take the binary value and I add 1 to it so for that little created a I do paterno book so I can.
Program a quantum pewter and.

In Jupiter notebook which i think is pretty cool so first to get set up I go to our website Righetti comm zoom in sign up for an API K this is a very simple process you don’t have to fill.

Out any form you just put in your name and your email then you get an email that looks something like this in your inbox this has your key and user ID in it which here I’ve yeah then you go to your notebook typically what you do is you just copy/paste this key in here the.

Key and user ID and write it to a file dot spike.

Will underscore config you have to do this once great.

So now presuming that you have installed pike wheel which you can install with either pip or Conda we can start importing some of these programming on so a program.

Which is a quantum program qvm connection so I’ll first part of this demo will run on our simulator which everybody has access to so if you sign up you can immediately use our quantum simulator and I’ll import some gates X and H great so I’ll connect.

To our qvm quantum virtual machine and now let’s let’s just quickly demonstrate how to create a program or create a program and I just apply an X pulse on keep it zero then I measure all the cute this is just a really nice shortcut here to measure qubits I can also actually just add a measure command here same thing I have to import it and then I can execute it on the q vm and i will get a result so as you see this.

Is a list of lists so what i mentioned before to actually reconstruct your quantum state you have to do multiple shots.

Or multiple measurements so I can here I can enter trials equals 10 so that’s what the inner list is the inner lists is the single shot result so as you can see here I flipped the.

Qubits from 0 to 1 so now I can also do a how to margate so I’m just gonna copy this.

So I set the hedemark aid rotates the qubit onto the equator and gives you a zero and one half of the time so if you would plot this on the histogram you would.

See half the time 0 half time 1 so that’s great a quantum die for this I used three cubits and I apply 3 how to Margate so I.

Basically create three random numbers three random bits so these are again.

These eight possible results than to roll the dice so I use this convenient measure all functions so I can just Prince roll dice you see that it creates this program automatically for you where it measures all the qubits and puts it into these classical registers great so I can roll this die and it’s gonna give me a random bit string and here I extract the dying number from this bit string and I add one because I start with one great I have a quantum die so now let’s run this.

On a real quantum of here so for this I import the qpu connection object I can see what devices are available as well I can run getting devices.

That’s dicked to get me a dictionary so I see here there’s two devices one of them is online the 8q agaves chip so I’m going to connect.

To that guy and again I’m going to roll the dice and now it’s running on our quantum feeder in Berkeley which I think it’s pretty.

Cool so yeah here we are quantum mechanical die and this is the result all right thanks very much so now to explain let me just quickly check on the time I think we’re still good.

So now I’m just I’m going to explain this concept of quantum entanglement which you might be familiar with might not be familiar with but what I really like as an analogy is using two boxes.

So let’s say I have two quantum boxes they have quantum mechanical properties I can put.

In two cubes in each box each cube has a label 0 or 1 then I’m going to put them inside of the box and I’m going to shake the box and randomize this result and then blindly I’m going to pick one cube.

The left box and one cube from the right box and there are 4 possible outcomes is 0 0 0 1 1 0 or 1 1 and each of.

Them occur with equal probabilities right if I just have a normal box now I’m going to do this entangling operation we want to entangle the two boxes the fun thing is now what happens I can change the underlying probability distribution of the outcome of these random guesses random pulls from these bucket these cubes out of the box and now I can actually enhance the probability to get a equal parity of 0 0 & 1 1 and completely.

Suppress odd parity so you might wonder okay how do I actually do this how do I create a quantum entanglement of course I cannot do that.

With macroscopic objects such as boxes but I can do this with qubits so these artificial atoms.

I can entangle qubits by the way this inten quantum entanglement Einstein who had a lot of Albert.

Einstein had a lot of problems with.

This he called the spooky action at a distance the reason why is because you actually when you when you get a zero from one box’s immediate influences the result of the other.

Box so this means that somehow there is some communication between the boxes or this is not something that he could understand or accept so this is a very very strange concept and.

The way that we actually make this happen in the lab so it’s a very it’s a strange but very real concept the way we make this happen in the lab is we apply another pulse and in.

This a flux pulse is what we do is we actually bring the energy levels of the two artificial atoms close together for a split second literally for a few like hundred.

Nanoseconds and this creates this interaction between them that entangles them so to a great a.

Bell State or this equal parity state that I mentioned before what you do is you apply how to Margate on one of the qubits so you bring it into the onto the equator and then I apply a conditional knot on the other qubit this means that if you measure this qubit to be in the.

Ground state then the other qubit is also going to be in the ground state and if surely this cubits being in the excited state then the.

Seen object will flip the other qubit into the excited state as well so this is what this program looks like in quill so there’s another example here that I’m not sure I’m gonna have time for so I’ll skip it for now but you can do it yourself on your laptop’s their link is right here I created a.

Binder repo here so you can either go to the repo yourself and install it on your laptop or you can just go to.

This link go to get e-comm slash quantum – dice and there’s a few notebooks and there including the one that I just demonstrated just now and the way you create two entangled.

Quantum dies is you use three qubits to incur encode one of the dies and then three qubits to encode the other die and then you untangle those three qubits like this so.

The first die with the first qubit of the second die you you apply this header Mart see not program and so forth and.

So on and so forth you’ll see that if you randomly roll the dice you always get the same answer for both of the qubits so.

I want to briefly go into some applications of quantum computing the example I showed what the quantum dies is a very simple example one that only shows a pure quantum algorithm so it doesn’t have any interaction with classical libraries or this hybrid interaction so what we do at Righetti is we work on somewhat something we call quantum machine learning so you see here this is a paper we published last year where we did unsupervised machine learning on our.

Hybrid quantum computer on our 19 you bit chip acorn and what we did is we mapped a max cut problem onto our cubed lattice so max.

Cut means that you have a graph where each node has some properties and max.

Cut creates the maximum difference between notes to classify them into different groups and what we did to achieve this result is we used a quantum algorithm called QA Oh a quantum aprox optimization algorithm which is a parameterised quantum circuits it’s parameterize by gamma and beta and we optimize over this circuit using a classical machine learning algorithm so this is the topology of our chip so this is.

Our different qubits and we.

Map our max with problem exactly on to this topology of the qubits so thanks very much for attention to learn more about Righetti you.

Can go to our website or read our Doc’s on Pyke we’ll read the docs dot io we’re.

Also on Twitter if you have any questions I’ll be here until Saturday just reach out to me I’m also on the site PI’s slack and thanks very much so we have time for questions once again there’s a mic there so you can line up there.

And I can also come to you if you have questions hi can you remind me how many qubits you have in the cloud right now online and I’m.

Also just wondering if anybody has done anything like witty useful like with it beyond sort of like a tional stuff mm-hmm so these are currently the chips that we have available so this is our 8 qubit device that we released last year it has 8 qubits in our ring and then we also have our 19.

Qubit chip which we currently only use internally but it’s been up in the cloud for available for a while there have been multiple people who have used our qpu to do research so quantum information theorists have.

Running their algorithms on our hardware so for example this group from Canada Waterloo have done quantum algorithms to train neural networks then this researcher from Switzerland has created a game to benchmark quantum computers and this group has done work from Oak Ridge National Labs and work on simulating an atomic nucleus so we’re still not at the point where we can do something useful in the sense that quantum computers are not yet faster or more efficient.

Than regular computers but we are at the.

Point where we can start thinking.

About these problems and and start thinking about when the hardware is at the point that it will reach a quantum advantage that we have our.

Software ready question over here sustainability so you’re calling this thing with liquidy with liquid helium I’m assuming so how’s that gonna transfer as we get more and more quantum computers given that liquid helium is and you know a.

Finite resource sorry can you repeat the question so you’re I’m assuming you’re cooling this thing down with liquid helium correct the cooling is premium so yeah liquid helium Oh helium yeah that’s right so how’s this gonna work yeah if liquid helium is a finite resource and it just goes into space right.