0% found this document useful (0 votes)
89 views31 pages

Qiskit 101

Qiskit is an open-source SDK for quantum computing that allows users to build, transpile, verify, and run quantum circuits. It includes a variety of tools and primitives for simulating quantum circuits, optimizing performance, and mitigating errors. Users can access IBM's quantum hardware through Qiskit Runtime, which facilitates efficient execution of quantum programs.

Uploaded by

kshubh0701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views31 pages

Qiskit 101

Qiskit is an open-source SDK for quantum computing that allows users to build, transpile, verify, and run quantum circuits. It includes a variety of tools and primitives for simulating quantum circuits, optimizing performance, and mitigating errors. Users can access IBM's quantum hardware through Qiskit Runtime, which facilitates efficient execution of quantum programs.

Uploaded by

kshubh0701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Quantum

Computing with
Qiskit

IBM Quantum
What is Qiskit?

Qiskit is an open-source SDK for The Qiskit Ecosystem is a


working with quantum computers collection of software and
at the level of extended quantum tutorials that build on or extend
circuits, operators, and primitives. Qiskit.

https://github.com/Qiskit/qiskit http://qiskit.github.io/ecosystem
https://docs.quantum-computing.ibm.com/

IBM Quantum 2
Getting started
with Qiskit

pip install 'qiskit[visualization]'


pip install qiskit-ibm-runtime

To access IBM hardware, set up your credentials


through one of:
• IBM Quantum Platform
• IBM Cloud

https://docs.quantum-computing.ibm.com/start

IBM Quantum 3
Qiskit workflow

Build Transpile Verify Run


Design and develop quantum Optimize circuits to efficiently Validate and evaluate your Execute programs on quantum
circuits run on hardware quantum circuits hardware via Qiskit Runtime

https://docs.quantum.ibm.com/build https://docs.quantum.ibm.com/transpile https://docs.quantum.ibm.com/verify https://docs.quantum.ibm.com/run

IBM Quantum 4
Build
In the build phase, you create
quantum programs that represent
the problem you are solving.

IBM Quantum 5
Build a circuit with Qiskit

The foundation of quantum To build a circuit:


programs are quantum circuits,
which consist of operations - • Initialize a register of qubits
including gates, measurement,
and reset - that manipulate • Add the qubits to a circuit
qubits in the quantum
computer. • Perform operations on those
qubits

IBM Quantum 6
The output of a quantum Sampler primitive Estimator primitive

circuit is encapsulated by
primitives

Output is a (quasi-)probability Output is the expectation value of an


distribution over possible observable (e.g. cost function of an
measurement outcomes optimization problem)

Circuit should include Circuit should not include


measurements measurements

IBM Quantum 7
Standard gates Variational ansatzes

Standard quantum gates such Parameterized quantum


Qiskit includes a library of as Hadamard, Pauli rotation circuits for chemistry and
gates, CNOT, Quantum Fourier combinatorial optimization,
standard gates and common Transform... include hardware efficient
ansatzes

circuits

Benchmarking circuits And more!

Circuits used for measuring


quantum volume and other
benchmarks of quantum
devices

IBM Quantum 8
Transpile
In the transpile phase, you rewrite
your circuit into a form that can be
efficiently executed on a quantum
device

IBM Quantum 9
Real quantum Basis gate set Qubit connectivity Errors
devices are
subject to Only a limited set of gates can be Only certain pairs of qubits can be Each operation has a chance of

constraints executed directly on the hardware.


Other gates must be rewritten in
directly interacted with each other. error, so circuit optimizations can
greatly affect performance.
terms of these basis gates.

IBM Quantum 10
Transpiler definitions

Transpilation occurs in a series A transpiler pass defines a A pass manager is a list of A staged pass manager is a list
of passes, with the output of standalone circuit transpiler passes grouped into of pass managers, with each
one pass becoming the input to transformation. a logical unit. one representing a discrete
the next. stage of a transpilation
pipeline.

IBM Quantum 11
Transpiler stages
1 2 3
Initialization Layout Routing
The circuit is prepared for The abstract qubits of the Swap gates are inserted to
transpilation. circuit are mapped to physical enable interactions between
qubits on the device. qubits that are not physically
connected.

4 5 6
Translation Optimization Scheduling
The gates of the circuit are The circuit is rewritten to The precise timing of pulse
translated to the basis gate set minimize its depth or number sequences is determined
of the device. of operations in order to based on hardware
decrease the effect of errors. information.

IBM Quantum 12
Transpile a circuit

Qiskit can transpile your circuit To transpile a circuit using Qiskit's


for you with reasonable default presets:
settings.
• Choose which device backend
you want to target

• Create a preset staged pass


manager with your desired
optimization level

• Run the pass manager on the


circuit

IBM Quantum 13
You don't need to transpile
your circuits to submit them
to Qiskit Runtime!

But for the best performance, you should


design your own transpilation pipeline.

If you transpile your circuits locally, remember to set


skip_transpilation=True (more on this later).

IBM Quantum 14
Verify
In the verify phase, you test your
quantum programs by running
them on simulated devices and
exploring their performance under
realistic device noise models.

IBM Quantum 15
Simulating quantum circuits

The cost of simulating Roughly speaking, circuits larger than 50


qubits can't be simulated.
quantum circuits scales
exponentially with the For such large circuits, you can:
number of qubits.
Test smaller versions of Modify the circuit so that it
your circuit becomes classically
simulable (e.g. a stabilizer
circuit)

IBM Quantum 16
Simulation tools

Several Reference Qiskit Aer Qiskit Aer stabilizer


simulation tools primitives included primitives simulator
are available for with Qiskit
verifying your For higher-performance simulation For efficient simulation of stabilizer

