Programming Quantum Computers with Qiskit and Qiskit...• Define quantum registers • Build quantum circuits • Compile circuits to run on desired backend • Submit jobs (in Qobj
Post on 09-May-2020
21 Views
Preview:
Transcript
Overview
arxiv.org/pdf/1905.02666.pdf
• Cloud-based quantum computers
• Composing quantum circuits
• The elements of Qiskit
• IQX platform tour
• What’s next
• Demo
IBM Q Experience
Launched May 4, 2016
Free, cloud-based GUI and programmatic access to small quantum devices and simulators
Detailed user guide with example algorithms
> 160,000 users
> 20 million experiments
> 200 scientific papers
© 2017 IBM Corporation4
Quantum computing through the cloud
Classical computer API server
Control computer
Control instruments
Quantum computer
Writing quantum circuits: the “quantum score”
arxiv.org/pdf/1905.02666.pdf
• “Textbook” way of showing quantum circuits
• Conducive to user-friendly drag-and-drop interface
• Useful for beginners studying simple circuits
• Becomes unmanageable for large/complex circuits
Writing quantum circuits: OpenQASM
arxiv.org/pdf/1905.02666.pdf
• Text-based circuit representation
• Equivalent to quantum score▪ The OpenQASM at right represents the quantum score on
the previous slide
• Good for sending basic commands to a quantum computer
• Not useful for writing circuits manually, but amenable to programmatic generation
Full specification: arxiv.org/pdf/1707.03429.pdf
Writing quantum circuits: OpenPulse
arxiv.org/pdf/1905.02666.pdf
• An even lower level than OpenQASM: direct control over theanalog pulses being sent to control and measure the qubits
• Programmatic generationis critical for building eventhe simplest circuits
Quantum programming desires
• Build and run circuits
• Study and mitigate errors
• Simulate device behavior
• Solve real-world problems
The elements of Qiskit
• Build and run circuits
• Study and mitigate errors
• Simulate device behavior
• Solve real-world problems
Terra
Aqua
Aer
Ignis
Open Source (Apache 2.0)
Written in Python 3
Modular and extendible
qiskit.org
© 2017 IBM Corporation11
The elements of Qiskit in action
Aqua
• Import problem
parameters from
domain-specific
software
• Execute suitable
algorithm in Terra
• Analyze results
and iterate as
appropriate to
solve problem
Terra
• Define quantum
registers
• Build quantum
circuits
• Compile circuits to
run on desired
backend
• Submit jobs (in
Qobj format) to
backends
• Retrieve results
Tutorials(Jupyter notebook-based)
• Run algorithms
• Visualize results
AerQASM simulator,
statevector simulator,
unitary simulator
Real backend A
computer, instruments,
wiring, quantum chip
AP
I S
erv
er
Real backend B
computer, instruments,
wiring, quantum chip
Simulator A
HPC cluster
Qobj
quantum
object
Results
(real or sim)
Results
(simulated)Instructions
Instructions
Results
Results
Ignis• Analysis and mitigation of noise and errors
© 2017 IBM Corporation12
Aqua
Aer
Ignis
Qiskit Terra
• Build and run circuits
• Study and mitigate errors
• Simulate device behavior
• Solve real-world problems
Terra
© 2017 IBM Corporation13
Qiskit Terra
▪Define → build → compile → run → retrieveCompile and run Get resultsBuild quantum circuits
State Counts
00000 513
00011 487
00000 00011
0.5
0.0
Pro
ba
bil
ity
Outcome
Qiskit Terra: building circuits
• QuantumCircuit(M,N) instantiates a quantum circuitacting on M quantum bits and N classical bits▪ Circuit operations are invoked as methods of this object
▪ Commonly used operations are defined in qiskit.extensions.standardo Single-qubit gates (iden, x, y, z, h, s, sdg, t, tdg, u1, u2, u3)
o Two-qubit gates (cx, cy, cz, cu1, cu2)
o Measurement, reset, and barrier (measure, reset, barrier)
• Example: prepare a Bell state▪ Make a circuit with 2 qubits and 2 bits
▪ Hadamard (h) on qubit 0
▪ CNOT (cx) from qubit 0 to qubit 1
Qiskit Terra: combining circuits
• Many ways to make complex circuits from simple ones
• Easiest is to use the + operator
• Example: measuring a Bell state in different bases
• Measurement is naturally in the Z basis
• Hadamard prior to measurement swaps
the X and Z axes
• Result: effective X-basis measurement
• | ۧ+ mapped to | ۧ0• | ۧ− mapped to | ۧ1
Qiskit Terra: more tricks with circuits
• The draw function can use matplotlib, LaTeX, or ASCII art
• Other features: width, depth, and other properties
• More: tutorial 4 in qiskit-iqx-tutorials/fundamentals
Qiskit Terra: backend providers
• Circuits are run on backends, which are accessed through providers
• Standard providers:▪ Aer (local simulators)
▪ IBMQ (IBM devices and simulators)
• Provider features:▪ List and filter available backends
▪ Provide backend objects
▪ IBMQ special function: least_busy
returns backend from the specified list
that has the shortest queue
arxiv.org/pdf/1905.02666.pdf
Qiskit Terra: backend details
• Retrieve configuration details (static):
• Retrieve qubit and gate properties (typically updated daily):
Qiskit Terra: executing a circuit
• execute makes it easy to run a set of circuits on any backend
• Optional arguments▪ memory: if True, return outcome of each individual shot in addition to aggregate counts
▪ initial_layout: manually specify mapping of circuit qubits onto physical qubits
▪ optimization_level: integer from 0 to 3 indicating how aggressively to optimize circuits
▪ See tutorial 5 in qiskit-iqx-tutorials/fundamentals for more options/details
• execute returns a job object immediately after submitting the job to the backend
© 2017 IBM Corporation20
Qiskit Terra: what execute actually does
▪execute does a lot behind the scenes:
• Verify circuit(s) can run on backend given its
number of qubits and coupling map
• Rewrite operations in terms of backend’s
defined basis gates
• Optimize mapping of circuit onto device
• Minimize number of swaps
• If desired, choose “best” qubits/gates
• Simplify gate sequences
• Submit compiled circuits to backend
Original Compiled
Compilation steps can be customized: see tutorial 4 in qiskit-iqx-tutorials/advanced/terra
• Check job ID, status, and queue position:
• Can also cancel jobs if desired
e.g. bell_job.cancel()
• Job ID can then be used to retrieve job
from backend at any later time:
• Alternatively, if job ID is lost, past jobs
can be retrieved in bulk:
Qiskit Terra: working with jobs
• After job finishes, get results and plot histogram of outcomes
• Strong correlation seen for
both choices of basis, a
signature of entanglement
Qiskit Terra: viewing results
More plotting options: tutorial 2 in qiskit-iqx-tutorials/fundamentals
Note on bit ordering: qubit 0 is
the right-most qubit!
Terra
Aqua
Aer
Qiskit Ignis
• Build and run circuits
• Study and mitigate errors
• Simulate device behavior
• Solve real-world problems
Ignis
Qiskit Ignis: Features
• Characterization▪ Coherence (T1 and T2)
▪ Gates (amplitude and angle calibrations)
▪ Hamiltonian (ZZ crosstalk measurement)
• Mitigation▪ Measurement error mitigation
• Verification▪ Quantum volume
▪ Randomized benchmarking
• Tomography (state and process)
Qiskit Ignis: example (error mitigation)
• Challenge: algorithm results are corrupted by SPAM errors
• Mitigation: systematic measurement errors can be calibrated out
• Ignis makes this easy!
Noisy results = A * (Ideal results)
Ideal results = A-1 * (Noisy results)
GHZ state
© 2017 IBM Corporation26
AquaIgnis
Terra Aer
Qiskit Aer
• Build and run circuits
• Study and mitigate errors
• Simulate device behavior
• Solve real-world problems
Qiskit Aer
• High-performance C++ simulator framework
▪ Provides backends to Qiskit Terra
• Simulator backends:
▪ Shot-by-shot QASM simulation (“qasm_simulator”)
▪Quantum state vector calculation (“statevector_simulator”)
▪Unitary operation calculation (“unitary_simulator”)
• Can incorporate noise:
▪Actual error rates
▪ Custom
Qiskit Aer: use in quantum volume studies
• Quantum volume experiments: run random circuits with specific form, compare observed to “expected” outcomes
• Definitions of “expected”:▪ State-vector calculation
▪ Shot-by-shot simulation
– Assuming ideal gates
– Using noise model based
on reported 1Q/2Q errors
• Questions of interest:▪ How do different types of errors
affect success probability?
▪ To what extent does noisy sim
capture actual device behavior?
IBM Q “Tokyo”
success threshold
Cross et al., arxiv:1811.12926
Quantum volume success probabilities:
experiment vs ideal and noisy simulations
Terra Aer
Ignis
Qiskit Aqua
• Build and run circuits
• Study and mitigate errors
• Simulate device behavior
• Solve real-world problems
Aqua
Qiskit Aqua
• High-level, application-specific modules
• Interfaces with domain-specific packages e.g. PySCF for chemistry
• Implements hybrid classical-quantum algorithms such as VQE
Qiskit on GitHub and PyPI
• All source code lives within github.com/Qiskit
• Key repositories:Core components (python packages)
▪ qiskit-terra, qiskit-ignis, qiskit-aer, qiskit-aqua: the four elements
▪ qiskit-ibmq-provider: the IBMQ provider for working with IBM backends
▪ qiskit: a metapackage including all of the above
Educational materials (Jupyter notebooks)
▪ qiskit-iqx-tutorials: a “standard” set of instructional Jupyter notebooks
▪ qiskit-community-tutorials: a wider variety of instructional Jupyter notebooks
▪ qiskit-textbook: an open-source quantum computing textbook using Qiskit
• pip install qiskit installs the latest Qiskitmetapackage release from PyPI
Qiskit.org
• A portal to everything Qiskit
• Lots of helpful info at qiskit.org/documentation/
Jupyter notebook environment
arxiv.org/pdf/1905.02666.pdf
Start a new notebook from scratch – or import one!
Creating a notebook
arxiv.org/pdf/1905.02666.pdf
• First cell is pre-populated with commonly-used stuff
What’s next
• “Homework”:▪ Create an IQX account
o quantum-computing.ibm.com
▪ Visit ibm.biz/explore_qiskito Create a GitHub account if you don’t already have one
▪ Select a listed topic, or come up with your own
▪ Start looking for 2 – 3 partners to work witho Post your topic as an “issue” in the WiSQCE repository linked from the project list, or join an existing topic
already posted there (i.e. “Assign yourself”)
o If more than 4 people are interested in a single topic, split into two groups!
• Plan for tomorrow:▪ 1:30 – 3:30pm: hands-on programming in small groups
▪ 3:30 – 4:00pm: coffee break
▪ 4:00 – 4:15pm: finish up and prepare to share
▪ 4:15 – 5:00pm: present your team’s findings to the rest of the group
top related