BackendV2
class qiskit.providers.BackendV2(provider=None, name=None, description=None, online_date=None, backend_version=None, **fields)
Abstract class for Backends
This abstract class is to be used for all Backend objects created by a provider. This version differs from earlier abstract Backend classes in that the configuration attribute no longer exists. Instead, attributes exposing equivalent required immutable properties of the backend device are added. For example backend.configuration().n_qubits
is accessible from backend.num_qubits
now.
The options
attribute of the backend is used to contain the dynamic user configurable options of the backend. It should be used more for runtime options that configure how the backend is used. For example, something like a shots
field for a backend that runs experiments which would contain an int for how many shots to execute.
If migrating a provider from BackendV1
one thing to keep in mind is for backwards compatibility you might need to add a configuration method that will build a BackendConfiguration
object and BackendProperties
from the attributes defined in this class for backwards compatibility.
A backend object can optionally contain methods named get_translation_stage_plugin
and get_scheduling_stage_plugin
. If these methods are present on a backend object and this object is used for transpile()
or generate_preset_pass_manager()
the transpilation process will default to using the output from those methods as the scheduling stage and the translation compilation stage. This enables a backend which has custom requirements for compilation to specify a stage plugin for these stages to enable custom transformation of the circuit to ensure it is runnable on the backend. These hooks are enabled by default and should only be used to enable extra compilation steps if they are required to ensure a circuit is executable on the backend or have the expected level of performance. These methods are passed no input arguments and are expected to return a str
representing the method name which should be a stage plugin (see: qiskit.transpiler.preset_passmanagers.plugin
for more details on plugins). The typical expected use case is for a backend provider to implement a stage plugin for translation
or scheduling
that contains the custom compilation passes and then for the hook methods on the backend object to return the plugin name so that transpile()
will use it by default when targetting the backend.
Subclasses of this should override the public method run()
and the internal _default_options()
:
_default_options
abstract classmethod _default_options()
Return the default options
This method will return a qiskit.providers.Options
subclass object that will be used for the default options. These should be the default parameters to use for the options of the backend.
Returns
A options object with
default values set
Return type
Initialize a BackendV2 based backend
Parameters
- provider (Provider) – An optional backwards reference to the
Provider
object that the backend is from - name (str) – An optional name for the backend
- description (str) – An optional description of the backend
- online_date (datetime) – An optional datetime the backend was brought online
- backend_version (str) – An optional backend version string. This differs from the
version
attribute asversion
is for the abstractBackend
abstract interface version of the object whilebackend_version
is for versioning the backend itself. - fields – kwargs for the values to use to override the default options.
Raises
AttributeError – If a field is specified that’s outside the backend’s options
Attributes
coupling_map
Return the CouplingMap
object
dt
Return the system time resolution of input signals
This is required to be implemented if the backend supports Pulse scheduling.
Returns
The input signal timestep in seconds. If the backend doesn’t define dt
, None
will be returned.
dtm
Return the system time resolution of output signals
Returns
The output signal timestep in seconds.
Raises
NotImplementedError – if the backend doesn’t support querying the output signal timestep
instruction_durations
Return the InstructionDurations
object.
instruction_schedule_map
Return the InstructionScheduleMap
for the instructions defined in this backend’s target.
The property qiskit.providers.backend.BackendV2.instruction_schedule_map
is deprecated as of Qiskit 1.3. It will be removed in Qiskit 2.0. The entire Qiskit Pulse package is being deprecated and will be moved to the Qiskit Dynamics repository: https://github.com/qiskit-community/qiskit-dynamics. Note that once removed, qiskit.providers.backend.BackendV2.instruction_schedule_map
will have no alternative in Qiskit.
instructions
A list of Instruction tuples on the backend of the form (instruction, (qubits)
max_circuits
The maximum number of circuits (or Pulse schedules) that can be run in a single job.
If there is no limit this will return None
meas_map
Return the grouping of measurements which are multiplexed
This is required to be implemented if the backend supports Pulse scheduling.
Returns
The grouping of measurements which are multiplexed
Raises
NotImplementedError – if the backend doesn’t support querying the measurement mapping
num_qubits
Return the number of qubits the backend has.
operation_names
A list of instruction names that the backend supports.
operations
A list of Instruction
instances that the backend supports.
options
Return the options for the backend
The options of a backend are the dynamic parameters defining how the backend is used. These are used to control the run()
method.
provider
target
version
Default value: 2
name
Name of the backend.
description
Optional human-readable description.
online_date
Date that the backend came online.
backend_version
Version of the backend being provided. This is not the same as BackendV2.version
, which is the version of the Backend
abstract interface.
Methods
acquire_channel
acquire_channel(qubit)
Return the acquisition channel for the given qubit.
This is required to be implemented if the backend supports Pulse scheduling.
The method qiskit.providers.backend.BackendV2.acquire_channel()
is deprecated as of Qiskit 1.3. It will be removed in Qiskit 2.0. The entire Qiskit Pulse package is being deprecated and will be moved to the Qiskit Dynamics repository: https://github.com/qiskit-community/qiskit-dynamics. Note that once removed, qiskit.providers.backend.BackendV2.acquire_channel()
will have no alternative in Qiskit.
Returns
The Qubit measurement acquisition line.
Return type
Raises
NotImplementedError – if the backend doesn’t support querying the measurement mapping
control_channel
control_channel(qubits)
Return the secondary drive channel for the given qubit
This is typically utilized for controlling multiqubit interactions. This channel is derived from other channels.
This is required to be implemented if the backend supports Pulse scheduling.
The method qiskit.providers.backend.BackendV2.control_channel()
is deprecated as of Qiskit 1.3. It will be removed in Qiskit 2.0. The entire Qiskit Pulse package is being deprecated and will be moved to the Qiskit Dynamics repository: https://github.com/qiskit-community/qiskit-dynamics. Note that once removed, qiskit.providers.backend.BackendV2.control_channel()
will have no alternative in Qiskit.
Parameters
qubits (Iterable[int]) – Tuple or list of qubits of the form (control_qubit, target_qubit)
.
Returns
The multi qubit control line.
Return type
List[ControlChannel]
Raises
NotImplementedError – if the backend doesn’t support querying the measurement mapping
drive_channel
drive_channel(qubit)
Return the drive channel for the given qubit.
This is required to be implemented if the backend supports Pulse scheduling.
The method qiskit.providers.backend.BackendV2.drive_channel()
is deprecated as of Qiskit 1.3. It will be removed in Qiskit 2.0. The entire Qiskit Pulse package is being deprecated and will be moved to the Qiskit Dynamics repository: https://github.com/qiskit-community/qiskit-dynamics. Note that once removed, qiskit.providers.backend.BackendV2.drive_channel()
will have no alternative in Qiskit.
Returns
The Qubit drive channel
Return type
Raises
NotImplementedError – if the backend doesn’t support querying the measurement mapping
measure_channel
measure_channel(qubit)
Return the measure stimulus channel for the given qubit.
This is required to be implemented if the backend supports Pulse scheduling.
The method qiskit.providers.backend.BackendV2.measure_channel()
is deprecated as of Qiskit 1.3. It will be removed in Qiskit 2.0. The entire Qiskit Pulse package is being deprecated and will be moved to the Qiskit Dynamics repository: https://github.com/qiskit-community/qiskit-dynamics. Note that once removed, qiskit.providers.backend.BackendV2.measure_channel()
will have no alternative in Qiskit.
Returns
The Qubit measurement stimulus line
Return type
Raises
NotImplementedError – if the backend doesn’t support querying the measurement mapping
qubit_properties
qubit_properties(qubit)
Return QubitProperties for a given qubit.
If there are no defined or the backend doesn’t support querying these details this method does not need to be implemented.
Parameters
qubit (int |List[int]) – The qubit to get the QubitProperties
object for. This can be a single integer for 1 qubit or a list of qubits and a list of QubitProperties
objects will be returned in the same order
Returns
The QubitProperties
object for the specified qubit. If a list of qubits is provided a list will be returned. If properties are missing for a qubit this can be None
.
Raises
NotImplementedError – if the backend doesn’t support querying the qubit properties
Return type
run
abstract run(run_input, **options)
Run on the backend.
This method returns a Job
object that runs circuits. Depending on the backend this may be either an async or sync call. It is at the discretion of the provider to decide whether running should block until the execution is finished or not: the Job class can handle either situation.
Parameters
- run_input (QuantumCircuit orSchedule orScheduleBlock orlist) – An individual or a list of
QuantumCircuit
,ScheduleBlock
, orSchedule
objects to run on the backend. - options – Any kwarg options to pass to the backend for running the config. If a key is also present in the options attribute/object then the expectation is that the value specified will be used instead of what’s set in the options object.
Returns
The job object for the run
Return type
set_options
set_options(**fields)
Set the options fields for the backend
This method is used to update the options of a backend. If you need to change any of the options prior to running just pass in the kwarg with the new value for the options.
Parameters
fields – The fields to update the options
Raises
AttributeError – If the field passed in is not part of the options