Subtitles section Play video Print subtitles We talked a bit about the hardware, you know, people are working on the hardware of quantum computing, yep What about software? where do you start thinking about that? Writing software for a quantum computer In my opinion is actually not very very different from how we write software for just a normal computer and we think about software in terms of being able to write down instructions for the computer and the computer executing these instructions changing some internal state when I write instructions for any type of computer whether it be like a modern MacBook Pro or an old PDP-11 In both cases in the end, we have an assembly code that gets executed that's changing the memory the disk The registers in your CPU and so on and it's not different with a quantum computer It's just like the question is what are we changing? And how do we change them? We can really describe these things in quite simple terms, if we were to do this in with sort of full textbook honesty, we would discuss things like finite dimensional vector spaces and in Hilbert spaces and Linear operators and unitary maps and all that stuff and all that stuff is very very important If if you're actually sitting down writing a program but to get an understanding of it I think we can do away with it. And actually just think about things in terms of simple probabilities. So the idea of a Qubit So Qubit is a Bit in a quantom computer Yep it is. Yeah. It's sort of the fundamental building block. It's like a it's like a bit and a regular computer The way I think of it is it's a resource in the computer. It's a resource that you can use to perform a computation So a qubit to me is anything it's sort of abstract. But anything that has two states of being and Some possibility or probability of those states. So for instance we can think about Photons and their polarization a photon can be sort of polarized left and right or it can be polarized up and down But if we're not looking then maybe it's it's possibly in one or the other. Maybe it's 50% moving and traversing left and right and 50% Moving up and down. This is just for photons Turns out there are lots and lots of different ways to construct qubits the qubits that that we work on in the so called field Of superconducting quantum computation. We use a device called a superconducting charge qubit It doesn't matter all the details, but it suffice to say that the two states there Are is their charge or is there no charge in this circuit? And then of course, we have the same thing. It could we could have a probability like maybe there's a 10% chance there's a charge or maybe there's a 90% chance there's a charge. These are called superconducting charge Qubits again, it sounds complicated, but the essence is the same two states but maybe it's in one or the other the interesting thing though is When we have multiple qubits, and this is really where the power of quantum computation happens We can actually think of it sort of simply Diagrammatically that if qubits if I just represent them sort of as a circle here, maybe we have three the idea Is that these qubits can interact this guy can interact with this guy? this guy can interact with this guy and these can interact with one another and every time we add a qubit if we were to Add a circle here. Let's say we added this fourth qubit right here We noticed that every single one of them can now interact with it. We have to draw lots of these lines It turns out that a quantum computer can deal with these additions of qubits in a very efficient fashion But like I said a qubit is something where it has two states So each of these guys can be in two states with a particular probability let's say the two states and our just 0 and 1, our qubit can be 0 or 1 or Possibly something in between. So if I write down these qubits with the probability, let's say we have three qubits here I'll call it Q0 Q1 and Q2 what we have is That qubit 0 let's say it's this one right here 1 and 2, well qubit 0 could be in 0 or 1 so it has some probability of being in 0 Qubit 1 also has some probability of being in 0 and qubit 0 also has some probability being in 0 maybe that's a 10% chance But now we have to painstakingly go through a write every one qubit 0 has a probability of being in the 0 state Qubit 1 also 0 and qubit 2 and we can write down all these possibilities Etc, etc until we get to the possibility that all of them are one and each of them has a probability. Maybe this is 5% Maybe this is 7%, maybe this is like 35%, maybe there's a very high percentage chance that all of them are one 8% and so on so every time we add a qubit the size of this table doubles the number of probability percentages doubles and it turns out that these probabilities right here are ultimately what a quantum computer is computing with when we do an Instruction on a quantum computer when we instruct it to do something in the end it's always about changing these probabilities to favor some computation that we're trying to do When we start up a quantum computer, when we flick the switch on it'll start as 100% in this state and everything else will be 0% We start off here, and we know that we start off here. It might be that when we apply a certain operation So for example an operation as is the so called superposition Initialization or we call it Hadamard initialization This is if we have any number of qubits, so starting off in zero, and maybe we want every probability to be equal So if we want to start off here We do something called Hadamard initialization where we do a particular instruction called the Hadamard gate and what happens is this 100% now turns into Let's say we just have one qubit It would be 50% chance in the zero State and 50% chance in the one state if we had two qubits Hadamard initialization would cause us to be 25% chance with both qubits being 0 25% chance 0 1 25% chance being 1 0 25% chance being 1 1 the point is is that this particular instructions one instruction on a quantum computer? Allows us to change these probabilities in a way that we'd like and it might be useful for us to do something like this Hadamard Initialization with all the probabilities being equal because then from here we could do some operation that affects all these qubits and affects all these Probabilities sort of in the same way. But like I said, this is just one possible instruction So there can be an infinite number just like a normal computer it's not that they're an infinite number of instructions It's that they're an infinite of possible things you could do with the instructions So one of the greatest discoveries was that we can arrange these probabilities to be in whatever way that we would like Using five instructions total there are sort of five different ways that we can Permute these things and change them and there are this, one is called a measure instruction measure instruction is pretty important because while we're talking about probabilities we can't actually see these probabilities in the quantum computer They're just in there At some point. We do want to see are they zeros or ones? Like we need to answer that question So the measure instruction will take any list of probabilities and turn it into One of them will change to 100% So each of these is 25% chance. It'll pick one Let's say it's this one right here and measure is gonna make this a hundred percent with the other ones being zero percent That's one way of changing and then incidentally we also get to read out from the clunkier that it was a 1 0 That's how we get our answers. That's the only way we get an answer. In fact from the quantum computer The rest of them are just purely ways of changing these probabilities. There are lots of different ways You can have instruction just like norm... Regular computers every single computer that's ever been built or every single CPU that's erver been built always has a different instruction set One possible instruction set is the following we have this Hadamard Is that named after someone? Yes, it's named after I think he was a mathematician He worked on a variety of mathematical subjects and there's a matrix that's actually one divided by square root of 2 1 1 1 negative 1 which is a so-called Hadamard matrix Incidentally this is also used to represent how these probabilities change so Hadamard is one instruction There's another instruction called Phase, again It just has the effect of changing probabilities around in a particular way There's another instruction called the T gate not very Creatively named there's another instruction called the CNOT gate and what's special about the CNOT gate is that all of these right here act on one qubit We say I want to do a measure on qubit 2 or i want to do a T gate on qubit 0 It sort of affects only one qubit. It'll affect a lot of probabilities because even though we're operating on one qubit here it accounts for this entire column so it actually changes all the probabilities CNOT is special because we get to choose two qubits This is how we get this interaction between them so CNOT you can say I want to do this on qubit 0 and qubit 2 For instance and this itself is an instruction in a sort of quantum assembly code Are these instructions a bit like gates? Yea, so they are like gates but there's an interesting reversal and for example a NAND gate is something like this where data is coming Into the gate and data comes out of the gate what's interesting about these gates and quantum computation is sort of the opposite you have data that's sitting there all these probabilities and You like apply the gate to the Machine and all the probabilities change. So you're not sending data into the gate You're not putting this gate on the chip like a NAND gate for instance Is a gate that you would actually etch into a chip Here it's an instruction that you apply to the computer and it changes these probabilities, but nonetheless They're both different operations that you do on data And how does what you do is code get changed into these operations of instructions Yeah, so like with normal computers you can write these instructions out as assembly code. In fact one example is Say I want the following probabilities I have 0 0 0 1 1 0 1 1 I want this I want it to be 50% chance to be 0 0 or 50% chance to be 1 1 this is called a bell state with a bell state. It's interesting because Theoretically let's suppose I have a qubit. Let's say close I could hold a qubit and Let's say I gave you a qubit it's 50% chance 0 0 or 50% chance 1 1 so even if we travelled halfway across the world and I decided to measure my qubit with the measure Instruction and I determine that to 0 Then I know for certain that you must be a 0 because there's a zero percent chance that were different, but somehow we determine this It's a 50% chance. It's not that it is already chosen literally is 50% chance. You don't know which one it is So we can write a program to construct a bell state I won't explain exactly why it works this way But you do a Hadamard on my qubit, qubit 0 we do a CNOT on My qubit and your qubit and we're done. This is a quantum program. You can write this out. Now there are higher levels of quantum programming where we don't want to restrict ourselves these instructions Maybe I want to more directly Express the probabilities and how I want them to change They all have to add up to 1 of course. I mean, we have a certain percentage chance It has to be 100% in the end, but maybe I want to shift the probabilities around in a particular way But not in any of the ways that's in our gate set I can write that down that can use something called a quantum compiler a piece of software that that converts what I want into these native instructions that gives me the next level of abstraction in the code we can go all the way up to using a full-blown library for writing this stuff one library that We've constructed is something called "PyQuil" Which allows us to actually write Python code to express quantum computations in Quil is actually this instruction set here Quil stands for quantum instruction language, which lets you write down this assembly code But hey, who came up with this things? is this a commercial thing or is this like... Yeah, yeah so quil was originally this particular type of instruction set