0% found this document useful (0 votes)
34 views

Lecture 1.1

QGSS 2024 Lecture Notes

Uploaded by

Shashank S
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)
34 views

Lecture 1.1

QGSS 2024 Lecture Notes

Uploaded by

Shashank S
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/ 39

Qiskit Global Summer School 2024

Lecture 1:
Intro to Qiskit 1.0

Abby Mitchell
Developer Advocacy Lead
IBM Quantum
Anatomy of a
Quantum
quantum
computing service
programming
language

User

Cloud service
(Qiskit Runtime)

Pulse sequences
Server in
laboratory

Control
electronics

Quantum
processor
Qiskit Global Summer School 2024 2
Example final
result

Qiskit Global Summer School 2024 3


What is Qiskit?

Qiskit SDK is an open-source SDK for Qiskit Runtime is a cloud-based service


working with quantum computers at the for executing quantum computations on
level of extended quantum circuits, IBM Quantum hardware.
operators, and primitives.
https://github.com/Qiskit/qiskit-ibm-runtime
https://github.com/Qiskit/qiskit https://docs.quantum-computing.ibm.com/
https://docs.quantum-computing.ibm.com/ Runtime Primitives version 2
version 1.0 released Feb 2024 🎉 released March 2024 🎉

Qiskit Patterns is a framework for The Qiskit Ecosystem is a collection of


breaking down domain-specific software and projects that build on or extend
problems into stages. Qiskit.

http://qiskit.github.io/ecosystem

Qiskit Global Summer School 2024 4


Getting set up 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

Qiskit Global Summer School 2024 5


Qiskit Patterns

1. Map problem to 2. Optimize 3. Execute on 4. Postprocess


quantum circuits circuits for target target hardware results
and operators hardware

Qiskit Global Summer School 2024 6


Qiskit Patterns

1. Map problem 2. Optimize 3. Execute on 4. Postprocess


to quantum circuits for target target hardware results
circuits and hardware
operators

Qiskit Global Summer School 2024 7


To map a problem:

• Start with numerical representation


• Map to quantum computing representation
• Choose quantum algorithm
Qiskit Global Summer School 2024 8
Build a circuit with Qiskit SDK

The foundation of quantum programs are quantum circuits.

They consist of operations—including gates, measurement,


and reset—that manipulate qubits.

Qiskit Global Summer School 2024


9
Build a circuit with Qiskit SDK

To build a circuit:

• Initialize a register of qubits


• Add the qubits to a circuit
• Perform operations on those
qubits

Qiskit Global Summer School 2024


10
Standard gates

Hadamard, Pauli rotation gates, CNOT,


Quantum Fourier Transform, etc.
Qiskit SDK includes a
library of standard gates
and circuits. Variational ansatzes

Parameterized quantum circuits for


chemistry and combinatorial
optimization, including hardware
efficient ansatzes

Qiskit Global Summer School 2024 11


Qiskit Patterns

1. Map problem to 2. Optimize 3. Execute on 4. Postprocess


quantum circuits circuits for target target hardware results
and operators hardware

Qiskit Global Summer School 2024 12


Optimize for hardware – techniques

Required: transpile your abstract circuit into


a circuit that can run on target hardware.

Optional: verify your circuit with simulation.

Qiskit Global Summer School 2024 13


Optimize for hardware – techniques

Required: transpile your abstract circuit into a


circuit that can run on target hardware.

Optional: verify your circuit with simulation.

Qiskit Global Summer School 2024 14


Basis gate set Qubit connectivity Errors
Real
Only a limited set of gates Only certain pairs of qubits Each operation has a
quantum can be executed directly can be directly interacted chance of error, so circuit

devices are on the hardware. Other


gates must be rewritten in
with each other. optimizations can greatly
affect performance.
subject to terms of these basis
gates.
constraints

Qiskit Global Summer School 2024 15


Challenge: run abstract circuit on a
specific quantum device.

Solution: transpilation —
convert abstract circuit into an ISA
(instruction set architecture) circuit.

Qiskit Global Summer School 2024 16


Transpilation terms
Term Definition Orchestra analogy

pass a standalone circuit or metadata an instrument


transformation
pass a list of transpiler passes grouped into a an instrument
manager logical unit section

staged pass a list of pass managers, with each one the conductor
manager representing a discrete stage of a
transpilation pipeline

Qiskit Global Summer School 2024 17


Transpile a circuit with Qiskit SDK
Steps:

• Choose which device backend you want


to target
• Create a preset staged pass manager
with your desired optimization level
• Run the staged pass manager on the
circuit

Qiskit Global Summer School 2024 18


Transpiler stages

1. Initialization 2. Layout 3. Routing


The circuit is prepared for The abstract qubits of the Swap gates are inserted to
transpilation, e.g., multi-qubit circuit are mapped to enable interactions
gates are decomposed into physical qubits on the device. between qubits that are not
two-qubit gates. physically connected.

