Note
This page was generated from docs/tutorials/2_jupyter_tools.ipynb.
Important: This notebook uses ipywidgets that take advantage of the javascript interface in a web browser. The downside is the functionality does not render well on saved notebooks. Run this notebook locally to see the widgets in action.
Qiskit Jupyter Tools#
Qiskit was designed to be used inside of the Jupyter notebook interface. As such it includes many useful routines that take advantage of this platform, and make performing tasks like exploring devices and tracking job progress effortless.
Loading all the qiskit Jupyter goodness is done via:
[1]:
from qiskit import *
from qiskit_ibm_provider import IBMProvider
import qiskit_ibm_provider.jupyter # This is the where the magic happens (literally).
To start, load your IBM Quantum account:
[2]:
provider = IBMProvider()
IBM Quantum Dashboard#
Perhaps the most useful Jupyter tool is the ibm_quantum_dashboard
. This widget consists of a Devices
tab and a Jobs
tab. The Devices
tab provides an overview of all the devices you have access to. The Jobs
tab automatically tracks and displays information for the jobs submitted in this session.
To start the dashboard you run the Jupyter magic:
[3]:
%ibm_quantum_dashboard
You should now see a small window titled “IBM Quantum Dashboard” in the upper left corner of the notebook. Click on the drop down symbol to see the two tabs. The Devices
tab may take a few seconds to load as it needs to communicate with the server for device information. The Jobs
tab should contain no job information as none has been submitted yet.
Getting an Overview of Backends#
The Devices
tab provides an overview of all the backends you have access to. You can use it to compare, for example, the average CNOT error rates. In addition, the number of pending jobs on the devices is continuously being updated along with the operational status.
Automatic Job Tracking#
The Jobs
tab automatically tracks and displays information for the jobs submitted in this session.
Now, let’s submit a job to a device to see this in action:
[4]:
from qiskit_ibm_provider import least_busy
backend = least_busy(
provider.backends(
simulator=False, filters=lambda b: b.configuration().n_qubits >= 5
)
)
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
mapped_circuit = transpile(qc, backend=backend)
job = backend.run(mapped_circuit, shots=1024)
Click on the Jobs
tab and you will see that the job has been added to the list of jobs. Its status, queue position (if any), and estimated start time are being automatically tracked and updated. If the job is running, the scheduling mode for the job is also displayed. For example, if the job status is RUNNING[F]
, that means the job is actively running and was scheduled using a fair-share algorithm. The button to the left of a job ID allows you to cancel the job.
If you want to kill the dashboard you can do so by calling:
[5]:
%disable_ibm_quantum_dashboard
Although the dashboard itself is killed, the underlying framework is still tracking jobs for you and will show this information if loaded once again.
Viewing Backend Details#
The IBM Quantum devices contain a large amount of configuration data and properties. This information can be retrieved by calling:
[6]:
config = backend.configuration()
params = backend.properties()
However, parsing through this information quickly becomes tedious. Instead, all the information for a single backend can be displayed graphically by just calling the backend instance itself:
[7]:
backend
[7]:
<IBMBackend('ibmq_belem')>
This widget displays all the information about a backend in a single tabbed-window.
[8]:
from qiskit_ibm_provider.version import __version__
print("qiskit-ibm-provider version: {}".format(__version__))
qiskit-ibm-provider version: 0.1.0
[9]:
import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright
Version Information
Qiskit Software | Version |
---|---|
qiskit-terra | 0.18.3 |
qiskit-aer | 0.9.0 |
qiskit-ignis | 0.6.0 |
qiskit-ibmq-provider (deprecated) | 0.17.0 |
qiskit-aqua (deprecated) | 0.9.5 |
qiskit | 0.31.0 |
System information | |
Python | 3.7.11 (default, Jul 27 2021, 07:03:16) [Clang 10.0.0 ] |
OS | Darwin |
CPUs | 8 |
Memory (Gb) | 32.0 |
Mon Sep 13 00:15:27 2021 EDT |
This code is a part of Qiskit
© Copyright IBM 2017, 2021.
This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.
[ ]: