DynamicsBackend¶
- class DynamicsBackend(solver, target=None, **options)[source]¶
Bases:
BackendV2Pulse-level simulator backend.
This class provides a
BackendV2interface wrapper around aSolverinstance setup to simulate pulse schedules. The backend can be configured to take advantage of standard transpilation infrastructure to describe pulse-level simulations in terms ofQuantumCircuits. Results are returned asResultinstances.A minimal
DynamicsBackendrequires specifying only aSolverinstance and a list of subsystem dimensions, indicating the subsystem decomposition of the model inSolver. For example, the following code builds aDynamicsBackendaround aSolverand indicates that the system specified by theSolverdecomposes as two3dimensional subsystems.backend = DynamicsBackend( solver=solver, subsystem_dims=[3, 3] )
Without further configuration, the above
backendcan be used to simulate eitherScheduleorScheduleBlockinstances.Pulse-level simulations defined in terms of
QuantumCircuitinstances 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 inbackend.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 toDynamicsBackend.run().shots: Number of shots per experiment. Defaults to1024.solver: The Qiskit DynamicsSolverinstance used for simulation.solver_options: Dictionary containing optional kwargs for passing toSolver.solve(), indicating solver methods and options. Defaults to the empty dictionary{}.subsystem_dims: Dimensions of subsystems making up the system insolver. 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 theDynamicsBackend.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 arbitraryStatevectororDensityMatrix. Defaults to"ground_state".normalize_states: Boolean indicating whether to normalize states before computing outcome probabilities, and normalize probablities before sampling. Defaults toTrue. Setting toFalsecan 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 are1and2.1returns IQ points and2returns counts. Defaults tomeas_level == 2.meas_return: Level of measurement data to return. Formeas_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 usingmeas_level==1results. Must have typeList[List[List[float, float]]]formatted asiq_centers[subsystem][level] = [I, Q]. IfNone, theiq_centersare dynamically generated to be equally spaced points on a unit circle with ground-state at(1, 0). The default isNone.iq_width: Standard deviation of IQ distribution around the centers formeas_level==1. Must be a positive float. Defaults to0.2.max_outcome_level: Formeas_level == 2, the maximum outcome for each subsystem. Values will be rounded down to be no larger thanmax_outcome_level. Must be a positive integer orNone. IfNone, defaults to1.memory: Boolean indicating whether to return a list of explicit measurement outcomes for every experimental shot. Defaults toTrue.seed_simulator: Seed to use in random sampling. Defaults toNone.experiment_result_function: Function for computing theExperimentResultfor each simulated experiment. This option defaults todefault_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: APulseBackendConfigurationinstance orNone. This option defaults toNone, and is not required for the functioning of this class, but is provided for compatibility. A set configuration will be returned byDynamicsBackend.configuration().defaults: APulseDefaultsinstance orNone. This option defaults toNone, and is not required for the functioning of this class, but is provided for compatibility. A set defaults will be returned byDynamicsBackend.defaults().
Instantiate with a
Solverinstance and additional options.- Parameters:
- 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
- control_channel(qubits)[source]¶
Return the control channel with a given label specified by qubits.
This method requires the
control_channel_mapoption is set, and otherwise will raise aNotImplementedError.- 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.
- 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 theQubitPropertiesobject for. This can be a single integer for 1 qubit or a list of qubits and a list ofQubitPropertiesobjects will be returned in the same order- Return type:
Union[QubitProperties,List[QubitProperties]]- Returns:
The
QubitPropertiesobject 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 beNone.- 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 byQuantumCircuit,Schedule, orScheduleBlockinstances.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.
- solve(solve_input, t_span=None, y0=None, convert_results=True, validate=True)[source]¶
Simulate a list of
QuantumCircuit,Schedule, orScheduleBlockinstances and return theOdeResult.This method is analogous to
Solver.solve(), however it additionally utilizes transpilation and the backend configuration to convertQuantumCircuitinstances into pulse-level schedules for simulation. The options for the solver will be drawn fromself.options.solver_options, and ify0is not specified, it will be set fromself.options.initial_state.- Parameters:
t_span (
Union[ndarray,number,int,float,complex,Tracer,Array,spmatrix,BCOO,list,None]) – Time interval to integrate over. Defaults toNone, 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]) – IfTrue, convert returned solver state results to the same class as y0. IfFalse, 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
CouplingMapobject
- 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,Nonewill 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
InstructionDurationsobject.
- instruction_schedule_map¶
Return the
InstructionScheduleMapfor the instructions defined in this backend’s target.Deprecated since version 1.3: The property
qiskit.providers.backend.BackendV2.instruction_schedule_mapis 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_mapwill 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
Instructioninstances 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 theBackendabstract interface.