Transcription
All right, so, uh, since the key interest seems to be about building Quantum, uh, circuits, here's what we're going to do. You're going to log into quantum.com. You're going to set up a new account. It is free. You get 10 minutes of usage a month for free. You're going to copy your API token and you're going to put it into an environment file in, uh, Wind Surf.
So we're going to create a new task. Use Qiskit to create and submit a circuit to IBM Quantum for Shor's algorithm. It's going to do all the things it does. Tell it to accept all. It's going to create the directory, da da da. And I'm going to advise that what you're going to want to do, once it's done creating the directory and creating its initial set of files, is open that folder. You want to let it finish its job, though, because it will stop. Cascade, it's creating a Shor's algorithm Python code. It's getting all of the, uh, requirements, creating the script to help set up the credentials. And I'm actually going to go over to a different folder and just copy my .env from that into this. We're going to copy it. And then we're going to go up. And it gave this Quantum Shor's paste. Okay. We're going to let it install the requirements. It created a README, which will help. And then we're going to go ahead and real quickly come over to Anthropic, create a new chat. And so that we can fully understand what we're doing, fully explained Shor's algorithm.
Shor's algorithm is a quantum computing algorithm developed by Mass physicist Peter Shor in '94. Why it's important: it's revolutionary because it can factor large numbers exponentially faster than the best known classical algorithms. How it works: problem conversion, quantum period finding, classical postprocessing. Mathematical foundation: choose a random number 'a' less than 'n'. Define the function f(x) = a^x mod n. Find the period 'r' of this function. While theoretically powerful, it requires a large number of stable qubits to factor numbers relevant to cryptography. As of now, it has been demonstrated on small numbers, but quantum computers aren't yet powerful enough to threaten current cryptographic systems. And I will tell you that most of the large language models have somewhat outdated information when it comes to things like current tech, especially as fast as the tech is growing.
Okay, it's still having some issues with one of its, uh, functions. So we're going to go ahead and open that folder. And then once it's open, we can see this is going to give us our memory and Wind Surf. And it was doing a thing. So it was interrupted. Create a quantum virtual environment for this operation. The env has valid API and [Music] token. Continue with install of dependencies into the venv. Okay.
And we're going to go ahead and open up the terminal. I don't know why it's not showing the terminal. There we go. All right, ready. Now it's activated that virtual environment. It's going to install the dependencies within that virtual environment. Takes a little bit of time. And had some errors. So it's going to know those errors. Sometimes it doesn't see the errors, so you have to kind of prod it to do that, which this little button here comes in real handy for that, because you can copy the command status and result and input it right here to give that to Cascade, which is in this case, it's Claude 3.7 Sonnet. That is our AI programming. Okay. Just doing all the setup. And because the, uh, Sonnet 3.7 has outdated information about Quantum IBM Quantum, we'll have to update that as we go. But it's going to go ahead and install the packages we need. Should have no errors this time. Installing collected packages. And by the way, we can go take a look at Shor's algorithm as far as the math and code, the Python code for putting it in. You can look at the setup IBM Quantum. And if you recognize or understand the code, it is easier to use this. I am not quite fully there yet, but I'm getting there. As I use it more and more, I see more and more what it does. I'm going to tell you that probably we're going to run into a problem with backends because it now no longer uses that particular methodology. And if it does shots, we're going to run into that as an error as well. Short circuit, find period, find close distraction, run the algorithm. Shor, yeah, I'm not seeing shots as a declared, which is one that causes problems. See job backend.run. We're going to have to, yep, and shots. So we're going to have to update both of those because those are the errors I get all the time. But as it continues to install this information and do the things that we need to do so that we've got all the different pieces of code that we call for to use, which is so far not a speedy process. It's usually not a speedy process.
And then one of the things I do to try and help it to learn this better is I come over [Music] to the docs and I copy that URL because it can go reference a URL, get the information from it, and then do what it's supposed to do. So we've got this one. And while it's still running this, I'm going to go ahead and start pasting this in here. And if you use Shift Enter, you can actually enter more than one paste at a time with the keyboard shortcuts. If you don't know that, just to help you out a little bit. The other one is session backend. We're actually going to get rid of the hashtag on anything because we don't want it to just read the one specific section. We want it to read the whole document. So for example, here we're going to back that up. We're going to back that thing up until we get past it. Make another couple of entries. It's still installing the, uh, it's a lot of dependencies to install to get it set up and run. It does take a bit, but it will be okay because Shor's algorithm should be a fairly short run. Getting there, getting there, getting there. I am waiting on my wife to leave work, so she's supposed to update me when she leaves. She has not yet updated me. Oh, see, there we go. Now it's going to try and edit the Shor's algorithm script. But before we run it, it's going to say, let's run it and give me an option to click start to run it. And we're going to say, not, not quite yet. And I'm going to start typing that message. Please reference this documentation regarding declaring a backend and declaring shots. And because it's trying to do something, it's going to want me to press Enter again to interrupt, which I do. It's going to go reference these. Okay.
Now, what we should see, and here's the thing, it honestly gives me the same error again. And then realizes where it got it wrong. I have not been able yet to get it to code properly with the, uh, default shots or the session, uh, jobs. So it's making the updates. And once it's done making the updates, it'll show me what those updates are, or it should. Sometimes it doesn't. These days, since one of the more recent Wind Surf updates, excuse me, generating this request is taking longer than expected. That happens. Okay. And then it's going to update the setup IBM. Yeah, I'm still not seeing any. It's not showing me. Not showing me any updates. Let's go take a look. Shots, transpiler, short circuits, backend, get counts, job results, options. Yep. I'm willing to bet it is still going to show an error when we get there, but it will fix the error faster now that it has something to reference in the documentation. We have to install some more requirements to update for the Qiskit runtime. Okay, it's telling me all the things it's done. Service. [Music] Backend. Okay. I still don't think it's right, but let's see what happens.
Okay, it's asking if we want to submit. Would you like to run the updated Shor's algorithm implementation now? We're going to say yes. And I'm not really worried about getting the actual results from this, simply because I don't know where it's going to be in queue. I don't know which backend is going to pick. Um, so I'm probably not going to record the results. This is just about using Wind Surf to create and submit a quantum structure. Okay, see. Okay, it's going to update the fallback simulator to code to use correct import for Qiskit 1.0. Let's also update the similar code. Run Shor algorithm [Music] function. The .env might have a different reference for the [Music] IBM underscore [Music] Quantum token. Okay, IBM Q API token to update the code. Use the correct variable name. Is that the only real error that we had? It couldn't access. Tried to fall back to a simulator, but we're not built to run on a simulator. It also found a problem [Music] with, looks like that's the same related problem. And we're going to install a couple more dependencies. Dependencies successfully installed. Okay, running the algorithm. Error accessing channel is required if token or URL is specified, but not name. Is not falling back to simulator. Measured period: two factors of 15, 3 and 1. Okay.
Okay, now let's go look at my dashboard and see if it actually submitted a job. Oh, not yet. Okay, session initialization. Yep, the sessions and the shots, the two things that always gets wrong. It has a reference now on how to fix it, and it will go back and fix it. It just takes forever without that reference for it to see what the problem [Music] is. Let's see here. Yeah, it's trying to use the QASM simulator as the backend. So what we're actually going to do here in this case is we're going to go pick a backend for it. We're going to go over to compute resources. The three that are available to me are Keve, Sherbrook, and Brisbane. We're going to take a look at what has the longest queue. 12 jobs, that's not bad. Eight jobs, that's good. And Sherbrook, three jobs. I see a job this low, I'm going to say it's probably stalled. So we're going to try and run it on Keve. Try running on. Oh, it's got a list of available backends. Maybe that'll make it easier for it to do itself. Okay, running Shor's algorithm to factor 15 using [Music] A7. I see we're making progress. That lists the available backends, but we're still having an issue with the backend initialization. Okay, it's going to continue to go through this process until it gets it right. That might be my wife telling me she's on her way home. And it did not correctly factor it, by the way, here or here, because the correct factors are three and five. So the fact that it's got that wrong with the simulator is interesting as well. Oh, there we go. Using IBM backend Brisbane. Let's go see if we go to our dashboard and refresh. Do we have an April 3D job? Yes, we do. And it still came back with three and one. They've got it to run now. We're encountering the issue with the sampler initialization. Session parameters not expected in the sampler V2 construction. Let's fix the issue. See, it fixes the issues as it since I gave it the documentation, it fixes the issues based on the documentation, not based on its previous knowledge, which is outdated. But it still tries to set up the initial run as its previous knowledge, using sampler instead of sampler V2. It's going to use Brisbane. No, we're still having trouble getting the initialization. Okay, checking it. V2 primitive, da da da. Checking, checking, checking. Updating. It used to show you where it was changing the code so that you could actually pay attention. It decided it doesn't want to do that anymore. I guess it doesn't say done, but it doesn't say not done. I'm curious what it's doing now.
Okay, let's see what happens here. It's able to access the backend, it's just not able to run the operation on the backend. So I'm willing to bet if we go back over to my session details, it, yeah, it had a zero second usage. That job was active and did not run at all. So we're getting submissions, it's just not actually running anything. So let's go see here and try this. Okay, it gave a migration guide. I might need to go back over to have it understand how to submit jobs. We'll run it one more time. See if it understands and fixed it. If not, we'll give it the instructions we just copied. We got to give it a second. Let's see what happens. Come [Music] on. Okay, different problem. We were able to access it, we just couldn't run the code on it again. But this isn't because of the same problem as last time, the initialization of the backend. We will get there, I promise. We will get there. Once you get it to run, it runs over and over again. It's just getting it to run, that's a little tricky. [Music] See what happens here. Hold your breath, cross your fingers. Just going to pick Brisbane backend [Music] again.
Okay, we're going to tell it to stop doing things and give it this. And I'm willing to bet if we go look at our Shor's algorithm again, where it references backend, it will change that to the right structure. Short circuit, Shor, Shor service, get runtime available back [Music] ends. Le busy submitting job to backend.name, which is still where it's having problems. Right, let's try it. Sometimes I have to literally like get stern with Cascade in here to get it to correct the same error that it keeps making because it looks like it still has backend as backend. Yep. Okay, sampler V2 has specific ways to call backend per documentation. As it finishes there, we're going to go ahead and not run the command this time. We're just going to tell it. So, see, oh, I had an error. Okay, now I understand how to properly initialize sampler V2 with a backend based on the documentation. Let me update the code. We're going to tell it to open the difference. It didn't really help me. It used to show me what was changed. Now it doesn't. And that's kind of annoying because it shouldn't be calling back backend specifically, it should be calling job or session or something. This right here, service.sampler. Maybe this will work this time. Oh, wrong button.
All right, we've still only used 8 seconds. It's still running zero state, 0 second. Oh, it looked like something just changed. The error that we keep getting is Qiskit runtime server. It's object as no backend. H. Let's see here. Yeah, see none of these are counted as jobs because my 736 hasn't gone up at all either. Oh, it's going to use Sherbrook this [Music] time. Still not accessing this. Well, we're getting closer because it used session instead of backend. No, no, no, no, no. You're still missing the point. Wind Surf. All right, so we're going to come up here. Actually, we're going to come here and we're going to go to this and feed it here. Let's see if I can go get the shots thing too. Shots. And I'm going to copy the whole page and feed that in here because I know we're going to get that error too. I'll just cut it all off of the path so I can get this done. So this information where, oh yeah, it went ahead and changed it to always running the simulator, which we told it to stop. And now it's going to go find the backend, Brisbane, Keve, or Sherbrook, the ones that are available to me. It's going to use Sherbrook. Is it going to successfully submit the job this time? Nope. Let's try this one more time. It should work this time. For. Hey, there we go. Job ID. We submitted it successfully. And now if we come over to our dashboard, we should have one. It'll probably be pending. Don't know how fast Sherbrook is moving as far as the queue. Yep. If we come here, the job is in progress. So it's already through the queue and it's the one being processed. Estimated 1 minute 43. Jesus Christ, that seems like a lot of usage [Music] for most of my functions run for two to three seconds. Something's broken. That's a big chunk of my time. Stop this video maybe.