Using IBM quantum cloud computers with python package Qiskit. Episode …
페이지 정보
작성자 bryanai 작성일 24-11-09 10:34 조회 161 댓글 0본문
Using IBM quantum cloud computers with python package Qiskit. Episode 1
- **(00:01)** Introduction to quantum computing with IBM's cloud-based quantum computers, accessed via Jupyter notebooks using the Qiskit Python package.
- **(01:11)** Guide on creating an IBM Quantum Experience account and obtaining API keys for cloud quantum computing access.
- **(02:08)** Explanation of qubits in quantum computing: unlike classical bits, qubits can exist in both 0 and 1 states simultaneously (superposition).
- **(02:50)** Demonstration of loading the Qiskit package and setting up an account to connect to IBM's quantum cloud.
- **(03:39)** Creating a quantum circuit with two qubits and performing basic operations like the NOT gate (X gate) and controlled-NOT (CX) gate.
- **(06:53)** Explanation of measuring qubits and viewing results through circuit visualization with Matplotlib.
- **(09:37)** Using Qiskit functions to display available IBM quantum computers, qubit count, and queue status.
- **(13:35)** Running the quantum circuit on a specific backend (e.g., IBM Vigo) and using Job Monitor to check execution status in the queue.
- **(16:42)** Visualizing results with a histogram, showing the probability outcomes of qubit states (e.g., probability of both qubits being "1").
- **(19:11)** Explanation of simulating quantum operations locally or on cloud simulators when access to quantum hardware is limited.
Transcript:
(00:01) hello everyone welcome to my quantum computing bit uh video episode one so we're gonna go to jupiter notebooks and we're just gonna open a notebook we're then going to go and obviously just create your own notebook i need to find one class they rename all right so all of this stems from ibm quantum computer
(01:11) and you can launch the ibm quantum experience so basically you go to their website and you can create an account and get a key to access uh various um quantum computers in the cloud so just as we've somewhat briefly touched upon cloud computing there's quantum cloud computing basically i send functions to a quantum computer that performs its operations and then gives me the results so let's begin today's video is mostly making a computer give me predictions on what qubits we should have so in normal computers we have a bit
(02:08) which is one or zero but in quantum computers there are qubits which are a quantum bits not only can it be zero and one it can also be both so today we're just gonna say create a circuit using two bits and two regular bits and then give me the results on the probabilities for what those bits are after some operations are performed on them so first we're going to import cue quiz kit as q so quiz kit is the main package that i'll show you how to download in the first video and it's the main package we're going to be using
(02:50) for our quantum tutorials and we're going to say from quiz kit import ibmq and we're going to say ibmq dot load underscore account parentheses and then we're going to do percent sign mat plot lib inline uh for those of you who are using this tutorial outside of jupiter notebooks you don't need this so you can ignore this if you're performing this in some other python ide other than jupiter so we import quiz kit and then we say ibm.
(03:39) load account this loads the credentials for us to send instructions to ibm's quantum computer in the cloud while that's running let me make sure it's recording is and so once that's done we're going to create an object called circuit and we're going to set it equal to q dot and if you're lazy you can press tab actually i have to wait for the package to load but we're basically saying object circuit equal to q dot quantum circuit parentheses two comma two and so what this says is we want to create a an object that has two bits and two regular bits so
(04:35) we're gonna manipulate two bits in the quantum computer and then we're going to say circuit dot x parentheses 0 and then circuit dot cx parentheses zero comma one right so what do we just do so circuit dot x is a not gate which um basically all um so qubits start at zero by default however when we say um not gate that says flip the value at the beginning so before all this in our circuit so in the circuit we have zero comma zero four qubits after this function after this statement
(05:43) we now have zero comma one sorry one comma zero for qubit and here we say circuit dot cx0 comma one so cx is a control knot or c naught and this entangles the second bit meaning it flips only if the first qubit is one so when this statement runs it checks for um value of first qubit sorry value first qubit and if is one then second qubit is also now one
(06:53) and you shift enter quantum circuit i misspell it quantum circuit oh i misspelled it sorry about that right that means it's been done so now i want to display oh hold on so now we're going to actually measure the q bits um first we say circuit dot measure parentheses zero comma one comma brackets zero comma one so they both have brackets so what we're saying here is we wanna specify what values we want return for both the qubits and regular bits and so that's what this is doing here mind you this is actually not running in
(07:52) the cloud just yet this is running on your machine quiz kit allows operations to perform as if in the quantum computer just not in the quantum computer and it's actually quite cool we'll be able to run simulations that uh we could run in the cloud and now we're going to draw or print the circuit so we say circuit dot draw parentheses and here we have the x value for um qubit 1 and we have the not gate or qubit 1 which means it depends on the value of the first qubit what the second qubit will be and then their measurements meaning uh
(08:42) what they could be you can also make a different representation with matplotlib we say circuit dot draw parentheses output but equal to quotes mpl and so it's the same thing the x being the x and then uh or the not gate actually no this is the this is the not gate this is the control knot and this is the not gate now this is the not gate and this is the control knob yeah so sorry the x is the not gate this is the control gate it depends on what the first value of the qubit is will determine the second value of the
(09:37) second qubit sorry about that and so that's just another prettier representation so now i'm going to show you how to create a function that prints out uh what computers what quantum computers are available for you so we say provider we create an object called provider and we set it equal to ibmq dot get underscore provider parentheses and quotes ibm dash queue all in lower case we say four back end in provider dot back ends ends with an s colon colon cubit underscore count equal to the length of back end dot properties
(10:45) parenthesis dot qubits and say accept we're going to say cubit underscore count is equal to parentheses simulated and then we're going to print but we have an f double quotes uh curly brackets back end dot name parentheses as early brackets back and dot status parentheses dot pending underscore jobs no parentheses cued brackets cubit underscore count
(11:54) outside of that cube and just enter let's see if that run all right so here's our output so it's a little different i'd have to sign out but um here are the available uh quantum computers around the world that you can access at any time you can see how many qubits you can actually uh play around with like the best uh quantum computer ibm has is ibm q16 melbourne with 15 cubits and you see the cue is how many people are trying to run something in this computer at a time so six other people are trying to run some commands
(12:47) before me so i'd have to wait in line so to speak but there are computers with less qubits that are either fully occupied or not at all this all depends on the time of day and where you're actually using this but this is a cool function that displays uh all the quantum computers how many cues they have and how many qubits so you can see ibm you vigo it has no cues and five bits so we'll probably just use that um and then i'm gonna show you how to see where where in the queue you are when you go to run your code
(13:35) so we create we say from quiz kit import oh from quizkit dot tools dot monitor import job underscore monitor and then we create an object called backend again set it equal to provider dot get uh underscore back end ibm u ibmq underscore vigo you create an object called job and set it equal to q dot execute parentheses circuit this r circuit comma back end equal to back end comma shots equal to 500
(14:40) and then we say job underscore monitor parentheses job okay so we're saying send our circuit or our code into ibm vigo and show what cue we're in and perform the job so shift enter and it will display job is being validated job is actively running meaning it's doing it right now and then job has successfully run it's performed our operations and so now we're going to see what our qubits are so basically what we were telling the machine to do is give us two qubits run these two operations with the first qubit being a one and the second uh qubit
(15:41) should also shift to one so let's see what they collapse into because there's all this probability involved so this has run so now we're going to say from quizkit dot visualizat visualization visualization import plot underscore histogram and we're going to say from matte plot lib import style and then we're going to say style dot use parentheses dark underscore background and we're going to say result okay create an object called result set it equal to job dot result parentheses then we're going to say counts is equal to results dot get
(16:42) underscore counts parentheses and circuit and we're going to say plot underscore histogram and brackets counts results is not defined did that in the tutorial too all right so here we see the probability so basically we wanted one one because we said change the first qubit to a one and then perform a statement that says if the first qubit is a one then the second one should be a one and so the probability is ninety one percent that they're both one one however what are these values so obviously i don't want to get too
(17:33) involved in the quantum aspects of things but there's something called quantum noise and basically um these machines don't work perfectly every time with every execution so it's saying there's a chance that they actually are the wrong values because of basically failure both more so on the execution side of things and um oh i forgot to mention so here we just said import job monitor to see uh what was being run we sent the code into ibm vigo and here we're saying execute our circuit set back end equal to back end meaning
(18:20) what uh quantum computer we want to use and shots equal to 500 so what we're saying in the code is predict 500 times uh what the quantum qubits or the qubits collapse into and so it's kind of like machine learning i can kind of increase it let me set it to a thousand job is being validated and if i wasn't the only one in the queue i would see like q1 q2 and wait my turn bob is actively running job is successfully we run again and you can see our probability has gone up so it's almost like machine learning in a way that we can
(19:11) pre change the amount of shots and the values will change all right so um we're now going to i told you in the beginning it you may not always have um a space to actually run your code however quizkit comes with functions and set or functions and classes that allow us to execute our code as if it was in a quantum computer locally on our machine so i'm going to switch the provider to ibm quasom simulator excuse me which is actually so the ibm quasim simulator is in the cloud yeah it's in the cloud but it's actually not a
(20:13) quantum computer i don't think i think it's just a normal computer that acts like one up to 32 cubits really well actually maybe yeah it is a quantum computer interesting all right so now we're going to change our circuit this video is almost 30 minutes long uh actually i'll call that for today uh that was sending in our qubits to be played around with um sorry for the short video but i'll make the next one better so thank you for joining me this is uh episode one
관련링크
- 이전글 Quantum@Class 퀀텀 AI 강의 일시 및 장소 : 11월14일 목 1122 금 1128 목 1206 금 19:00~ |CTCoC 회의실 (마포대로 122 / 공덕역 4번출구 프론트원 6층) 신청대상 : 관심 있는 누구나 신청방법 :
- 다음글 Introduction to Qiskit | Coding with Qiskit 1.x | Programming on Quantum Computers
댓글목록 0
등록된 댓글이 없습니다.