4. Translation 5. Optimization 6. Scheduling


The gates of the circuit are The circuit is rewritten to Delay instructions are
translated to the basis gate minimize its depth (# of added to align the circuit
set of the device. operations) to decrease the with the hardware’s timing.
effect of errors.

Qiskit Global Summer School 2024 19


Additional transpilation tools

• Qiskit transpiler service


• Qiskit Ecosystem, e.g., circuit-knitting-
toolbox
• Write your own transpiler plugins

Qiskit Global Summer School 2024 20


Optimize for hardware – techniques

Required: transpile your abstract circuit into a


circuit that can run on target hardware.

Optional: verify your circuit with simulation.

Qiskit Global Summer School 2024 21


Simulation tools
Qiskit SDK reference Qiskit Runtime local Qiskit Aer
primitives testing
Ecosystem project for
Exact simulation, but Provides “fake” simulation, including
small circuits only and backends to model
no noise simulation. each quantum machine. • larger circuits
• stabilizer circuits
• noise models

Qiskit Global Summer School 2024 22


Problem: the runtime cost of
simulating quantum circuits Techniques for large circuits:
scales exponentially with the
number of qubits. 1. Test smaller versions of circuit
2. Modify circuit so that it
becomes classically
~50+ qubits cannot be simulatable: stabilizer circuit
simulated. aka Clifford circuit

Qiskit Global Summer School 2024 23


Qiskit Patterns

1. Map problem to 2. Optimize 3. Execute on 4. Postprocess


quantum circuits circuits for target target hardware results
and operators hardware

Qiskit Global Summer School 2024 24


Sampler primitive Estimator primitive

Primitives encapsulate
the output of a
quantum circuit Output is mapping of
bitstrings to counts, e.g.,
Output is the expectation
value of an observable,
e.g., the net spin of a
{'0': 12, '1': 9}
system.
Circuit should include
Circuit should not include
measurements.
measurements.

Qiskit Global Summer School 2024 25


To run a circuit on quantum
hardware:

1. Initialize the Qiskit Runtime


service
2. Choose a hardware backend
3. Initialize a Qiskit Runtime
primitive with your chosen
backend
4. Invoke the primitive with
your circuit

Qiskit Global Summer School 2024 26


The input to the Estimator
primitive is a list of primitive
unified blocs (PUBs). Each PUB
consists of:

• A single circuit without


measurements
• One or more observables
• (Optional) One or more
parameter values

Qiskit Global Summer School 2024 27


Shots Error Error
The number of suppression mitigation
measurements.
You can More shots reduce
Use dynamical decoupling Reduce the effects of
to reduce decoherence device noise after
customize statistical error but during execution. execution.
Qiskit Runtime increase running time.
• Twirled Readout Error
Caveat: requires delays
behavior between gate executions, eXtinction (TREX)
measurement twirling
so it’s not always possible.
• Zero Noise Extrapolation
(ZNE)

Downside: computational
overhead

Qiskit Global Summer School 2024 28


Execution modes
• Single job
• Batch: multiple concurrent jobs
• Session: iterative workload

Qiskit Global Summer School 2024 29


Benefits of batch mode versus a single job with
multiple circuits:

• better concurrency of classical processing


• get individual results sooner

Qiskit Global Summer School 2024 30


Batch mode

Qiskit Global Summer School 2024 31


Sessions allow iterative workloads, like VQE.

Qiskit Global Summer School 2024 32


Sessions

Qiskit Global Summer School 2024 33


Qiskit Patterns

1. Map problem to 2. Optimize 3. Execute on 4. Postprocess


quantum circuits circuits for target target hardware results
and operators hardware

Qiskit Global Summer School 2024 34


Postprocess technique: visualize
results

With Sampler output, use


plot_histogram() from
qiskit.visualizations

Qiskit Global Summer School 2024 35


Postprocess technique: post-selection

Discard outputs known to be incorrect based on prior


knowledge, e.g., if you know outputs must match a certain
pattern

["1111", "1010", "1010", "1110"]

["1010", "1010", "1110"]

Qiskit Global Summer School 2024 36


Postprocess technique: circuit knitting

1. During the optimize for


hardware step, decompose the
problem into smaller circuits,
i.e., “circuit cutting”.
2. Execute smaller circuits.
3. “Knit” the results into a
reconstruction of the original
circuit’s outcome.

Qiskit Global Summer School 2024 37


Qiskit Patterns

1. Map problem to 2. Optimize 3. Execute on 4. Postprocess


quantum circuits circuits for target target hardware results
and operators hardware

Qiskit Global Summer School 2024 38


docs.quantum.ibm.com
Documentation for Qiskit and IBM Quantum services.

learning.quantum.ibm.com
Courses on quantum computing and how to use IBM
Quantum services to solve real-world problems.

www.youtube.com/qiskit
Lectures, tips & tricks, tutorials, community
updates, and exclusive Qiskit content!

Qiskit Global Summer School 2024 39

You might also like