Hello World | Coding with Qiskit 1.x | Programming on Quantum Computers
HTML-код
- Опубликовано: 1 июн 2024
- Welcome back to Coding with Qiskit, where IBM research scientist Dr. Derek Wang will get you up to speed with the latest developments in quantum computers for your own work.
What is Hello World? When installing anything new, whether it’s a language or package, it’s standard practice to include a “Hello World” example. The purpose is twofold: first, we ensure that the installation was done correctly, and second, we want demonstrate what a typical application workflow looks like. Here, we’re going to prepare a two-qubit Bell state and then, to highlight how this approach can scale to utility-scale circuits on over 100-qubit circuits, we’ll generalize our approach.
Qiskit Resources:
GitHub notebook for this episode: github.com/derek-wang-ibm/cod...
Install Qiskit - qisk.it/cwq-install
Hello World Tutorial: docs.quantum.ibm.com/start/he...
Introduction to Primitives: docs.quantum.ibm.com/run/prim...
Error Suppression and Mitigation: docs.quantum.ibm.com/run/conf...
Qiskit Github Notebook: qisk.it/cwq-ep2
Miniconda: docs.anaconda.com/free/minico...
A free IDE: code.visualstudio.com/
Qiskit GitHub: github.com/Qiskit
IBM Quantum: quantum.ibm.com/
#ibmquantum #learnquantum #qiskit - Наука
Some lingo that may be useful!
1. Bell State
A Bell state in quantum computing is a special type of entangled state where two qubits are linked such that the state of one qubit instantly influences the state of the other, no matter the distance between them.
2. Superposition
The principle that a qubit can exist in multiple states (0 and 1) simultaneously, rather than being in a single state like a classical bit.
3. Hadamard Gate
A basic operation that transforms a qubit into an equal superposition of its 0 and 1 states, creating a state where the qubit has a 50% chance of being measured as 0 and a 50% chance of being measured as 1.
4. The CNOT (Controlled NOT) Gate A two-qubit operation where the state of the second qubit (target) is flipped if the first qubit (control) is in the state 1, otherwise, the target qubit remains unchanged.
5. Pauli Operators
A set of three basic matrices (Pauli-X, Pauli-Y, and Pauli-Z) used to describe quantum gates that can change the state of a qubit by flipping its state, rotating it, or inverting its phase.
In quantum computing, operators like ZZ, XX, and YY perform specific transformations on qubit states, altering their properties such as phase, amplitude, or entanglement.
Very helpful, thanks!
I was expecting the Qubit's to print "Hello World" 😂
Man it looks like I have a lot to learn.
Awesome Derek, a fantastic Qiskit Intro! Well done and keep going compiling the tutorials in the same style... really appreciated the condensed and swift walkthrough the code and step by step instructions... 👍
Thank you so much for the clear explanation, making it easy to follow and working on my end as well. I've now completed my very first job on the IBM quantum platform 🙂! Will definitely continue with this series and enhancing my quantum knowledge.
This is great to hear!
Nice to see new videos for qiskit 1.0 . Congratulations!!! But, instead of the estimator, how to calculate the count to create the histogram, as was previously done with get_counts?
You can use Sampler instead. I will show how this can be done in a future video dedicated to Primitives.
Great video! I am also getting stuck on how to implement get_counts on the new version
@@oluwapelumiolubayo2043 See the next episode on Primitives, where I show how to get counts with SamplerV2
Hey, is there any detailed class on operators or some other resource? That is one part I cant still wrap my head around.
Hi, thanks for these lessons! They are incredibly useful. I have a quick question, when we initialized the two qubits q0 and q1 are they automatically in the |0> state? (are they both in the same state..?)
The convention is to assume that the qubits start in the 0 state. For the two-qubit example, we then apply a Hadamard gate to the 0th qubit, so it would no longer be in the 0 state.
Hi Derek, great video and initiative! I attempted to implement a 5-qubit GHZ example on IBM Kyoto, but I received a warning that the task would take more than 10m to execute. Surprisingly, when I tried the same on IBM Brisbane, it completed in nearly 50 seconds. This compels me to ask: How can I determine which system is more suitable for a particular task? Many thanks in anticipation.
Unfortunately, I don't think there's a feature for estimating resource cost, especially on a device by device basis, until after you submit.
Is the transpiling section you used specific for the ibm_brisbane backend? Or can it be used for any device
It should work for any backend, as long as you swap out the backend name "ibm_brisbane" with your target backend. Some of the information being sent to the preset pass manager includes the coupling map, native gates, and number of gates, and these properties can of course change from device to device.
@@DerekWangIBM QiskitError: 'Number of qargs does not match (2 != 100)'
I keep having this error from the operators_transpiled_list. What could be the issue?
@@techjunk8467 It appears you did not create operators with 100 qubits. Instead, you are applying a layout for 100 qubits on observables that have 2 qubits, which are likely leftover from the initial 2-qubit example.
Sir can you please try the bb84 simulation using qiskit ?
Sir i have problem with installation process it just shows my name of pc in terminal anad when i try to create another environment for anaconda(like u) it just shows an error. Can you please help me to resolve my issue?
It sounds like `conda` is not active. See if it's installed by typing `conda --version` in your terminal. If conda is indeed there, try activating it: `conda init`. When conda is active, you should see (base) before your username. Once it's active, you should be able to create an environment within conda.
Happened to me also.
You have to start your terminal in "MiniConda mode". Go to Start Menu and type 'Anac' and there should be something like "Anaconda Prompt (miniconda3)". Start that command/script/program. Someone smarter than me should know how to do this in the VS Code.
@@HrvojeKalic Thank you! I only showed installation on Mac in the video. Glad that differences with PC could be resolved here.
@@HrvojeKalic thank you sir i will try and see if the problem is solved or not
@@DerekWangIBM thanks sir
When I tried to run the estimator part of the code it is showing that qc is not defined, why is it happening, is it because I refreshed the VS Code, because when I again run all of the code from the start it works
Run the block that defines the `qc` before trying to pass it into the Estimator.
Hello, I have an error saying that I am unauthorized with the code 'backend=QiskitRuntimeService().get_backend(backend_name)'. (16:40) Can you help me? Thanks!
It's possible you do not have access to that particular backend that I use in the video. Use a backend that you do have access to.
great!!
I did't get why we are intoducing operators and not just running the qc to get 50% |00> and 50 % |11> what are we doing here ?
Sure, one could do that too. In fact, we do exactly what you suggest in an upcoming video :)
@@DerekWangIBM Can't wait to see it, i'm trying to get a grasp of qiskit but there is son few documentation on version 1.X (except official one of course)
what extensions did you install for putting colors in the code?
I'm using the default dark color theme in Visual Studio Code.
@@DerekWangIBM I mean your QiskitRuntumeService is written in nice green color which is readable, but my code is all shown in white🥲
@@DerekWangIBM I was wondering about the color of the code because I can see nice readable green color from your library code but not in mine.
I am looking for BB84 simulation on Qiskit.
Sir, When i am to do:
from qiskit import IBMQ
this is showing error "ImportError Traceback (most recent call last)
Cell In[6], line 1
----> 1 from qiskit import IBMQ
ImportError: cannot import name 'IBMQ' from 'qiskit' (C:\Users\sachin.pathak\AppData\Local\anaconda3\Lib\site-packages\qiskit\__init__.py)"
even I have upgraded my qiskit to new version. Please suggest.
The module IBMQ does not exist in Qiskit I believe. If you're trying to access providers and backends, you'll need to `pip install qiskit-ibm-runtime`.
@@DerekWangIBM thanks for your reply. I already have installed ibm run time in my system still it is not working.
In Step 3 for the n-qubit GHZ state, I'm getting this error:
ValueError: cannot create object arrays from iterator
The line causing the error is:
job = estimator.run([(qc_transpiled, operators_transpiled_list)])
The Estimator().run() functions expects `qc_transpiled` and `operators_transpiled_list` to be lists, not iterators. So make sure you've actually instantiated these variables as lists.
@@DerekWangIBM The thing is, I followed exactly every step. The cell where these variables are defined run well. The other one does not. Not really sure what am I missing here.
def get_quantum_circuit(n):
qc = QuantumCircuit(n)
qc.h(0)
for i in range(n-1):
qc.cx(i, i+1)
return qc
n = 100
qc = get_quantum_circuit(n)
# qc.draw(output='mpl')
from qiskit.quantum_info import SparsePauliOp
operator_strings = ['Z' + 'I' * i + 'Z' + 'I' * (n - i - 2) for i in range(n - 1)]
print(operator_strings)
print(len(operator_strings))
operators = [SparsePauliOp(operator_string) for operator_string in operator_strings]
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
backend_name = "ibm_brisbane"
backend = QiskitRuntimeService().get_backend(backend_name)
pass_manager = generate_preset_pass_manager(optimization_level=1, backend=backend)
qc_transpiled = pass_manager.run(qc)
operators_transpiled_list = [op.apply_layout(qc_transpiled.layout) for op in operators]
from qiskit_ibm_runtime import EstimatorV2 as Estimator
from qiskit_ibm_runtime import EstimatorOptions
options = EstimatorOptions()
options.resilience_level = 1
options.optimization_level = 0
options.dynamical_decoupling.enable = True
options.dynamical_decoupling.sequence_type = "XY4"
estimator = Estimator(backend, options=options)
job = estimator.run([(qc_transpiled, operators_transpiled_list)])
job_id = job.job_id()
print(job_id)
Starting to see how I sound to my parents when explaining classical computing 😭
Hello sir I love this series so knowledgeable and amazing sir can I join ibm quantum as a student
You can visit the IBM quantum website, look for a careers page, and you might find something that interests you , you can apply there
The only thing I've learned in this video is that quantum software is in its infancy.
You all would benefit from watching my RUclips videos where I trained ChatGPT on my Quantum Language Model.
What is pauli ?
Pauli is referred to matrices, specif a set of three 2 × 2 complex matrices that are Hermitian, involutory and unitary.
Rather ask who is pauli
it would be excellent if the folks doing work in the quantum space would stop naming things after themselves and instead give them descriptive names.