BasicSimulator
class qiskit.providers.basic_provider.BasicSimulator(provider=None, target=None, **fields)
Bases: BackendV2
Python implementation of a basic (non-efficient) quantum simulator.
Parameters
- provider (Provider | None) – An optional backwards reference to the
Provider
object that the backend is from. - target (Target | None) – An optional target to configure the simulator.
- 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
MAX_QUBITS_MEMORY
Default value: 24
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.
instructions
A list of Instruction tuples on the backend of the form (instruction, (qubits)
max_circuits
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.
Returns
The Qubit measurement acquisition line.
Return type
Raises
NotImplementedError – if the backend doesn’t support querying the measurement mapping
configuration
configuration()
Return the simulator backend configuration.
Returns
The configuration for the backend.
Return type
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.
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.
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.
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
run(run_input, **backend_options)
Run on the backend.
Parameters
- run_input (QuantumCircuit |list[QuantumCircuit]) – payload of the experiment
- backend_options – backend options
Returns
derived from BaseJob
Return type
Additional Information:
backend_options: Is a dict of options for the backend. It may contain
- “initial_statevector”: vector_like
The “initial_statevector” option specifies a custom initial initial statevector for the simulator to be used instead of the all zero state. This size of this vector must be correct for the number of qubits in run_input
parameter.
Example:
backend_options = {
"initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2),
}
run_experiment
run_experiment(experiment)
Run an experiment (circuit) and return a single experiment result.
Parameters
experiment (QasmQobjExperiment) – experiment from qobj experiments list
Returns
A result dictionary which looks something like:
{
"name": name of this experiment (obtained from qobj.experiment header)
"seed": random seed used for simulation
"shots": number of shots used in the simulation
"data":
{
"counts": {'0x9: 5, ...},
"memory": ['0x9', '0xF', '0x1D', ..., '0x9']
},
"status": status string for the simulation
"success": boolean
"time_taken": simulation time of this single experiment
}
Raises
BasicProviderError – if an error occurred.
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