quantum For exact simulation of small


that can handle larger circuits, or to
incorporate noise models
circuits

programs quantum circuits

https://qiskit.org/ecosystem/aer/

IBM Quantum 17
Use the Estimator primitive
from Qiskit Aer

The Estimator primitive is used To use the Estimator primitive,


to estimate the expectation pass it:
value of an observable.
• A circuit without measurements

• An observable

Measure
expectation
value of ZZ

IBM Quantum 18
Simulate noise Calibration data for ibm_brisbane
9am ET, Nov 16, 2023
https://quantum-computing.ibm.com/

Real quantum devices are


subject to errors. These errors
vary across different devices,
different qubits and
connections on the same
device, and time.

In the near term, a variety of


error-mitigation techniques
help us counter the effects of
noise.

In the long term, we will use


error-correction to build fault-
tolerant quantum computers.

IBM Quantum 19
Build noise models with Qiskit Aer

You can use Qiskit Aer to build You can initialize a noise model
and simulate noise models. with parameters set from the
calibration data of a real backend.

You can also build your own


custom noise models from
scratch.

Depolarizing error:

IBM Quantum 20
Stabilizer circuits can be
simulated efficiently

Stabilizer circuits are a special To simulate a stabilizer circuit, use


restricted class of circuits that a Qiskit Aer primitive with the
can be efficiently simulated "stabilizer" simulation method.
classically.

Stabilizer circuit if every 𝜃 is an integer multiple of 𝜋/2

IBM Quantum 21
Run
In the run phase, you send your
quantum program to be executed
on a quantum system.

IBM Quantum 22
Anatomy of a quantum
computing service

Quantum
programming
language

User

Cloud service
(Qiskit Runtime)

Pulse sequences
Server in
laboratory

Control
electronics

Quantum
processor
IBM Quantum 23
Run a circuit on quantum
hardware using Qiskit Runtime

Running a circuit on a real To run a circuit on quantum


quantum device is similar to hardware:
running it on a simulator. The
main difference is that you use • Initialize the Qiskit Runtime
a Qiskit Runtime primitive and service (requires setting up
choose the hardware backend account credentials
you want to use. beforehand)

• Initialize a Qiskit Runtime


primitive

• Invoke the primitive with


your circuit

IBM Quantum 24
Qiskit Runtime sessions Jobs within an active session A session becomes active
take priority over other queued when its first job starts running.
jobs.
A session allows a collection of jobs to
be grouped and jointly scheduled by
the Qiskit Runtime service, facilitating
iterative use of quantum computers
without incurring queuing delays on
each iteration.
A session stays active until one Note: The queuing time does
of the following happens: not decrease for the first job
• Its maximum timeout value submitted within a session.
is reached.
• Its interactive timeout value
is reached. In this case the
session is deactivated but
can be resumed if another
session job starts running.
• The session is closed or
cancelled.

IBM Quantum 25
Qiskit Runtime sessions

IBM Quantum 26
Run jobs in a session

A session is typically created as To run jobs in a session:


a context manager using the
with statement. The context • Initialize the Qiskit Runtime
manager takes care of closing service
the session when you're done.
• Initialize a session as a
context manager, specifying
the backend

• Initialize a Qiskit Runtime


primitive within the session

• Invoke the primitive as


usual

IBM Quantum 27
Customize Qiskit Runtime
behavior

Several options Shots Runtime Error mitigation


are available to transpilation
customize the The number of measurement Several error mitigation techniques

behavior of Qiskit shots used by the primitives to


compute their results. Increasing The primitives may perform runtime
are available to help you counter the
effects of device noise. These
Runtime this value lowers statistical error, transpilation to optimize circuits,
with the degree of optimization
techniques incur computational
but increases running time. overhead and should be evaluated
primitives controlled by an optimization level case-by-case.
option. The optimization level you
choose affects the transpilation
strategy, with higher levels invoking
more expensive or aggressive
optimizations.

IBM Quantum 28
Configuring runtime transpilation

The primitives expose preset


transpilation configurations via Optimization level Effect
the optimization_level
option. No optimization: typically used for
hardware characterization or debugging
0 • Basis translation
You can also elect to • Layout (as specified)
disable runtime transpilation • Routing (stochastic swaps)
using the
skip_transpilation
Light optimization:
option. • Layout (trivial → vf2 → SabreLayout if
1 routing is required)
[Default] • Routing (SabreSWAPs if needed)
• 1Q gate optimization
• Error suppression: dynamical decoupling

IBM Quantum 29
Configuring error mitigation

Resilience level Definition Estimator Sampler


The primitives expose error
mitigation via the 0 No mitigation
resilience_level option.
Minimal mitigation costs:
1 Twirled Readout Error Matrix-free Measurement
Mitigate error associated
Higher resilience levels incur a [Default] eXtinction (TREX) Mitigation (M3)
with readout errors
greater cost.
Medium mitigation costs.
Typically reduces bias in
Zero Noise Extrapolation
2 estimators, but is not
(ZNE)
guaranteed to be zero-
bias.

Heavy mitigation with


layer sampling.
Probabilistic Error
3 Theoretically expected to
Cancellation (PEC)
deliver zero-bias
estimators.

IBM Quantum 30
Links IBM Quantum https://docs.quantum-computing.ibm.com/
Documentation
Access the documentation for Qiskit and IBM
Quantum services.

IBM Quantum https://learning.quantum-computing.ibm.com/


Learning
Learn the basics of quantum computing, and how
to use IBM Quantum services and systems to
solve real-world problems.

Qiskit YouTube https://www.youtube.com/qiskit

Join us for engaging lectures, tips & tricks,


tutorials, community updates and access to
exclusive Qiskit content!

IBM Quantum 31

You might also like