Learning Q# with Python: building the quantum programming community - CFS2020
Hang everyone. Good. Morning thanks. One. Person, who's been caffeinated this morning. Hi. Thank you so much for being. Here this morning with me I am really excited to share with you why. I am excited about quantum, computing and in, particular, Microsoft's. Programming. Language cue sharp and the quantum development, kit, so. Let's. Just get started a. Little bit about me I, am a research, engineer at an engineering consulting. Firm called pensar development just a few blocks away from here in downtown Seattle, my. Background though is an experimental, quantum optics so. I've spent a lot of time in dark labs looking, for single photons or, maybe lots, of them trying to melt things with them. And in my spare time I actually, do, a lot of writing I'm really excited about trying to help communicate, what. Is generally perceived as more technical, or complicated. Science, topics, to, a broader audience, so, you can see I've got a bunch of free copies of all of these books here that you can come find me after the talk. Cool. So here's. The audience-participation. Part of, the talk I. Want, to know when I start with a new group what, you guys know. About quantum computing because, I know I definitely didn't know very much when I started so I, just, shout some stuff out at me what have you heard it could be word association, it could be, complete. Thoughts but maybe not too long. Sorry. Non-binary. Okay. Great. Security. Probabilistic. All right those. Are all pretty good ones anything, else. Entanglement. There we go that's that's, a good one. Superposition. Cool, we've, hit a lot of the buzz words now awesome. So, my. Phone knows that I am interested, in quantum computing and, likes, to suggest articles to me a lot which, I assume is generally, like, one. Avenue how people learn about quantum, computing and. When. I read these headlines. And sometimes, the articles. Inside I. I. Wonder, so like. My favorites here quantum. Physics can explain much of the world suffering. What. Came, first the chicken or the egg both, quantum, physics says. The. Promise of quantum computing, supremacy. Is bunk like all, of these titles I feel like would not communicate, even though I know. Something, about the field don't, really communicate very, much to me about what, it is or, what's. Even going on and, part. Of that is just because physicists. Are, very whimsy, and like to name things with very, fun. Names like time, crystals, or quantum, mana or magic, States and then we. End up with it pretty much everybody confused so. What. In the heck is a quantum, computer then. Cool. So. Yeah this is a picture of some. Of the hardware. It supporting hardware for what Microsoft's, working on, but. Yeah, like given all of that what are we actually even talking about, so. We're, all pretty familiar with, what, a regular. Computer is you've probably got your phones in your pocket or your hands, that's, the computer you can hold you've got your car your, computer you can drive in, but. Basically they're devices, for manipulating, information. In the form of binary bits, and, to. Change what those binary bits say we write programs which, probably most of us here do. So. Really quantum, computing isn't that much different, like we still have a device that is storing information we. Are still writing programs, to manipulate. What that device knows about or what that information in the device is but. Really all we're swapping out is how, we're storing that information. Now. Instead, of binary bits you, know your ones and zeros now we're gonna be using quantum, systems. I'm. Going to leave that nebulous, for a little bit because we're gonna do some demos in Q sharp to, kind of explore, what that actually, is.
So. If, I were to try and kind of diagram, like, what a quantum, computing, system. Would look like. Here. You go so. You, would definitely, need your regular, classical. Computer dev machine, so, your. Desktop your cluster, whatever you like a classical, computing resource, which. Is where you're gonna be writing those programs, to instruct the quantum systems what to do. That, program is going to compile, instructions. And. Pass. Those along to, a, whole, litany of other classical, controls. Other. Classical, computers FPGAs, things, that basically translate, those. Programmatic. Instructions, kind of the high-level algorithmic. Instructions, to like. Actual analog, electronic, pulses, and. Send. Those along to your quantum systems now, the quantum, systems have to live in a. Very. Cold environment and I'm not talking just your regular kitchen fridge or your chest. Freezer in your garage, they. Have to live in, cryogenic. Freeze fridges. That exist. At about. A couple. Millikelvin maybe, maybe. More but basically very. Very close to absolute zero. Deep. For, the ref or a reference point deep space is about 4 Kelvin so that's way too warm for quantum computing so. Really. Cool, and. What we can kind of observe, from this is that this, isn't, exactly something that even from a hardware standpoint is gonna be in your house, anytime. Soon. This. Is kind of gonna be similar to a, lot of the models for early computing where you had like a company or a university you know that maintained. The device and then you could remote in for time on the computing. Resource you, know now would be by the cloud but then dial-up. And whatnot so. You've, been kind of a, good way to like a mental model to think about where quantum computing, fits in with the rest of our, computing. Infrastructure, is as, a, hardware accelerator, so kind. Of like GPU. Clusters that you can access in the cloud or an azure or, specialized. Machine, learning hardware. Quantum. Computers are good at providing. Speed ups for particular types of problems. That. You're. Not going to be checking your email on a GPU, cluster and, similarly. You're not going to be replacing a lot of those tasks. Your your classical, computer is perfectly. Good. So. Quantum computers will, kind, of fit in that same model of a specialized, hardware accelerator. So. Given. That what. Would we actually speed up with a quantum computer it's. A good question, so. There, are lots of different kind. Of domains, in which people are exploring what we can actually do with quantum computing. Some. Of the some. Of these actually came up when we were shouting out stuff earlier cryptography. Both. In the manner of. Breaking. Current, classical. Protocols. As well as enhancing, with. The quantum technology, to build new cryptographic, Hardware. Accelerating. Particular, machine learning protocols. And. What. A lot of the other folks here at build from the U sharp team have been talking about the, chemistry, and material. Science simulation, so it turns out that, a lot of the kind, of chemical.
Reactions, And things that we have a hard time simulating, and understanding, now actually. Get a lot easier if you can just use a quantum system to, simulate a quantum system so. You. Know it. Kind of makes sense but. That's. Actually a really exciting application. Because it, could, potentially have, impacts, to like understanding, photo, understanding. Photosynthesis. Helping. Us make. Fertilizer more, efficiently which. Right. Now consumes, around, one to three percent of the entire global. Energy budget so, there's. Some significant, impacts and, so, that. Kind of leads to the next obvious question, when. Is this going to be like when will we be able to do this what, can we what is, the time frame. The. Best way to understand, that is to just take. Your application, and start building it, we. Need to answer questions, like how, many qubits do you need to do like, how many qubits do you need what, sorts of algorithms, do. You need - those, kind of are interlinked and, you. Can, see this is a picture from an. Experiment I was doing in the lab I, was, definitely spinning. Time appropriately while, waiting for data to come in. But. More. Importantly. With. These applications, who, is actually going to develop it. Who. Would you guys guess could. Write a quantum program or a quantum algorithm. You. Just shut up. Nobody. Then no. One can do this. Any. Guesses. Scientists. Okay yeah yeah so, it. Seems like you. Might need to understand, a lot of different things to be able to write, these applications, so. We actually. Can do this I. Would. Posit that teachers. Can do this data. Scientists, can do this project. Managers, can do this, pretty. Much, you. Can do this and. Everyone. Can, actually, program for a quantum computer. This. Is my kind of primary thesis, and hopefully I can convince you that this, is something that is a thing, that you can just sit down and do yourself maybe later or maybe when you get back home so. Given. That how are we going to do this how, can we learn together how, to develop, for a quantum computer. Some. Obvious challenges, that might come along with this. Kind. Of as we saw with those headlines I feel, like a lot of the, educational. Material, you you might find about, quantum computing falls into one of two categories it's. Those sorts of headlines, and, pops I articles, or graduate. Level research papers, so. You. Know between the two if you, know if you want to actually understand what's going on but you, don't want, to have like a PhD. In math and physics and, whatnot, to actually understand. The notation and syntax of what they're doing, it's. Kind, of hard to find what the right material, to, learn is, it's. Also, has. Been kind of hard to get hands on we.
Don't Have a lot of quantum hardware, there. Are a number of companies that have kind of a number, of qubits you can work with but there's nothing that really constitutes. A Oh computer. And. Similarly. As I kind of alluded to if. You, wanted to understand everything from like the what's, the, quantum physics that's going on in your quantum systems to, like the FPGA, programming for. The signals, that you're generating to you, know the, cloud. Communication. If. You wanted to understand that full entire stack that, that would be a lot I certainly don't understand, that entire stack similarly. When I push the power button I don't, know how my computer turns on like I have some general, ideas but that is a huge, and incredibly, complicated stack, of you. Know protocols, procedures. But. It, works, pretty well so. Thankfully. My slides came up today so, yeah. What. I'm trying to get at though is we, don't have to necessarily understand. Every. Detail of every layer to be able to program for the quantum computers. So. We have our, classical. Computers, right here right now. So. Let's. Actually what what can we do with those to. Understand, what we might be able to do with a quantum computer. So. Meet. Q sharp and the quantum development, kit Q. Sharp is a domain-specific, programming, language. Specifically. For expressing. Quantum algorithms, now. It kind of makes sense that we'd want a new programming language for this because our, quantum systems. Operate. Differently and in fact by different laws of physics than, our classical, bits so it, kind of makes sense we might want a different language to actually describe what what's, going on there, and. Other. Really, cool things that I'm excited about it, was actually announced by Martyn on Monday but. The. Libraries were already open source but the rest of the compiler, and the quantum development kit will, be open source by summer, there's. A good blog post on the Microsoft quantum blog about that but. You can see I've got a screenshot over here of a. Simple. Q. Sharp program running, in BS code. So. Q, sharp is built off of dotnet. Court which, is really cool because it means it's cross platform you, can you it pretty much anywhere. You like. You. Can it also has great extensions, for visual studio and Visual Studio code which.
Means I'm, mainly a Visual Studio code user but. You. Have the full intellisense, you can get, contain. A lot of the stuff that you know you're kind of used to with a lot of other languages in your development, environments, you, have or, you. Have for cue sharp. So. If we're to. Look at what's actually going on here so. I said it's built off dotnet core what, happens when you write a cue sharp program is you're writing some. Operations, and functions yourself. And. The. Quantum development kit has a bunch of libraries, that you can pull, from already, so algorithms. That are already implemented, that you can use, helpful. Utility, functions all kinds of stuff so. Between, you compile. All of these together and. Your. Cue char program gets, executed by, a host program which. In this case is a c-sharp program, and. What. You write in your cue sharp code. Doesn't. Have. Doesn't. Know anything about what, it actually will be running on and the, host program is in charge of sending. Your program to the appropriate, target machine so, you can target your program, to a, simulator. Which is great because you can that means you can run a bunch, you can simulate your program on your laptop, you. Can do usually. Around about 30 on a reasonable, like. Dev. Lab Deb. Machine and. Possibly, a few more on if you use cloud. Resources, but, that's a great way to get started because. You can just start playing around with stuff, another. Target machine you can use that's, provided with the quantum development kit is the. Resource, estimator so. 32. Qubits, is around. 30 cubits is not so. Many there. Definitely are applications. We can think of where we might want more but. The, question is all, right I've written this you sharp program. What. Do I actually need to run it that was kind of one of the questions that motivated, us for trying to understand. What's going. And the resource estimator will, actually, tell us how, many qubits, we need to run it what type of gates we would need which. Gives us a really good way to say alright you know I have this application I'd like to use you, know do I need five thousand cubits do I need fifty thousand Cuba's joining five million cubits and. That. Can help us understand, you, know the timelines, or if, maybe we should try to do, some optimizations, on our algorithm. Cool. So. What. Really really, got me excited about Q sharp as, you saw in the lab I do a lot of stuff in Jupiter, and or, with Python and in Jupiter notebooks, and.
Cue Sharp is actually interoperable, with Python. And. I. Think this is really important because I think the Python community is, a really kind of great place it's very opening. Very. Open and welcoming, and. So. We can now basically open, up Q sharp to that entire community as well, as, to. Help kind of onboard people. And. As. A much much more recent addition in the. Jupiter. There, is now a Jupiter, notebook kernel for Q sharp which means you don't have to. Handle. Any of the backend, so basically the host program, target. Machines like, normally. You would write a seat you'd edit a c-sharp driver file to do all of that but. If you use the IQ sharp kernel that's, basically all abstracted. Away for you and you can just run your functions. And operations in a few sharp just. Kind of like you would any. Other language, that you can run with. A with. The Jupiter notebooks. And. I, think this is just one. Of the coolest things because I basically, learned a program with Jupiter notebooks I. Came. From Mathematica, I was actually a kernel dev at Mathematica, for a while so this whole environment. Of being able to kind of like play around and, evaluate, parts of your code come back to it but documentation, in line with it is a really powerful teaching. Tool. So. Let's. Dive in I'm. Gonna. Over, to the demo here. Cool. So. I'm gonna launch Jupiter notebook here. And. So. I'm launching Jupiter notebook right now with a Python kernel, and we're, going to be using Python, to, interoperate, with Q sharp and, actually. Interact, with things so, it. Will probably take it a minute to spin up here. Cool. And. For the record all the code and everything you see here there's a github repo that I, I. Will. Be sharing the link on Twitter, and. Y'all. Can find it on github, they're. Awesome. Ok, so. Let's. Start. By doing kind of the standard pythonic, thing of let's actually just import the package that we want to use which in this case it's called Q sharp. And. It will take in a moment to spin up all the dotnet. Stuff. Also. If you like how the Jupiter. Notebook goes to slides this is a really cool Jupiter plug-in called rise I found a couple days ago so I'm. Super stoked about it, cool. So I had it also just print out the versions, here so. I could make sure I was on the right version. So, let's. Return to the. What. I was saying before about the. Quantum systems being our method, of storing, information. Before. We with, our classical, bits its ones and zeros right. So. For our quantum, quantum. Bits or qubits is. Basically, probably, the thing you've either heard about. Well. Now hear about, cubed. Is just quantum, and bit smushed. Together, and. So a qubit. Is represented, by a vector of complex. Numbers so in particular for, a single qubit you. Have a two entry vector for, two, qubits you have four, entries so it scales two -, and. Yeah. -. One I forget, no, - 2 - n 2, to, the N. Right. And you. Can kind of see there's this weird symbol, here to the, left, of it, this this. Notation is called a cat so, you, would pronounce this cat X, and. It's. Basically. Another. Way. In. Which physics, kind of came, up with a cute naming thing so this is a cat if you flip it the other way and you have an angle bracket and then, a pipe that's, a bra and so you put them together they make rocket. So. But. The point and the main point is the. Cats here is basically, going to be the notation that we use to just simply, label, a vector so, it's. The same thing they don't, worry about it. So. What. Can we actually do with a cubed you, know I've gotten. Us all excited about doing programming, quantum computers so what are we actually gonna do with the resources. Well. Firstly, you, can prepare, a qubit. You. Can do operations, with a qubit and you. Can measure a qubit and. Of. All of these kind. Of the most interesting, one is, compared. To our, classical, bits is the measurement. So. We have this quantum system it's represented, by a vector. Of complex numbers when. We measure it we don't just, get that vector, of complex numbers out we, get a 1 or a 0. We're classical, beings we cannot see. We're, not paul rudd an ant man we cannot see into the quantum realm so, we. When, we make measurements, we, get classical, data back out and so, part. Of the art of quantum, algorithm. Development, is trying, to, arrange. And, and, get your, end quantum. Your, end like. Data stored in your quantum computer in such, a way that when you make the measurement you. That. One bit communicates, what you want to know about it so. We're. Gonna look, at some examples of this so. Let's start by preparing a Cuban so. You. Can see what. I'm doing here, from, the quiche our package we're gonna use compiled.
So. We, have a couple different ways to actually use, cue sharp and Python this is a good example of one of them I can pass here directly just the string. You. Can see it's a multi-line, string of the. Code that I would have maybe in your. Standard Q sharp file. So. I can run this it's. Going to actually compile this for me and what's cool is, prepare. Qubit now is actually. Like. A pythonic, object so if i go, to look at attributes, i hit, tab I can. See my options are estimate, resources, simulate. And, source, but. What I'm interested here in is simulating, it so. What's. Actually gonna happen. Let's. Look at the code so. Our. Operation. Here is called prepare Cuban. Cue. Sharp is a, typed, language strongly, typed so we. Have no inputs, here but we can see the the output type is unit. And. Then. We have this using statement which, basically tells whatever, our target machine is whether, it's the simulator, or hardware hey, heads up I'd like a qubit please so. I want one qubit we're gonna call it qubit. And. I'm. Not actually doing anything with the qubit here this is just, allocating. The qubit and then. Dump machine here is a. Kind. Of a utility, function that allows us to see what. The simulator is actually storing about the qubit now, dump, machine is not something you should use in, production, or in any like, actual. Quantum algorithms, I'm doing this here to basically show us what the simulator, is recording, so, that we can kind of talk about it and explain. It, but. In general you wouldn't be able to I can do this because I'm using the simulator target machine but. If I were using a real, hardware I wouldn't be able to do this so you don't want to write your. Program to rely on this so, that when. You actually go to Hardware won't work so. Well. Let's see what happens. So. We get this output here from dump machine we, can see the parens here which is just the unit returned. But. It actually prints out here what. What. It's storing, for our for, our qubit and. If. We look, here I've just copied and pasted it up here, this. Is pretty, close to what we saw earlier as representing, our qubit so, the. Only difference here is that you can see there's another column. That. Represents.
The Coefficients, for the imaginary parts of, each entry so this. One corresponds, to the first-century zero to here but, these are the real components, and these are the imaginary components, so that's. Kind of why I continued. To write out zero times I even though obviously it doesn't matter it's still zero. So. Now. Let's, actually use, this and do, something fun. Generate. Random numbers, this. Is definitely a thing. We can already do with a lot of the qubits, that we have in hardware, and. Is. Pretty. Important from a cryptographic standpoint. A lot of times our entire. Cryptographic. Train. Of chess. Train. Chain. Of trust I have. Not had enough coffee yet. Relies. On where. Your source of randomness is coming for your key, and. So, if that's compromised, everything else down the down the chain is compromised, as well so if you can replace, procedures. You. Know like the stuff. Built onto your CPU with. A quantum, system deciding. What your random number is, you. Can actually write a proof of security, that is not. Computational. You can write it basically from the laws of physics this, is random so that, you, know security, people like that, so. Let's, give this a go so. We. What. I'm doing here I'm gonna demonstrate the, other mode of using. Q sharp and python which is loading, it from other files in your directory, so this, is just a snippet. From. I had, it up here at the beginning but I've, got a couple files in my my, repo here one is these. Are t-shirt files you can see up here, and. I've. Defined a namespace, and. Then, our imports, and then the functions and operations. And. In. Python what. That means with. The Q char package we, can just say, hey from this namespace let's. Import. One. Of the functions or operations. So. When. That's part of what happens when Q sharp starts up it looks through your directory, finds things that are, also in. Your project. Cool. So now it knows about the operation, Q. R and G, so. Let's. Take a quick look at what's actually going to happen here so this, part probably looks a little familiar we. Have the same sort of using hey, I'd like a cube it please, and. Then we're gonna do this, operation, the, H operation. A. Little. Bit more about this in a minute the, H stands for Hadamard but it's a very very, useful quantum, operation, that, doesn't really have a good analogue to, our. Classical, boolean, logic gates but, it kind of is as useful as like a knot. Or a NAND or something like that so. We do our operation, and then. We do a measurement and what. This what, we're doing here so we're gonna return this and. You can see our return type here as a result so, we're gonna return the result of measuring. Our. Qubit along the, z axis now. It. Doesn't matter it, doesn't matter too much. What. That, means is, kind. Of like I was talking about before we can't just measure that entire vector that, Zed basically, tells us you, know some, what, subset of that vector we want to look at or what component, we want to look at, and. We, reset the qubit because as, a part of the promise we make to our target machine when we say hey can, you give me a qubit is that. We will return it back to the simulator, clean. We. Reap. Repaired back to that zero state or the. One zero, cubed. That we were looking at before so kind, of like good stewards we were turn it back the way it came to us. Cool. So. Another. Cool thing is that when we write documentation, in our Q sharp files. That. Actually, kind of comes along to the Python side as well so. If. I ask the. Python kernel hey what. What does Q orangy do I, can actually see the the doc strings that I wrote in the Q sharp file and. Actually if you were doing this in Visual Studio code. Or Visual Studio this. Would also get pulled along in intellisense. As, well. So. I find. That very helpful so that I don't have to like tab back and forth between things. So. That. Let's. Actually look at it real quick it. Says that, given. A cubit initially, in the zero State if we apply that H operation. And. It. Gives us in this particular state and. More. Importantly it returns a one result with a probability of 0.5 and, a zero result with a probability of 0.5 so.
This Is going to be what. We expect here to happen is basically, this is a. Really. Good coin flip that is. If. We. Were running this on real Hardware guaranteed, by the laws of physics to be truly random since, we are technically running this on a computer a classical, computer simulator, this still technically, is pseudo-random. So. Let's. Just actually give this a go so I can use list comprehensions just, like I would regularly in, Python and say I would like to do this ten times and get ten random numbers and, you. Can see it works. Numbers. Do change, just. Checking. Yeah. So you, know that isn't super, exciting there's obviously a ton of other ways we could get random numbers. But. It. Is cool because we. Could we now have the opportunity we've written this code and we could actually run it on real. So. Let's talk a little bit more about what that h, operation. Is so. I'm. Going, to pass. This time the. Option, of I, basically, gave myself a toggle for the print statements. So. I will set the. Simulator verbose mode this time and. See. What we can find out about what's going on to our actual quantum state, so. You, can see just like before when, we get a qubit from the, simulator it starts. As a zero in the, zero state so that means it's 1 in the first entry and zero, in the second and no, imaginary components, and. So. I also added a dump a dump right a dump. Machine after. We. Did the H operation. And. You. Can see what happens, so now we don't just have a 1, 0 now we have ok, this is 1 over the square root of 2. But, we have more importantly the, same number for both 1 and 0 and, that's. Basically, what means when we actually sample, this as a probability we. Will measure. 0. With. 50% probability and, 1 with, 50% probability. And. You can see that one time that we ran that we go to 0 cool. So. This is great we, now have, done we've prepared a single qubit we've done an operation, with it and. We've. Measured it gotten. Ones and zeros out cool. But. Generally speaking we're gonna need more than one qubit to do something interesting. So. Let's. Talk about to. Keep it. So. With. So, I think somebody at the beginning shouted out entanglement, as one of the things that they'd. Heard about quantum computing this. Is a really great way we can actually explore what entanglement. Actually is. So. I'm. Gonna do the same thing as before I have in that file. In the directory a, namespace. Or from, the same namespace an. Operation. Called entangled, qubits. And I. Will. Turn on to propose their verbose asan so, now. We, have two cubits and. You. Can see our dump machine, actually now has like four. Entries so that's the two, to the two, and. How, we can, how. We can understand, like what these map to before the, first one just meant. That's. The, zero state for the cubit and the one state just, labels, basically. Now.
The Labels, for two cubits are gonna be kind of the same way you would count. Binary. Bits so this would be the first entry here would be, information. About both, cubits being in the zero zero state then. 0 1 1. 0 1, 1. So. We. Can see here when we when, we first get two cubits from the simulator they. Are a hundred percent both. In the zero state so that makes sense that was the promise made to us by the simulator, and. After. We do the, entanglement, operation, which is actually. Two. Gates there are two operations but, we end up with this state so. What. Do we see here we, now see, numbers. Only for the zero zero entry. And the. 1 1 entry, and. So. What that means is that when, we measure these two qubits, we. Will only if we measure one of them as a zero the, up we know there, is no chance that, the other one will be something. Different than what we measured the first time so, basically. Our only possible, measurement outcomes are, 0, 0 and 1, 1 and. Again. From the same argument of these being the same number it, will happen with about 50/50, probability. So. Let. Me try. Running this a bunch of times again. You. Can see each, time we measure measure, the pair after entangling, them we. Do in fact get, either, 1 1 or 0 0 so. Thankfully. The, laws of physics work out. So. I think that's, most. Of what, I've got for this. Part of the demo. Actually. Are. You guys keen on seeing some more demo stuff, yeah. Okay cool. I've, been going faster than I thought so let's. Talk about an actual quantum algorithm, so. Just. As a initial, disclaimer, this is definitely a toy algorithm. The. Objective. That you're trying to solve, seems, a little contrived, and yeah. It is but. What is useful about it is that you can generalize. It and you can use it kind. Of as a subroutine for a larger, algorithm, and still, get the speed ups from so. Let's. Set this up. Let's. Say I had a function that has a 1 bit input so, this is just classical, function, one, bit input and one bit output how many different operate, how, many different options would I have for that function, I, kind. Of drew a little picture here to represent, that so if my, options for input, are 0 and 1 and my options for output are also 0 and 1 there's. Basically four different ways I could map the inputs, to the outputs. So. You. Know if I just basically said all right, output. What you gave me that's. I'll. Just call it the identity, function. If. I swap them that's an OP if, I send both inputs, to 0. Called, 0 and same for 1. So. With. That as a set up. Let's. Talk about Deutsch Josa so this is this is the toy algorithm, that I was mentioning before. The. Problem statement for it is if. I'm given a black box implemented. On my quantum computer that actually, computes. This classical, function f. You. Know one. Of those four options basically so it takes one bit as input and. Outputs. One classical, bit I, would, like to know not, what, function is in that box but, a property, about that function, and in particular whether it is constant, or balanced, and. I want to do this with as few. Tries of, throwing, data into the box so. Given. That this is just one bit input technically. There's only two, possible, inputs I could give to it so. You. Know from, our human perspective that doesn't seem like a huge speed up but this actually does scale for, n sized, inputs, and n sized outputs, so I just, don't like drawing that many lines, connecting. The dots. Android. Shows that can actually do this in one query so we go from one query. With. The quantum computer to to two, queries classically, like. I said it, always is just one query no matter the size of the input. So. This. Global property. Balanced. Or constant is pretty, straightforward. Basically. The. Identity. And not. Versions. For this function f are. The balanced category, because well you, kind of like map you. Cover all of the, same. Outputs as inputs here. These are constant, because well they, constantly. Output, the same thing it's, not. Too complicated and, so. My, goal here is to with. Basically, one query, to this box figure. Out which. Category it's in. Without. And, I, but I don't care what actually. Function, it is that's, not important, to me. So. Let's. I, again. Have. Yeah. So I'm gonna use the the compile option here again so. I'm just passing stuff in and. I'm. Even passing stuff in here and using stuff from the. Q sharp file that's also in my directory, because. It was too big to put on the slide so, I've. Got an operation, here that's going to ask is our zero Oracle, so. Oracle, here is basically the name that I've given to this black box that I don't know what's inside I know that, there's a function in it but I don't know which one and. So. Here, I'm just asking. I know. Ahead of time but I have missour Oracle and I'm trying to ask is balanced. And. So, if it's zero Oracle we would expect that this should be false, because they're the zero Oracle would map everything to zero which is a constant, not a balanced.
So. Let's. Compile that and. Thankfully. My. Mental. Math here worked, out so. Yeah. That that's what we expected, that's not we. Saw from our picture actually. I did have it repeated here, the. Zero. Oracle here is. Constant not, balanced. We. Can do, this again for, the. Knot. Oracle. Which should be balanced, so this should be true. Cool. And. Let's. Put this all together and, I. Can actually I have a. Operation. In my Q sharp namespace. As well called, run. The entire algorithm and I will actually check that. All, of our or all of the Oracle's that we implemented here actually. Do indeed with one query. Rastelli. Whether. They are constant, are balanced correctly, which. I. Realize. Just having a printout that says all tests pass, is. Maybe, not so convincing, but the, fun part is you can check out this repo yourself and actually look at what's going on. And. Try it out here. I had it at least say, with. What, it found so the. Zero and one Oracle's. We would expect to be constant, so are, they balanced no, and. The ID and not Oracle. Should. Be balanced, because they. Cover all the outputs, so cool. Already. One. Other thing we can note from this is you. Can see that the output. There. Are some interesting. General. Guidelines, for. Writing. Quantum, algorithms, that allow us to kind, of get around that whole measurement. Challenge. Of not being able to read out our full final state so one, of the things that you. Can kind of see from this. Sample is that, we, like. It when our quantum algorithm, basically, has a yes or no question at the end, that. Makes it really easy to kind, of design our quantum state so, that we basically have one entry we're looking at in the vector and we. Want to know whether and we can try to use the. Quantum properties of the system to, create a really high probability, that or, certainty. In most in some cases that, we, actually get the answer we want which since. We're measuring a one or a zero I mean. That's a yes or no question so basically. You. Know that, your problem might be a, good candidate for a quantum computer if, you can kind of like boil it down to it yes or no question, about whatever. Your input is. Cool. So. Let's. Hop, back to. The slides. See. How seamlessly, I can do this. Cool. So. We've. Seen now playing around with cue sharp in in, Jupiter, notebook and with Python I was, doing this in Jupiter notebook here but of course you could write your own Python, scripts and files or use ipython, like.
Any Of the ways that you like using Python, or dotnet. If you want to just write Q sharp directly, there's. Lots of options and so you can really use what you're most familiar with and what, you like, so. We. Have all. Of this promise and all of these applications, but. How do we actually get, there well Q. Sharp is a really awesome start, to help us, understand, and actually, start writing some of those applications, but, we need more we. Need to write that software and. We've. Seen from experience, that communities. Of people write, software the. Watching. And kind of understanding, how the open source communities, for, tons of different languages including. A lot of Microsoft, stuff now it's. Really neat to see how, people, work together to, make these really, awesome cool software projects. You. Know everyone. From data. Scientists Python developers. Academics. But what. We know right now is that a lot of those people are not engaged, in the quantum computing community and I. I would. Challenge. That we, actually do want everybody, involved here because that's how we're actually going to get the ideas to. Figure. Out where those applicants, where we can apply it next like you. Know the same three, people are just thinking about this term somewhere, they're not gonna have, new. Ideas or different ideas like I love. Working on the interdisciplinary team, that I work with because I work with mechanical engineers and electrical engineers software engineers, some, that you know do FPGA, design and, we all have different things we bring to the table so. It's. Really important, that we, include everyone, when we're trying to develop. These applications, for quantum computing. So, how, do we we're. Kind of at a crossroads now. Quantum. Programming, is really starting to be a thing we have now a language, we can work with we have a number of different platforms we, can use, so. How do we be intentional, about this and create these, developer, communities. The. Way we want to see them. There's, lots of cool things that at least I've noticed, from other open-source communities, things. Like encouraging. And supporting member contributions, I love it when I come upon a project, that has like a good first issue tag because, I know like my first, public, PR laugh, was last year build so. I had, not. I'd. Been kind of too scared or intimidated by, trying of contributing. To these projects, so having you know maintainer. X' and other community members be like hey this. Is a good one this is pretty easy you know it's not gonna be high. It's. Gonna be a good good. Project, for a, newcomer to our problem to our repo. Other. Things, that are really important about creating. Our new quantum programming community are having, codes of conduct which, create safe spaces for members, to actually be. Another. Is good, documentation, tutorials I, know as. I'm, an experimentalist, I like, to code experimentally, as well which, means. I will probably not read the docs first shame, on me I will just get a sample from a tutorial that I find somewhere try to build it try to use it tweak it and. Then probably go read the docs when it doesn't work so, having those tutorials having, you know kind of even if it's just a really simple walkthrough of like how, to use, a you. Know use a qubit and do a QR ng like this or do. You. Know just, get. Your environment, set up for Q sharp, things. Like that are really helpful and I think can. Help people. Who are maybe too intimidated, by looking at Docs or looking at the, full. Repo samples, in the repo, which. There are lots of good samples. And the Q sharp repo I should say. And, lastly. Meetup. Groups and hack nights I I. Really love I live, here in Seattle so obviously there's lots of really great. Tech. People here in the area so I go to PI ladies Seattle all the time, but.
It's Really great to find other people who are excited about the things you're excited about and like compare, notes in a more synchronous fashion than. Just, slack messages, or otherwise. Asynchronous. Stuff so. Let's. Really be intentional, and use these, lessons. That we've learned from other open source communities, other programming, and development communities, in general and make. The quantum programming. Community really cool and. A, great place to be so. Given. That what. Can I do. Because. I square, root of -1 now that I've explained it it has, totally lost all of its humor. So. Obviously. A good first step is to just go try quiche up for yourself. Go. To the there's, lots of different options I'll show some links on the next page but. If. You want you can even just try it in your browser going. To using. A jupiter notebook and using the IQ sharp kernel so you don't have to set up anything on your machine to actually go try this. Start. A meet-up like duo i do lunch and learns at work a lot when i find something interesting that. I am learning about i just tell, my team hey. Come have lunch with me we'll talk about this thing, that's. That's something that's fun to do. Right. Some of those blog posts and tutorials, and. You. Know and hopefully. We. Can kind of provide, feedback on those as a community, and and. Leave the more. Importantly leave the community better than you find founded, so you, know finding, and contributing, to to, the official Docs fixing. Bugs and. Just. In general acting. Intentionally, to, include, as many people as possible in, this. Quantum. Programming, community so. I mentioned, some links so, a. Good, first starting place is, actually a new group that myself and Ralph. Are. Starting. Up, it's, the URL is just Q sharp community, so, it's gonna be it's a Q sharp or it's a github org where we're gonna try and collect a bunch of different projects. Examples. Tutorials. Things, that, that. We can help maintain as a community and you. Know help. Inspire. People for, their own projects, and find you know what they might want to work on as. As. Always. Read the docs doc, step microsoft.com slash quantum. They're. The. Shameless self-promotion, is. My. Chris. Grenade and myself have been working on a textbook that's, basically, this talk is kind of a short. Preview for. So. I've got a bunch of free codes for those that. I just come up and talk to me after the talk I'll give I'll give them out and. Obviously. I've, also found, a lot of good information on Q&A, sites so Stack Exchange Stack. Overflow are great. Reddit. User beware. But. In, general, I will. End with this and then take questions but go. Make the quantum development, community the best community it can be. Thanks. Cool. Is there any questions. Yeah. And please use the mics. So. That they can be transcribed I'm. So super cool question the, hardware that you guys are using is that d-wave by chance or what. Is, that in-house hardware. For the quantum processing. Yeah. That was actually Microsoft from, Microsoft some, of their hardware that they're using those. Fridges okay. The. Short description of what it is is when. You put, your quantum systems in a fridge, you basically have to setup a bunch of different thermal stages, all. The things down because.
There You can't just if, you have regular electrical, wires that are connected to your computer those are at room temperature, and anything, that conducts electricity also. Conducts heat so. You have to have these kind of like floating islands. That basically step down your temperature, and then, you have different yeah. So basically that's what that is and it just hangs usually, suspended, in like. Liquid. Sometimes. It's liquid. Helium. Sometimes. They're derived but yeah that's the ideas that's kind of like a pyramid, of temperature, onto the very lowest one which is where your actual chips it's like. A partnership then with you aver was that literally like totally, separate like that's. Microsoft's. Own hardware that's really neat Devers yeah thanks. So. The. Fundamental building block of a CPU is a transistor, what is the fundamental building block of a quantum chip, a. Qubit. You. So, qubits, are your information, storage and then depending. On I, mean, there's tons of different ways you can make quantum systems right like what. I've normally worked with is photons which are great as individual. Qubits and for doing cryptographic things, but, for a computer you need them to interact and unfortunately. Photons, don't like to, work together so in. Hardware, systems like the one the. Type, that Microsoft, is working on and. A lot and other groups with, superconductors, you're using microwave. Pulses from. External fields, to basically kind of. Get, them to interact and, produce the operation, that you want on one or more cupid's so you have, that's. Where that classical, control, kind. Of intermediary going. From, your actual desktop to the to. The quantum systems that's. Doing a lot of translation, to figure out okay I'm gonna make these arbitrary waveforms, which generates, the magnetic field in this position, that. Actually, manipulates, the quantum system, so. As I understand the direct quantum logic gates, what are those logic, gates, like how are they made. Essentially, I guess, well. So you make them by usually. Electromagnetic. Pulses so, they're kind of transient they don't exist. As, a physical, thing. But. More. Generally, there is kind, of a similar so we know from classical computing, like if you have a NAND is, it. NAND and maybe one. Other thing you can make any Arbit, to. Make any sort of arbitrary, logic there, are similarly. Minimal. Date. Sets for quantum computing that, give you the, ability to make basically arbitrary, operations. That's. Not something I'm an. Extensive. Expert on but I do know that basically there's lots of research on like a number of different. Kind. Of core. Gate, sets that would give you are betrayals. And it's like usually, I think about three but. Don't quote me on that so it's not like you need 40 gates there's, like a handful. I. Buy. I'm not I'm not by any means knowledgeable. In this area but the little thing I read. Told. Me that all the quantum, program, is giving it's a probability. And. In, the end you, find the probability of your answer, I can, have multiple stages, and, you get the let's, say that make the best decision, it.
Was Only 0 and 1. Sure. Sure. Yeah, so I I was. You. Are entirely correct the, entries in that vector basically, do. Describe effectively, a probability, distribution, that when we do that measurement we're sampling that probability distribution now. I like, to make those distributions, certainties, so, it's easier to talk about what's, going on but, like we saw when we did that H operation, that, gave us like the 0.7, and 0.7. If. You square those those actually turn into 1/2 and 1/2 and so that's, your probability it's a uniform probability distribution. Over 0 and 1 and so. They're. Definitely you can do probabilistic, quantum, algorithms which. Basically, you're. Trying to get down what. You the, answer you want to get to have the highest probability but. You can also actually make deterministic. Quantum algorithms, so Deutsch Josa is actually a deterministic. Algorithm, that does have a 1 in. In. A particular place in that vector so when you measure it you, know that that's your answer, so. Yeah. Can. You explain us about the, topological, qubit, I read about it but come. Up over here. I. Think the short answer is I, cannot, I. Am NOT I'm not, I I, mainly did photonic, cupid's but, I dunno if you go check out the, quantum. Booth Microsoft. Has it some quantum boosts out and the I think it's the App Center so if you go where the big glowy edge thing is and to the right go. Ask a bunch of folks there they will know a lot more about that I do. Hi. So. I've. Heard a fair bit about quantum, computing but. I'm having, a bit of trouble figuring, out the application. For it everything, I've heard so far seems, to depend heavily on random. Number generator is there. An application, for it a real-world one, right now that isn't, based off simulation, or. Is it mostly, simulation. Based. Okay. So, if I understand the question correctly you're asking, where. Like. What. Near-term, applications, look like for this yeah, so what what would you actually use it for, sure. Other than just having fun, at 2:00 a.m. on my computer when I'm waiting for other things to compile, good. Question, so. Kind. Of one of the things I mentioned before, about. Applications. There's definitely, like. Long, moonshot, sort of things which I think are. Generally. Speaking more like the Shor's algorithm like factoring, RSA, like. That will, take us a significant. Number, more qubits than we currently have orders. Of magnitude so. But. What is exciting about kind, of what. We see in the near term with. The. Types, of real. Hardware resources, we have as well as the simulation, is. The. Simulating, other quantum systems so, like, there's lots of cool Microsoft, has a partnership with Pacific. Northwest National Labs, which does a lot of quantum chemistry stuff and so, they've released, some. Like quantum chemistry libraries, that actually go with Q sharp and you can actually simulate. Electronic. Levels of different, atoms and molecules and, things like that so I. Really, think like some of those material science stuff just basically helping us understand, quantum mechanics and and other like chemistry better, is. Definitely. Where a lot of the initial stuff is going to be. Interesting, and. The. Other thing that we've, learned a lot from. Just. Playing around with simulators, and stuff like that is the quantum inspired algorithm, so, Martin. From, the Microsoft. Quantum team and as well as the two startups, that spoke with him. Are doing quantum inspired algorithms, so basically, from trying to understand, how quantum algorithms, work and write, those because, it. Is a very different sort of way of thinking you, don't have you know ones and zeros you can't make copies of things like there's, lots of weird, rules there but, if you kind of use. Those as inspiration, they've actually found ways to speed up classical, algorithms. You. Know with classical techniques there's no quantum, necessarily, to it but using lessons that we've learned from. Ways. You might manipulate data quantum. Systems. So that's. Another thing that's kind of been really exciting as of late coming from even, stuff with simulators. Yeah. Any. Other questions. So. You're spoken about that there, are these certain. Certain, specific, applications like, machine learning cryptography. So. Then quantum computing, so. There might be.
Certain. A good area to use but, what do you think that maybe certain, speaking in terms of certain. Long-term that, certain. Can be like move towards, quantum computing for like for. A regular, like laptops, and desktops that is that. So. So. They're not what, certain. Quantum computing is for, and only for this needs, so. These needs are so. These specific applications, is what, southern. Corner computing is required. Ok, I'm, sorry I'm having a hard time with the acoustics in here but I can, speak a little bit to the the, quantum machine learning applications, a lot of what we've seen with that is we know that there's particular kind. Of sub components, or. Sub. Routines of quantum, machine learning protocols. That we do know how to speed up and in fact sometimes exponentially. One. Good example of this is an algorithm called h HL which does linear. Regression exponentially. Faster but. Kind. Of the challenge with this is. We. Can do that but, we have to translate our actual, classical, data in, - and. Transcode, it into. The cubits and so. Far we don't really have any good, ways. To do that we're, in the overhead, from doing that does not blow away all of the advantages, you get from running it on the quantum systems to start with so. That. I, don't think rules it out as a possibility for application, I think it means we have to kind of be more clever about how much data we need to actually pass to it in what ways and. Things, like that but. Yeah. I. Think. We're at time but, thank you so much everyone for joining me and if you have any other further questions come up and talk to me go check out the Microsoft booth out on the floor and yeah.
What came first the chicken or the egg.. correct answer is it's the rooster. :D
No.... I would say it is rather the state of linear superposition of egg and chicken ;) Remember the shrodinger cat that is both dead and alive ... It is the same.
the subtitle has delay