Placeholder Image

字幕列表 影片播放

  • what is going on?

  • Everybody.

  • And welcome to a quantum computer programming tutorial.

  • Siri's right out of the gate.

  • I just want to stress I am not a quantum physicist.

  • I know a little bit about things, but I am just not an expert on quantum stuff.

  • Okay, I would argue that it seems like nobody really, truly is.

  • But I am less so than most.

  • Okay, that might talk on this subject anyways, So, um, my, my credentials are python.

  • YouTuber says to give you a little bit of understanding of my understanding of quantum physics.

  • So with that out of the way, I do want to at least give a basic foundation of quantum att least in terms of quantum computers.

  • I might say some wrong things, So I encourage you to go out and learn that yourself.

  • I think there's really no shortage of material, even just on YouTube.

  • But just on the Internet, in general, in terms of concepts and visualizations and just the theory of quantum mechanics and quantum computers, what there's almost nothing of is the actual practical side of things.

  • That's what I want to come here and do so.

  • First of all, what's a quantum computer?

  • So a quantum computer is just made up of cubits or quantum bits as opposed to our classical computer, which is made up of bits.

  • So the next question, of course, is what's a cubit?

  • So a cubit is well, first, what's a bit so a bit is in your classical computer.

  • It's just a It's a transistor, right?

  • And that that could be either a zero or a one.

  • And it gets its value from, Is it?

  • Ah, hi signal.

  • So we send voltage through.

  • Either it's a high signal or it's a low signal.

  • If it's a high, it's a one.

  • If it's a low, it's a zero, so a bit could be a zero or a one.

  • A cubit, on the other hand, can be a 01 We're both wait.

  • That's illegal Now, I assure you, apparently it can.

  • So So it does this through two characteristics that are unique to these quantum bits, which are superposition and entanglement.

  • So the idea of superposition is it is anything it could be, right.

  • Um, and it doesn't actually pick something until you make the observation.

  • So So for example, I think the mug is actually a pretty good example.

  • Right inside this mug, there could be water, coffee, tea, I don't know, hot fudge, all kinds of things, right?

  • And we and s So if this mug was in superposition, it would be all of those things, right?

  • And it's only when we look into it and be like, Oh, what do we got, Dewey?

  • Does it collapse on one of those values?

  • That's the concept of superposition.

  • Now to me and my, you know, I don't know lizard brain.

  • It says, No, There's really only one thing in that cup, so whatever, but But I'm just saying, Hey, that's the property.

  • The next thing is entanglement in the concept of entanglement is also magical.

  • And this is kind of the if you've ever heard the Einstein's spooky action at a distance.

  • This is what it comes from.

  • So if two cubits are entangled, a change in one causes a change in another one instantaneously, and distance is irrelevant Again.

  • I agree.

  • That's not allowed.

  • Um, it seems pretty spooky to me, but you know, people much smarter than me assure us that it's not actually spooky action at a distance.

  • We're not violating certain laws, like transferring information faster than the speed of light.

  • I mean, that's what it seems like to me, but we are assured that is not it.

  • So anyway, um, I'll leave the theorizing to other people.

  • All I can say is we have these two properties, how we have them, I don't know.

  • But we have them so cool, so that that's the difference between a cubit and a regular bit.

  • Now what happens when we have these two characteristics is in a classical computer the amount of like states that you can represent right, so each bit has two states that it could plausibly be.

  • It could be a zero, and it could be a one right in a quantum computer.

  • It could be 01 or anything in between.

  • So what?

  • I hate to say anything that is incorrect, I would say 01 or both States.

  • Let's just stick with that.

  • It's like a multitude.

  • It's not like it wouldn't be a scaler to my understanding.

  • Anyway, I see the comment section is probably blowing up with some experts.

  • Anyways, what this means to us is programs on the practical side of things is a classical computer can represent n bits times two states.

  • That's it.

  • A quantum computer can represent two to the power of n bits states.

  • So this is exponential.

  • This is massive.

  • It's a huge difference.

  • Rain.

  • So how many states both we can represent, but also like, consider?

  • So So, uh, quantum computers are unlikely to just, like replace classical computers one.

  • Because we kind of need classical computers toe work with quantum computers.

  • But also it's not that quantum computers will solve all the things that regular computers do or classical computers do faster, right?

  • It's not that it's quantum computers will solve problems that classical computers can't solve.

  • They just can't.

  • It would just be intractable, impossible to solve, right?

  • Or it would take a really long time, such as factoring numbers when it comes to, um, factoring for prime numbers.

  • So, for example, breaking encryptions, one of those things gets thrown around all the time that quantum computers could do.

  • That's true.

  • So if you're somebody that owns, um, like a database that today, if somebody was siphoning from it right now in 20 years with that, if that data would still be highly valuable, I'd be careful if I was you, because probably in 20 years R s a encryption could is dungeons.

  • So So these are things we have to think about.

  • I don't really think we're there now.

  • And also, as you'll see when we actually do the practical side of things, quantum computers have noise and error, and we don't quite yet know how to remedy that.

  • For some problems, it really doesn't matter.

  • For other problems, like breaking encryption, for example, it makes a huge difference.

  • So, um yes.

  • Oh, so the problems that quantum computers are going to be and currently are and going to be useful for our problems where, like the state space is just just massive.

  • Right?

  • So these exponential things, So ah, good example to think about is like any time you have many combinations.

  • So one example that I see gets thrown around by, you know, people that are trying to kind of sell The idea of quantum peters is like logistics.

  • So if you're delivering packages and you've got a route that you need to take, you know each kind of intersection that you pass is in theory, a branch that you could have taken and before long, each each turn that you pass or take branches out and creates this just again intractable number of other possibilities that you could have taken a classical computer kind of checks each, each one kind of in a brute force manner.

  • Sometimes we can use things like radiant descent or something like that to you, too.

  • Sort of optimized this task, but a quantum computer just simply can analyze all of them all at once, given the correct number of bits.

  • But it doesn't take long to have that correct number of cubits.

  • It doesn't take that long to have enough cubits, because there it's exponential.

  • So like a logistics is one another.

  • One is like modeling for like, molecules, things in like chemistry.

  • Right now, classical computers can sort of model things.

  • But classical computers, the best thing that classical computer Dio can do is like get close to T statistics, weaken sort of simulate probabilities.

  • But it's not real probability, right, Whereas a quantum appear as best I can tell, dare I say is probability like it just it's just it's true.

  • So that's the difference, right?

  • So another kind of really simple example that I think is easy to fit in one's brain is like, let's say you're organizing a charity event and you you're gonna see people at a table and ideally, you'd want those people to get along.

  • So they're in a nice donating mood.

  • Well, if you have five people, then that would be You know, you've got, like, five seats at a table, the combination of people that you could like, you know, what combination do you want to see?

  • People.

  • You only have five people, but the combinations Air five factorial, right?

  • So this means it's five times four times, three times, two times one right, So that's 120 combinations.

  • But if you just add one more person, it's because you went from 5 to 6.

  • It's 120 times six now, right?

  • So six factorial 7 20 right?

  • And then let's just jump all the way to like 10 people.

  • It's like 3.6 million.

  • So as you keep just adding just one more one more option, um, things get crazy.

  • So these are the types of things that, like, you know, a classical computer could obviously solve for the 120.

  • And the classical computer can do a pretty good job when you start getting to six million, Um, or 3.6 million, let's say.

  • But as you continue to go further and further the classical computer, at some point, it's just not even possible because at some point you end up having Maur more possibilities than there are like, you know, Adam's in the entire universe.

  • So you just It's just impossible, right?

  • And so we can prove that already we can definitely have quantum peters that will eventually exceed anything a classical computer could do in terms of large state spaces.

  • Okay, so I think that's really all I really want to talk about in terms of the fundamentals.

  • If you've got questions, feel free to ask them.

  • If I said something silly, feel free to correct me below.

  • Like I said, I'll put some other resource is in the description.

  • But let's say you're interested in this stuff.

  • You know you want a quantum computer.

  • What do you d'oh?

  • Well, it turns out, as you might expect building a quantum computer.

  • I mean, I don't know exactly how much would go into it, but I'm gonna imagine that if you wanted to start from scratch, it's probably like a least a $100 million enterprise.

  • Um, you can buy.

  • Like I've seen, that D Wave has sold at least one quantum computer for 15 million D waves.

  • Quantum computers are different from what appears to me to be.

  • Everyone else is, uh and I'm not intelligent enough to explain exactly why.

  • But something tells me that there, questionable compared to the differences, are questionable, at least So So let's I'm just going to throw out that they're probably about $100 million device, right?

  • Like so if you Googles, you know, 50 cubits, quantum meter R B ends or whatever.

  • So so they're expensive, whatever the heck they are.

  • So what these companies do with them?

  • Well, it turns out they just connect them to the cloud.

  • And anybody can connect and run these quantum circuits on them for free.

  • That's incredible.

  • To me.

  • This seems like it's like the equivalent of like if NASA was like, Hey, you can drive the Mars Rover, just connect to it and drive it around Mars.

  • That's what it seems like to me.

  • It's this incredible, but I think the thing is, right now, we're in a time where nobody totally knows what exactly are we going to use Quantum?

  • What all can we use quantum computer computers for?

  • And so it's just like a big kind of experiment right now.

  • So anyway, what a cool time to be alive that we can even play with these machines.

  • So, yes, we will play with actual quantum computers, uh, as well a simulator.

  • So, um, I think we've got the time.

  • Uh, let's go ahead and and set the set.

  • The mood.

  • So first of all, I'm gonna be working in the following.

  • I'm just gonna have this quantum computing tutorial.

  • Uh, and then we're going to, um we're gonna install something, So let me get out of the way, too.

  • I'm assuming everybody following this tutorial, please know the basics of python and installing packages.

  • If you don't, um, I will try my best to put a link to the basics tutorial in the description, but otherwise go to python programming dot net, go to the fundamentals and learn python the basics of python.

  • You honestly could learn the basics of python.

  • I feel like in a day.

  • Maybe that's unfair.

  • But day za Okay, So, um yeah, so cool.

  • So moving on.

  • What we're gonna need for this series is some form of Pip.

  • I'm gonna be using Python 37 So really, I would say pick 37 but depending on what operating system around, all that is going very but mostly pip install.

  • And they were going to be using kiss kit.

  • That's cute.

  • I s K I t We're gonna use numb pie.

  • I'm gonna be doing things in a Jupiter notebook.

  • So Jupiter Lab, if you want to use Jupiter notebook, you can use whatever editor you want, Uh, Matt plot lib and then kiss kits.

  • I'd be M Q and then provider.

  • And so if that doesn't give it away, we're gonna be using IBM sze quantum computers.

  • So there's a lot of providers like De Wave has them in the cloud Google has.

  • I think, in the cloud Microsoft definitely does.

  • Um and then, yeah, IBM.

  • I'm sure there's other providers.

  • I'm spacing out right now.

  • I kind of poked around Everybody's and honestly, IBM is, in my opinion, the best by far.

  • First of all, you could get set up hope I'm gonna be your jacket and explaining things.

  • But you could honestly get set up and running in, like, a minute or not a minute.

  • Let's say two minutes on IBM stuff.

  • So anyway, um, shots out toe IBM for forgetting this right on down kiss kid.

  • I don't know if it's people at IBM who made kiss kid or what, but they seem to be entangled.

  • Uh, I'm so cool.

  • So it's all those things.

  • I'm not gonna run it because I've already installed those instead.

  • What?

  • I'm going to Jupiter Lab.

  • Oh, also on at least Lennox, I found that, um, kiss kit IBM que provider might get installed with kiss kit.

  • And then it's like you already have this.

  • It's fine.

  • And then I attempted to use it and it didn't work.

  • So I needed to do ah soon a pip install upgrade force Reinstall of that.

  • And I also got a warning about mismatching version numbers.

  • Um, after force installing it, everything was great.

  • But if you have a problem, please let me know.

  • Even though I think IBM is doing a phenomenal job here.

  • But this all of this stuff is fairly buggy um for what it is, it's awesome.

  • But just expect to be need to be patient.

  • I'll also try to put the slack for a kiss.

  • Kiss Kiss kit has, like, a slack channel.

  • Um, and at least when I needed help, I got help pretty quick and it was actually useful help.

  • So anyway, I'll try to remember to put that in there, but, yeah, there there's so many things to talk about it in point, you two and stuff.

  • So I might forget something.

  • But if I ever get somebody, remind me, I'll put it in there anyway.

  • Jupiter Space Lab to open a new book.

  • Okay, so let's get this good enough.

  • Okay?

  • So let me name this, uh, kiss kit one or something like that.

  • Obviously.

  • Just I'm assuming you guys aren't amateurs, but kiss, Get one.

  • Just name it.

  • Something that isn't kiss.

  • Get that pie, because watch these I python notebook.

  • You get away with it.

  • Probably.

  • Anyway, just a good idea not to name it exactly the thing that you're going to use.

  • So let us go ahead and get started pot.

  • Actually, before we get started, you could actually start with kiss kit, but you're gonna have a hard time.

  • So, um, I might have to do some blurring if I screw this up, but I'm gonna show you guys how tow set up, I think because we're gonna run on a quantum computer first.

  • But so so probably before we get started.

  • The next thing we should do is go to quantum dash computing dot IBM dot com.

  • So, uh, let me see if I could just pop over there.

  • Yeah, so you'll have to make an account.

  • Um, and if I think you can just connect your Google account anyway, I forget how Simply I said I got set up here, but anyway, you'll need to do that.

  • And then you click on this.

  • Uh oh.

  • My face is on it.

  • Uh, we do this, uh, this little account icon, if you click on that, and then you go to my account, you'll see you'll have a token here.

  • Hopefully, I'm not showing anything else I should know.

  • I think I am.

  • Um, just click copy token.

  • Which reminds me I need to copy over.

  • Um, a token.

  • Dang.

  • I'm gonna have to edit this video.

  • Uh, let me do it.

  • So, actually, I'm I don't have to edit this video, so I am going to have my token in a separate, um file, because I just don't want to show it, but you don't necessarily have to have to do that.

  • I just don't wanna end up showing it on camera token.

  • So I saved mine in a file called token dot text.

  • And then if I go back to where we are, pasta boom done don't have to edit Nice.

  • So you would copy that token, and then you would use it in a moment.

  • So, um, just take note or you could copy it.

  • I think you'll be fine.

  • We won't do any copying and pasting until we need it anyways.

  • So now what we're ready to do is import kiss kit as q all of the like.

  • Official kiss kit tutorials that I've seen do from kiss kit import asterisk.

  • Um, I think that's the only thing I would complain about.

  • Don't do that, guys.

  • It's not that, um, that form that form and then Matt plot lib in line and kiss kit.

  • Just simply somewhere along lines is important.

  • I think when you do your visualization tools.

  • They just import Matt Pot lid.

  • And then this is just notifying Jupiter notebook to plot in line, like in the actual notebook.

  • So if you are, um, not in Jupiter notebook.

  • You don't need a tight Matt plot limit line.

  • Okay, so now we're gonna define our actual circuits So again, with quantum computers were working with the bits.

  • So so we that's how far down we're going.

  • So it's painful as a python programmer.

  • I know, but we got to start at the bit level, and this is partly why we're going.

  • Why, I I I don't see quantum computers, at least not anywhere in the near term replacing classical computers because we actually kind of need to work with both of them.

  • So, with, um, with with what we're gonna do here, generally you'll have, you know, python doing most of your logic or a bunch of your logic.

  • And then, for a certain task, you'll pass it through a quantum computer, get your response.

  • So the way it works generally is you're gonna define your circuit right in python, and then you it's just kind of a representation of the circuit.

  • You pass it through the quantum computer, the Quantico Peter does its thing.

  • And then, actually, what it does is even though So it runs it through and runs it through those cubits and then spits back out the answer, and it spits out the answer in bits.

  • So classical bits and again, this will make more sense, I think, as we actually work with this.

  • So anyway, I'm just trying to explain as we go, So we have to build these circuits and the circuits.

  • Are these, like, bit circuits?

  • Welcome to, uh, CS 101 So cute dot Quantum circuit.

  • And then what we're gonna say is to comma to another thing that I kind of noticed was, um, the shorthand here for how how to actually get away with this varies.

  • So I've kind of been running through a bunch of different, you know, documentations and stuff like that in overtime.

  • This appears to have changed, and it might change some or in the future, but so sometimes you'll just see to here, and I'm not sure how that would have ever worked, but anyways, it it has worked for me.

  • So anyway, whatever, um, I guess I guess you could probably get away with, too, if all you were doing was like, not actually running it and taking measurements.

  • Anyway, um, I've personally found that confusing, but what the's each value means is basically the it's two cubits, and then we'll have to classical bits.

  • So then what?

  • We're gonna do his circuit, um, circuit dot x.

  • So this is a ah, not Gates.

  • So we're going to say we're gonna apply a not gate to cubit uh, zero.

  • So by default, these bits are going to start as zeros.

  • So we're going to say, OK, Cuba's Cuba zero not so we're just flipping it.

  • Okay, so now Cuba zero is, um so let's say just to make it super clear.

  • So currently, Cuba assume these air cubits, it's just a 00 were saying, Okay, cubit, um, Cuban zero.

  • Not now.

  • So then we're going to say 0110 trying to help.

  • Uh, Now what we're gonna do is apply a circuit don't see X.

  • This is a control night or a C night.

  • Um, and this basically and it's it's I guess maybe the Maur um prime one of the more common ones and this will entangle the 22 cubits.

  • So you're gonna pass to through here.

  • But also, what it does is, um let me just note it here.

  • So it's a C not or controlled, not.

  • And it flips second Cuba Cube cubit value if and only if, um, the first Cuba, Cuba is a one right there is on basically So So we'll see x and then it's gonna be zero and one.

  • So in theory, you could actually you could put other cubits in here.

  • We only have two anyways, so but what we're saying so we flip this.

  • So this circuit now or this cube, it rather is one.

  • So already knowing that it flips the second Cuba so it flips Cuba one.

  • If the first Cubit is a one is, let's say is a one just to be clear.

  • So what will happen?

  • Right?

  • So what we should get in return at least up to this point, right?

  • Should be a 11 right, Because we flipped Cuba zero to be a one.

  • So then what we could say is we don't have to say this is again was kind of confusing to me when I was going through things, but we take our measurement.

  • So when we measure, it's important to understand that as soon as you take your measurement, if you did have cubits in superposition, they will collapse into a value.

  • So, um, more on that later.

  • But just know that at this point now we're actually measuring.

  • We're looking inside the Schrodinger's box with the cat, right, So we're going to see what's in the coffee mug, so we measure.

  • And then again, I didn't quite understand this, but slowly began to make sense.

  • We, specifying the actual cubit register how it is going to map to the classical bit register.

  • So we're going to say 01 here and then again, 01 So it's going to be a direct representation of cubits to a rather yeah, cubits to classical bits.

  • What this means is the value after we take our measurement, the value for Cuba zero is what we're going to return for classical bit zero, and then the same thing for a number one, right?

  • So what we should get at this point when we take this measurement is 11 as classical bits.

  • So again, with quantum computers, you take in whatever the circuitry is, right.

  • You're gonna probably use a classical computer to build the circuit logically with, um, with beautiful programming languages like Python.

  • Then you're gonna pass him through this, this quantum machine, which is going to run this quantum circuit with cubits.

  • And then after we got the Cuban answer, we're going to translate that answer back to classical bits so that we can pass that then back to our beautiful python language and do the next things that we plan to do.

  • For now, we're just building circuits, so that's that's all we're going to do.

  • So So we take that measurement, um, And then what we can do at this point is there's some really cool methods in here.

  • Whoever made these I don't know if you're watching.

  • Probably not, but whoa.

  • So, circuit drawing what we get is a asking representation off the circuit.

  • That is really cool that the amount of thinking that goes into making a visualization like this um, this way, uh, is really cool.

  • Eso awesome job.

  • Whoever made that So another option.

  • You have a circuit dot draw, and then is it back end?

  • I have to check.

  • Oh, no, it's output.

  • I was once a back end, but its output equals M p L.

  • This is Matt Lib.

  • So now you get a more pretty representation.

  • But I really like you.

  • I really like this one.

  • Anyway, um, here is kind of how they didn't know the measurements.

  • So actually, the first time I was started, it was like looking at the actual outputs here.

  • I was a little confused, Um, because I didn't know what what was this?

  • Right?

  • And so this is the symbol for measurement.

  • Same thing here.

  • It's a plus sign rather than I'm sure that's the that's coming from historical things, but, like, why isn't like this is an ex, but then controlled, not Looks like this.

  • I don't know.

  • It's a little confusing, but anyway, you can see here.

  • You've got your, um, your classical bit numbers here and then here.

  • I don't know, I was just like this one better, I think, but anyway, um, you can see here, this is our not gate, right?

  • And then this is our controlled not gate like it's based on this value here.

  • And then these ems we take in our measurement just a nice way for us to kind of see where we're headed.

  • So from here, we can actually run these things through our quantum machines.

  • Now, you can either run it through an actual quantum machine where you can run it through a simulator.

  • So you would use the simulators just when you're doing our Mindy.

  • But then when you're actually ready to do your true research, you want to see what the actual answer is.

  • That's when you're gonna feed it through a, um you know, an actual quantum computer.

  • So you can you can do either of these two things.

  • But I know everybody is goingto want to at least try it once to two run things on a quantum computer.

  • This way, when you're done, you can actually update your resume and call yourself a quantum programmer now.

  • So So in order to do this, I'm gonna show you guys, and you may follow along, but especially if you're following along on the day of release, feel free to do it.

  • But the cues will probably be quite long.

  • So do what you want.

  • But anyway, what we're gonna do is make some space and what we're gonna say is from kiss kit.

  • We're going to import IBM Q uh, and then we're going to say I I b m q die save underscore account.

  • And then you would put your token in here so you might even still have it copied pasted in there for me.

  • I saved my token to a file, so I'm actually gonna say, Oh, clips.

  • I'm going to sit one of these days, I'm going to say open, uh, token dot text open toping text.

  • Dude, we're wrapping up.

  • Ah, token text on dot Read and then close it all off.

  • Cool s so I could run that.

  • It's going to say the credentials already exists because I've already done this.

  • So you actually only need to do this once it saves.

  • It s so in your other programs, you don't really need to do that.

  • So you only need to run that one time and then to use it subsequently, just do IBM cute dot load, underscore account.

  • And there we go.

  • So it's an account.

  • It tells you.

  • Hey, this is an IBM que account, blah, blah, blah.

  • Uh, and then now what we can do is actually start working with IBM Q.

  • Which is is this here?

  • Which then gives us access to these following back ends So, uh, continuing along to actually send it.

  • Send something to those back ends.

  • What we're going to say, uh, is provider first of all, is going to be equal to, uh, I'd be mq Don get under scorer, prove fighter and we're going to say IBM Dash Q.

  • That's our provider on.

  • And then we have a bunch of back ends.

  • Now there's a few ways that we can access these back ends.

  • One is you could just look and pick one of these.

  • If we go to the home page, you can see here like IBM Q or IBM.

  • IBM Que Melbourne has a queue of 87 jobs, which is eight hun of jobs.

  • I don't know what the deal is when I'm like when I was working with this initially there, there's like no competition.

  • There was like the cues were all super short, but today it's just going nuts, so interesting anyways, and the jobs seem to be taking longer.

  • Like I said, there's a lot of variability here.

  • It's buggy might not be the right word, but patients will be required sometimes.

  • Anyway, I think you get provider.

  • So now what we could do is 44 back and in provider dot back ends.

  • We're going to try.

  • This is gonna be a terrible Cubitt cubits underscore.

  • Count equals Len back end dot properties dot cubits.

  • We're trying because one of them is a simulator.

  • Except where you're gonna handle the exception.

  • We're just going to say Cuba count equals simulated.

  • Uh, and then we're going to print, and we'll just make this a nice f string were going to say back in don't name, uh has.

  • And then we're going to say back end dot status and then dot Pending jobs.

  • Uh, cute and cubit count cubits.

  • Cool.

  • Hopefully that works.

  • No cube Always spelled cubit Run.

  • Yeah.

  • Cubit cubit count area Quit and we spelled cued wrong.

  • Terribly.

  • Run!

  • Run that one more time.

  • Okay, So, um within simulated, huh?

  • Cubic count Back and Properties Cube.

  • Do we spell?

  • We spoke cubits wrong again.

  • That's why cubits Cupid's.

  • That's why you don't un uh yeah, that's why you don't not handle your exceptions, but anyway so, So real quickly.

  • We can just kind of see.

  • Okay, Well, the chasm simulator, um, does have any Cuba.

  • That's cause it's a simulator.

  • So it should run pretty quick.

  • And then I bet they don't even have a queue for it on.

  • And then here we can see.

  • Okay, there's 14.

  • Cute 80 70.

  • We can see immediately when we're actually running our script.

  • And then later you could even work this and pick the exact back end right before you want to run.

  • So you get the lowest Q.

  • So long as it has enough cubits.

  • So different ones have different cubits, right?

  • The biggest one available to me has 14 cubits.

  • Where is the rest of them?

  • Have five.

  • So, uh, least right nowthe lowest Q is IBM que Burlington?

  • So we could say, OK, let's use that one.

  • So the next thing that we're going to say is from kiss kit dot tools dot monitor import job, underscore.

  • Monitor What this does is it tells us where we are in the queue and then where we are when we actually go to run the job.

  • So we're gonna say back end is going to be equal to provider.

  • Don't get underscore back back end, and then we're going to pass the name.

  • So we said IBM que Burlington.

  • We'll just go with that one.

  • That's fine.

  • Uh, so that gives us our back, and then we're gonna actually say, or job is going to be cute dot Execute on.

  • And they were gonna execute the circuit that we built, and then we're going to say that back end is whatever back end we chose, uh, and then shots.

  • This is how many times I want to send it through.

  • Because again, every time you take a measurement, it collapses toe one value.

  • So we want to send enough shots through to get a decent representation.

  • So I'm just gonna say, 500 for now.

  • So then after as we run, cuter executes gonna store the job.

  • But we also want to do the job monitor for that job.

  • So let's hope that works.

  • And if it does, I'll probably have to pause it.

  • Wait as we see.

  • What kind of cute I'm in?

  • Okay, were four.

  • Thank you.

  • Sometimes this runs pretty quick, like historically.

  • Like I said, if I was fourth in line, it would take less than a minute.

  • But lately, it's been taking a lot longer.

  • So we will see I'm gonna code that at least the next block.

  • And if it's done, then it's done.

  • And if it's not done a project pause or something, Um and then if you're running one, you can either pause or you could just break the current owners hit, stop in the run it on a simulator and then later come back and run it.

  • You know, maybe when you're gonna go eat dinner or something, wait in line and actually run the code.

  • But anyway, so, um so, yes.

  • So once that actually runs, we end up getting something from the job, which in this case will be a result of business would be 500 results, which are just these counts of what are the actual bit values that we got in return.

  • And it would be 500 examples because we we ran this through the circuit 500 times.

  • So now we're gonna say it's from kiss kit, uh, visual ization.

  • We're going to import plot underscored, hissed a gram and again, just like that.

  • Ask anything and even this is really cool for Matt.

  • Plot lib like These are all very hard visualizations to to make so really impressed with whoever did all the visualizations for kiss Kidder.

  • I assume it was prime multiple people, but anyway, pretty cool.

  • One spot in line.

  • Closer.

  • So apply.

  • Hissed a gram.

  • Uh, and then from Matt plot live.

  • I'm going to import style.

  • You may or may not need to do this.

  • If you're on a dark theme like me, you will, um Ato Least if you want to see numbers and then so I'm gonna say style dot Use on.

  • I'm gonna call this dark background, uh, and then we're going to say result equals job dot results.

  • So in this case, it will be these like, it'll be a result object, actually, but basically what it like.

  • I said, what it is is it's going to be, um, a collection of bit values.

  • Right?

  • So it should be a collection of, you know, in this case, there's there's four possibilities because it could be a 111001 or a 00 In theory, it really could only be one of those things, but you'll see in a second.

  • So john dot results and then, um, let's do accounts equals results.

  • Don't get underscore accounts for the circuit, and then we will do plot underscore hist o gram for the count's, um And then we'll say legend.

  • Um, well, we actually don't really.

  • This one, we don't need a alleged.

  • Um, where are we in the job?

  • I was still in third place.

  • Uh, terrible.

  • And then obviously everyone's job is a little different.

  • So some people's jobs are pretty quick.

  • Like when we go to run this I feel kind of bad because everyone's gonna be running jobs, But our jobs are actually really quick, like we don't really take that much time to run this little simple circuit.

  • But anyway, uh, so then anyway, whenever this is ready, we would run this.

  • Now, unfortunately, I'm still third in line.

  • Really see any reason to stay here Second in line?

  • I don't ask for too much longer, but while we wait, I will say, shouts out.

  • Did the recent new channel members I am sure Chung, Chris, Austin Meyer, Dean Honoria and Cory Shaffer Thank you all very much for your support.

  • You guys were awesome.

  • Especially Cory Schaefer.

  • If you like python programming tutorials and you want Maur Check out Cory Shavers Channel.

  • If you just type that into search, you'll find this channel really good.

  • Good tutorials.

  • So anyways, I am So our job is running.

  • Look at that perfect timing.

  • So our job is running.

  • Hopefully, we don't get any errors.

  • If you do get errors, there's is it job, Aaron, and we get Ares.

  • I forget what it is.

  • There is a way to access your actual airs.

  • But even this job is taking a while.

  • So I said, I think something's going on today That is making things run a little longer than normal.

  • I thought it was quiet time computing.

  • I thought it was supposed to be fast.

  • Oh, has successfully kiss kit visual ization, visual ization.

  • I was like, Oh, no, to be hidden there.

  • Uh, just hypo visualization.

  • Strike one more time.

  • Cool.

  • So we get our accounts now, this is why we can't actually break encryption.

  • So as you can see, the most common response was 11 which is that the one we were supposed to get?

  • But as you can see, we got some 00 sum 01 and some 10 Why is that?

  • We have quantum noise.

  • Notice how everything in quantum physics just sounds awesome.

  • Like this is a quantum tutorial.

  • I'm a quantum teacher.

  • Uh, this is quantum errors.

  • Um, but anyway, it's because of noise, and that's a lot of noise.

  • My gosh, um, maybe that's what's going on.

  • I don't know what's going on if they're like throwing a party in the same room that they have the quantum machines, who really knows.

  • But they're susceptible to noise, like a change in temperature, even.

  • Right.

  • So these cubits are stored at, like as close to t like absolute zero is possible.

  • It is colder than outer space, right?

  • It is far as we know.

  • It's like the coldest.

  • It's a close place that we know of, which is also nuts, by the way, anyways, so Okay, so a sense that took so long, I I think the next thing I'm going to do is just run this through a simulator.

  • Um, if you're finding it to go fast, feel free to keep running it through the rial back ends.

  • Also, if if if you, um you can run either through the back and you could run it through the actual chasm simulator, which is this one here, or there is the local version that you could run.

  • But for now, I think I'm actually just gonna run things on the chasm simulator.

  • So I'm just gonna change the back end before I forget to chasm Chasm.

  • Um, I don't need a type that I could just copy it, copy pasta.

  • And now what I'd like to do is actually change our circuit a bit.

  • So, um so what?

  • I'm gonna d'oh.

  • I think we'll just copy what we have up here.

  • I was gonna copy that.

  • Come down here.

  • Pasta.

  • So we're still gonna be a 22 We start, we started by Flipping X.

  • But instead, what I want to do this time is, um, use a Hatem.

  • Our gate pride butchered his name as well.

  • Um, Anyway, what this does is it puts whatever cubit you pass here and a superposition.

  • So now we'll see the results of whether this cube it was a zero and a one.

  • Um, depending on how many shots we end up taking So again, we'll take 500 shots, though just so we do see what the result is so So this one was is entangling cubit zero and one together.

  • So we already saw entanglement, but we did not see superposition and really super position is I mean, they're they're both pretty valuable, but superposition is the one that's maybe more bonkers.

  • But I don't know entanglements pretty, pretty bonkers as well.

  • Uh, anyway, so we're gonna run them through the simulator.

  • And so we've got the back end simulator above a blow a circuit draw.

  • We take the measurement there, So let's go ahead and draw that circuit.

  • Make sure makes sense.

  • So as you can see, we have the Hatem our gate here.

  • But otherwise you still got that C, not gate.

  • And then we take our measurements.

  • So the only thing that we flipped, it was rather than flipping Cuba zero.

  • Now we're saying, actually, Cuban zero.

  • So when we flipped it, we just like Cupid's arrows.

  • One basically.

  • Now what we're saying is, Cuba zero is actually in superposition, and then we're running the rest of the circuit, so that's our circuit.

  • Now we can actually run that on the back end.

  • So again, we're just going to say, um, job that execute monitor job.

  • So we're actually using the chasm simulator so we'll still connect.

  • Run the job.

  • Uh, and then we'll get our results.

  • So copy this.

  • Come down here.

  • Pasta that this time, as you can see, we got two major results.

  • Either a 00 or 11 makes total sense, because again, um, we're using the sea, not gate.

  • And the only time it will flip that second bit is if the first Cuban is a one.

  • So it's either want to be a 00 or a 11 exactly what we expected.

  • And as you can see, since we use a simulator, it's simulating a perfect quantum machine, which we don't have.

  • But that's why you don't see the other options because it's it's simulating as if we had a quantum, perfect quantum.

  • Peter, we don't, um, So if we were to run this exact same circuit, feel free to if you want.

  • But if we were to run this exact same circuit on an actual quantum machine, we would have found that we got vastly different results, right or not?

  • Vastly different.

  • We would have found that it was 00111 with the highest bars, but we would have also seen some noise.

  • Okay, so finally, just in case, you know you're on the airplane, right?

  • And you don't have you didn't feel like paying 20 bucks for the WiFi.

  • You can also run locally on a simulator.

  • So that's the last thing I'm gonna show before we bounce out of here.

  • So the other option is from kiss kit Kiss kit, Import air.

  • So this is your simulator framework for kiss kit.

  • Um, And then we're gonna say the SIM back end equals air dot Get underscore.

  • Back end, chasm, chasm simulator.

  • And again, there's also multiple back ends here.

  • You've got the chasm simulator, uh, unitary simulator and then a step date factor, I think.

  • But we can also generate over them, so I'll do that real quick so we could save four back ends in air.

  • Don't get back in that back.

  • End's prince.

  • Back in dirt.

  • Get back ends.

  • Really?

  • What did I do wrong here?

  • Air.

  • Don't get back.

  • End.

  • Is it back?

  • Oh, I try to do the same thing before, huh?

  • Okay, so we've sent our sim back and already be the chasm simulator But as you can see, you get state vector in unitary.

  • So again, uh, this is what represents and is most closely like the actual quantum machine that you're going to use, right?

  • You're going to pass it through a quantum machine, and each time you make one pass, you get one measurement, right?

  • Things can be in superposition.

  • But as soon as you take a measurement, you, uh, that superposition collapses down to that value, right?

  • So you're going to pass 500 times.

  • So the the return you get from the chasm simulator is going to be counts for however many shots he passed State Vector.

  • On the other hand, you could actually just pass one time.

  • What you'll get back is all of the possible states, right, because it's a simulator.

  • Okay, So one thing that taken to consideration, though, is if you're actually working on real quantum like problems, the state vector simulator is going to be a problem, because you're going to have to store all of the states and memories.

  • So the whole point of quantum machines is so we don't have to do that or that we're going to solve problems that we can't do that on a classical computer, so this is really cool.

  • And it comes with a bunch of extra visualization type stuff that we can do something here.

  • They're all really good, but but the chasm simulator is most closely related to what we're actually doing here.

  • So, uh, anyway, eh?

  • So once we've got the SIM back end again, we can run all of these exact same things.

  • So just take this pasta and then, rather than back end will say sim back end, Uh, and then this boop wait for it because we're running 500 shots, so don't forget.

  • And again, our simulator locally is also perfect.

  • So we don't have any error.

  • Um, so we only get zeros around 11 but okay, I'd say that's enough.

  • It looks like I've been recording now for 46 minutes.

  • That's a good introduction to quantum computers.

  • Like I said, not an expert.

  • But there you go, moving forward.

  • I don't know.

  • You know, I don't know how long this series will be When the next video is coming out.

  • I'm gonna keep tinkering around.

  • I think it's really cool.

  • It's a It's a completely new paradigm.

  • It's a new way for us to have to think about computing.

  • Um, so it's just really interesting to me.

  • And I also think it's just awesome that you can run things on a real quantum computer.

  • Like I said, I find it similar to if they if NASA let you control the Mars rover.

  • So anyway, really cool to continue along.

  • Like I said, I'll put some, um, some further resource is in the text based version of this tutorial.

  • Also, if you just go to that quantum dash, computing IBM dot com on, then click the little thing that looks like a Jupiter notebook.

  • You get start here, and that has a bunch of links to further information.

  • There's also a textbook that I link in the text based version of the tutorial.

  • Why're you taking so long?

  • Thank you.

  • It's got a whole bunch of information here.

  • I would at least you know, if you really want, you can go through all of this kind of stuff here on.

  • And then there's theat Vance tw ones.

  • You've got advanced in fundamentals.

  • There's a bunch of stuff.

  • There's just so much information.

  • And like I said, I think it's I think IBM has done a really good job of just getting all this stuff out there and making it really quick and simple to get running.

  • Right.

  • Um, so yeah, pretty cool.

  • Also again, things might be buggy.

  • Also, if especially the day I released this video, chances are the cues.

  • They're gonna be massive.

  • You might wanna wait.

  • You might just want to use the simulator, um, and then run it later or something like that, but okay, that's all for now.

  • Questions, comments, concerns.

  • Feel free to leave in below.

  • Come join us in the discord.

  • That's discord dot g slash Centex again.

  • Thank you to the new channel members.

  • And I will see you guys another video.

what is going on?

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

量子計算機編程與Qiskit (Quantum Computer Programming w/ Qiskit)

  • 9 1
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字