DynamicsBackend

class DynamicsBackend(solver, target=None, **options)[source]

Bases: BackendV2

Pulse-level simulator backend.

This class provides a BackendV2 interface wrapper around a Solver instance setup to simulate pulse schedules. The backend can be configured to take advantage of standard transpilation infrastructure to describe pulse-level simulations in terms of QuantumCircuits. Results are returned as Result instances.

A minimal DynamicsBackend requires specifying only a Solver instance and a list of subsystem dimensions, indicating the subsystem decomposition of the model in Solver. For example, the following code builds a DynamicsBackend around a Solver and indicates that the system specified by the Solver decomposes as two 3 dimensional subsystems.

backend = DynamicsBackend(
    solver=solver, subsystem_dims=[3, 3]
)

Without further configuration, the above backend can be used to simulate either Schedule or ScheduleBlock instances.

Pulse-level simulations defined in terms of QuantumCircuit instances can also be performed if each gate in the circuit has a corresponding pulse-level definition, either as an attached calibration, or as an instruction contained in backend.target.

Supported options

The behaviour of the backend can be configured via the following options. These can either be passed as optional keyword arguments at construction, set with the DynamicsBackend.set_options() method after construction, or passed as runtime arguments to DynamicsBackend.run().

  • shots: Number of shots per experiment. Defaults to 1024.

  • solver: The Qiskit Dynamics Solver instance used for simulation.

  • solver_options: Dictionary containing optional kwargs for passing to Solver.solve(), indicating solver methods and options. Defaults to the empty dictionary {}.

  • subsystem_dims: Dimensions of subsystems making up the system in solver. Defaults to [solver.model.dim].

  • meas_map: Measurement map. Defaults to [[idx] for idx in range(len(subsystem_dims))].

  • control_channel_map: A dictionary mapping control channel labels to indices, to be used for control channel index lookup in the DynamicsBackend.control_channel() method.

  • initial_state: Initial state for simulation, either the string "ground_state", indicating that the ground state for the system Hamiltonian should be used, or an arbitrary Statevector or DensityMatrix. Defaults to "ground_state".

  • normalize_states: Boolean indicating whether to normalize states before computing outcome probabilities, and normalize probablities before sampling. Defaults to True. Setting to False can result in errors if the solution tolerance results in probabilities with significant numerical deviation from a proper probability distribution.

  • meas_level: Form of measurement output. Supported values are 1 and 2. 1 returns IQ points and 2 returns counts. Defaults to meas_level == 2.

  • meas_return: Level of measurement data to return. For meas_level = 1 "single" returns output from every shot. "avg" returns average over shots of measurement output. Defaults to "avg".

  • iq_centers: Centers for IQ distribution when using meas_level==1 results. Must have type List[List[List[float, float]]] formatted as iq_centers[subsystem][level] = [I, Q]. If None, the iq_centers are dynamically generated to be equally spaced points on a unit circle with ground-state at (1, 0). The default is None.

  • iq_width: Standard deviation of IQ distribution around the centers for meas_level==1. Must be a positive float. Defaults to 0.2.

  • max_outcome_level: For meas_level == 2, the maximum outcome for each subsystem. Values will be rounded down to be no larger than max_outcome_level. Must be a positive integer or None. If None, defaults to 1.

  • memory: Boolean indicating whether to return a list of explicit measurement outcomes for every experimental shot. Defaults to True.

  • seed_simulator: Seed to use in random sampling. Defaults to None.

  • experiment_result_function: Function for computing the ExperimentResult for each simulated experiment. This option defaults to default_experiment_result_function(), and any other function set to this option must have the same signature. Note that the default utilizes various other options that control results computation, and hence changing it will impact the meaning of other options.

  • configuration: A PulseBackendConfiguration instance or None. This option defaults to None, and is not required for the functioning of this class, but is provided for compatibility. A set configuration will be returned by DynamicsBackend.configuration().

  • defaults: A PulseDefaults instance or None. This option defaults to None, and is not required for the functioning of this class, but is provided for compatibility. A set defaults will be returned by DynamicsBackend.defaults().

Instantiate with a Solver instance and additional options.

Parameters:
  • solver (Solver) – Solver instance configured for pulse simulation.

  • target (Optional[Target]) – Target object.

  • options – Additional configuration options for the simulator.

Raises:

QiskitError – If any instantiation arguments fail validation checks.

Methods

acquire_channel(qubit)[source]

Return the measure channel for a given qubit.

Return type:

AcquireChannel

configuration()[source]

Get the backend configuration.

Return type:

PulseBackendConfiguration

control_channel(qubits)[source]

Return the control channel with a given label specified by qubits.

This method requires the control_channel_map option is set, and otherwise will raise a NotImplementedError.

Parameters:

qubits (Union[Tuple[int, int], List[Tuple[int, int]]]) – The label for the control channel, or a list of labels.

Return type:

List[ControlChannel]

Returns:

A list containing the control channels specified by qubits.

Raises:
  • NotImplementedError – If the control_channel_map option is not set for this backend.

  • QiskitError – If a requested channel is not in the control_channel_map.

defaults()[source]

Get the backend defaults.

Return type:

PulseDefaults

drive_channel(qubit)[source]

Return the drive channel for a given qubit.

Return type:

DriveChannel

measure_channel(qubit)[source]

Return the measure channel for a given qubit.

Return type:

MeasureChannel

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 (Union[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

Return type:

Union[QubitProperties, List[QubitProperties]]

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

run(run_input, validate=True, **options)[source]

Run a list of simulations.

Parameters:
  • run_input (List[Union[QuantumCircuit, Schedule, ScheduleBlock]]) – A list of simulations, specified by QuantumCircuit, Schedule, or ScheduleBlock instances.

  • validate (Optional[bool]) – Whether or not to run validation checks on the input.

  • **options – Additional run options to temporarily override current backend options.

Return type:

DynamicsJob

Returns:

DynamicsJob object containing results and status.

Raises:

QiskitError – If invalid options are set.

set_options(**fields)[source]

Set options for DynamicsBackend.

solve(solve_input, t_span=None, y0=None, convert_results=True, validate=True)[source]

Simulate a list of QuantumCircuit, Schedule, or ScheduleBlock instances and return the OdeResult.

This method is analogous to Solver.solve(), however it additionally utilizes transpilation and the backend configuration to convert QuantumCircuit instances into pulse-level schedules for simulation. The options for the solver will be drawn from self.options.solver_options, and if y0 is not specified, it will be set from self.options.initial_state.

Parameters:
  • t_span (Union[ndarray, number, int, float, complex, Tracer, Array, spmatrix, BCOO, list, None]) – Time interval to integrate over. Defaults to None, in which case the interval is set to [[0, input.duration] for input in solve_input]].

  • y0 (Union[ndarray, number, int, float, complex, Tracer, Array, spmatrix, BCOO, list, QuantumState, BaseOperator, None]) – Initial state.

  • solve_input (List[Union[QuantumCircuit, Schedule, ScheduleBlock]]) – Time evolution of the system in terms of quantum circuits or qiskit pulse schedules.

  • convert_results (Optional[bool]) – If True, convert returned solver state results to the same class as y0. If False, states will be returned in the native array type used by the specified solver method.

  • validate (Optional[bool]) – Whether or not to run validation checks on the input.

Returns:

object with formatted output types.

Return type:

OdeResult

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.

Deprecated since version 1.3: 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
meas_map
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

Return the backend Provider.

Returns:

the Provider responsible for the backend.

Return type:

Provider

target
version = 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.