IBMQJobManager
class IBMQJobManager
Bases: object
Job Manager for IBM Quantum Experience.
The Job Manager is a higher level mechanism for handling jobs
composed of multiple circuits or pulse schedules. It splits the experiments into multiple jobs based on backend restrictions. When the jobs are finished, it collects and presents the results in a unified view.
You can use the run()
method to submit multiple experiments with the Job Manager:
from qiskit import IBMQ, transpile
from qiskit.providers.ibmq.managed import IBMQJobManager
from qiskit.circuit.random import random_circuit
provider = IBMQ.load_account()
backend = provider.get_backend('ibmq_qasm_simulator')
# Build a thousand circuits.
circs = []
for _ in range(1000):
circs.append(random_circuit(num_qubits=5, depth=4, measure=True))
# Need to transpile the circuits first.
circs = transpile(circs, backend=backend)
# Use Job Manager to break the circuits into multiple jobs.
job_manager = IBMQJobManager()
job_set_foo = job_manager.run(circs, backend=backend, name='foo')
The run()
method returns a ManagedJobSet
instance, which represents the set of jobs for the experiments. You can use the ManagedJobSet
methods, such as statuses()
, results()
, and error_messages()
to get a combined view of the jobs in the set. For example:
results = job_set_foo.results()
results.get_counts(5) # Counts for experiment 5.
The job_set_id()
method of ManagedJobSet
returns the job set ID, which can be used to retrieve the job set later:
job_set_id = job_set_foo.job_set_id()
retrieved_foo = job_manager.retrieve_job_set(job_set_id=job_set_id, provider=provider)
IBMQJobManager constructor.
Methods
job_sets
IBMQJobManager.job_sets(name=None)
Return job sets being managed in this session, subject to optional filtering.
Parameters
name (Optional
[str
]) – Name of the managed job sets.
Return type
List
[ManagedJobSet
]
Returns
A list of managed job sets that match the filter.
report
IBMQJobManager.report(detailed=True)
Return a report on the statuses of all jobs managed by this Job Manager.
Parameters
detailed (bool
) – True
if a detailed report is to be returned. False
if a summary report is to be returned.
Return type
str
Returns
A report on job statuses.
retrieve_job_set
IBMQJobManager.retrieve_job_set(job_set_id, provider, refresh=False)
Retrieve a previously submitted job set.
Parameters
- job_set_id (
str
) – Job set ID. - provider (
AccountProvider
) – Provider used for this job set. - refresh (
bool
) – IfTrue
, re-query the server for the job set information. Otherwise return the cached value.
Return type
Returns
Retrieved job set.
Raises
- IBMQJobManagerUnknownJobSet – If the job set cannot be found.
- IBMQJobManagerInvalidStateError – If jobs for this job set are found but have unexpected attributes.
run
IBMQJobManager.run(experiments, backend, name=None, max_experiments_per_job=None, job_share_level=None, job_tags=None, **run_config)
Execute a set of circuits or pulse schedules on a backend.
The circuits or schedules will be split into multiple jobs. Circuits or schedules in a job will be executed together in each shot.
Parameters
-
experiments (
Union
[QuantumCircuit
,Schedule
,List
[QuantumCircuit
],List
[Schedule
]]) – Circuit(s) or pulse schedule(s) to execute. -
backend (
IBMQBackend
) – Backend to execute the experiments on. -
name (
Optional
[str
]) – Name for this set of jobs. Each job within the set will have a job name that consists of the set name followed by a suffix. If not specified, the current date and time is used. -
max_experiments_per_job (
Optional
[int
]) – Maximum number of experiments to run in each job. If not specified, the default is to use the maximum allowed by the backend. If the specified value is greater the maximum allowed by the backend, the default is used. -
job_share_level (
Optional
[str
]) – Allow sharing the jobs at the hub, group, project, or global level. The level can be one of:global
,hub
,group
,project
, andnone
. -
job_tags (
Optional
[List
[str
]]) – Tags to be assigned to the jobs. The tags can subsequently be used as a filter in theIBMQBackend.jobs()
function call. -
run_config (
Any
) –Configuration of the runtime environment. Some examples of these configuration parameters include:
qobj_id
,qobj_header
,shots
,memory
,seed_simulator
,qubit_lo_freq
,meas_lo_freq
,qubit_lo_range
,meas_lo_range
,schedule_los
,meas_level
,meas_return
,meas_map
,memory_slot_size
,rep_time
, andparameter_binds
.Refer to the documentation on
qiskit.compiler.assemble()
for details on these arguments.
Return type
Returns
A ManagedJobSet
instance representing the set of jobs for the experiments.
Raises
IBMQJobManagerInvalidStateError – If an input parameter value is not valid.