Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

Qiskit Tools

Parallel Routines

A helper function for calling a custom function with python ProcessPoolExecutor. Tasks can be executed in parallel using this function. It has a built-in event publisher to show the progress of the parallel tasks.

parallel_map, values, task_args=(), task_kwargs={}, num_processes=2)

GitHub(opens in a new tab)

Parallel execution of a mapping of values to the function task. This is functionally equivalent to:

result = [task(value, *task_args, **task_kwargs) for value in values]

On Windows this function defaults to a serial implementation to avoid the overhead from spawning processes in Windows.


  • task (func) – Function that is to be called for each value in values.
  • values (array_like) – List or array of values for which the task function is to be evaluated.
  • task_args (list(opens in a new tab)) – Optional additional arguments to the task function.
  • task_kwargs (dict(opens in a new tab)) – Optional additional keyword argument to the task function.
  • num_processes (int(opens in a new tab)) – Number of processes to spawn.


The result list contains the value of

task(value, *task_args, **task_kwargs) for

each value in values.

Return type



QiskitError – If user interrupts via keyboard.


terra.parallel.start: The collection of parallel tasks are about to start. terra.parallel.update: One of the parallel task has finished. terra.parallel.finish: All the parallel tasks have finished.


import time
from import parallel_map
def func(_):
        return 0
parallel_map(func, list(range(10)));


A helper module to get IBM backend information and submitted job status.

job_monitor, interval=None, quiet=False, output=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, line_discipline='\r')

GitHub(opens in a new tab)

Monitor the status of a IBMQJob instance.


  • job (BaseJob) – Job to monitor.
  • interval (int(opens in a new tab)) – Time interval between status queries.
  • quiet (bool(opens in a new tab)) – If True, do not print status messages.
  • output (file) – The file like object to write status messages to.
  • sys.stdout. (By default this is) –
  • line_discipline (string) – character emitted at start of a line of job monitor output,
  • r. (This defaults to) –


from qiskit import BasicAer, transpile
from qiskit.circuit import QuantumCircuit
from import job_monitor
sim_backend = BasicAer.get_backend("qasm_simulator")
qc = QuantumCircuit(2, 2)
qc.h(0), 1)
tqc = transpile(qc, sim_backend)
job_sim =


GitHub(opens in a new tab)

Monitor a single IBMQ backend.


backend (IBMQBackend) – Backend to monitor.


Examples: .. code-block:: python

from qiskit.providers.ibmq import IBMQ from import backend_monitor provider = IBMQ.get_provider(hub=’ibm-q’) backend_monitor(provider.backends.ibmq_lima)


GitHub(opens in a new tab)

Gives overview information on all the IBMQ backends that are available.


from qiskit.providers.ibmq import IBMQ
from import backend_overview
provider = IBMQ.get_provider(hub='ibm-q')

Events (

A helper component for publishing and subscribing to events.



GitHub(opens in a new tab)

A simple text-based progress bar.

output_handlerthe handler the progress bar should be written to, default

is sys.stdout, another option is sys.stderr


The progress bar can be used to track the progress of a parallel_map.

import numpy as np
from import parallel_map
from import TextProgressBar
%qiskit_progress_bar -t text
parallel_map(np.sin, np.linspace(0,10,100));

And it can also be used individually.

from import TextProgressBar
iterations = 100
t = TextProgressBar()
for i in range(iterations):
    # step i of heavy calculation ...
    t.update(i + 1)  # update progress bar
Was this page helpful?
Report a bug or request content on GitHub.