StatevectorSimulator#
- class StatevectorSimulator(configuration=None, properties=None, provider=None, **backend_options)[source]#
Bases:
AerBackend
Ideal quantum circuit statevector simulator
Configurable Options
The StatevectorSimulator supports CPU and GPU simulation methods and additional configurable options. These may be set using the appropriate kwargs during initialization. They can also be set of updated using the
set_options()
method.Run-time options may also be specified as kwargs using the
run()
method. These will not be stored in the backend and will only apply to that execution. They will also override any previously set options.For example, to configure a a single-precision simulator
backend = StatevectorSimulator(precision='single')
Backend Options
The following configurable backend options are supported
device
(str): Set the simulation device (Default:"CPU"
). Useavailable_devices()
to return a list of devices supported on the current system.method
(str): [DEPRECATED] Set the simulation method supported methods are"statevector"
for CPU simulation, and"statevector_gpu"
for GPU simulation. This option has been deprecated, use thedevice
option to set “CPU” or “GPU” simulation instead.precision
(str): Set the floating point precision for certain simulation methods to either"single"
or"double"
precision (default:"double"
).executor
(futures.Executor): Set a custom executor for asynchronous running of simulation jobs (Default: None).max_job_size
(int or None): If the number of run circuits exceeds this value simulation will be run as a set of of sub-jobs on the executor. IfNone
simulation of all circuits aer submitted to the executor as a single job (Default: None).max_shot_size
(int or None): If the number of shots of a noisy circuit exceeds this value simulation will be split into multi circuits for execution and the results accumulated. IfNone
circuits will not be split based on shots. When splitting circuits use themax_job_size
option to control how these split circuits should be submitted to the executor (Default: None).zero_threshold
(double): Sets the threshold for truncating small values to zero in the result data (Default: 1e-10).validation_threshold
(double): Sets the threshold for checking if the initial statevector is valid (Default: 1e-8).max_parallel_threads
(int): Sets the maximum number of CPU cores used by OpenMP for parallelization. If set to 0 the maximum will be set to the number of CPU cores (Default: 0).max_parallel_experiments
(int): Sets the maximum number of experiments that may be executed in parallel up to the max_parallel_threads value. If set to 1 parallel circuit execution will be disabled. If set to 0 the maximum will be automatically set to max_parallel_threads (Default: 1).max_memory_mb
(int): Sets the maximum size of memory to store a state vector. If a state vector needs more, an error is thrown. In general, a state vector of n-qubits uses 2^n complex values (16 Bytes). If set to 0, the maximum will be automatically set to the system memory size (Default: 0).statevector_parallel_threshold
(int): Sets the threshold that “n_qubits” must be greater than to enable OpenMP parallelization for matrix multiplication during execution of an experiment. If parallel circuit or shot execution is enabled this will only use unallocated CPU cores up to max_parallel_threads. Note that setting this too low can reduce performance (Default: 14).
These backend options apply in circuit optimization passes:
fusion_enable
(bool): Enable fusion optimization in circuit optimization passes [Default: True]fusion_verbose
(bool): Output gates generated in fusion optimization into metadata [Default: False]fusion_max_qubit
(int): Maximum number of qubits for a operation generated in a fusion optimization [Default: 5]fusion_threshold
(int): Threshold that number of qubits must be greater than or equal to enable fusion optimization [Default: 14]
Aer class for backends.
This method should initialize the module and its configuration, and raise an exception if a component of the module is not available.
- Parameters:
configuration (AerBackendConfiguration) – backend configuration.
properties (AerBackendProperties or None) – Optional, backend properties.
provider (Provider) – Optional, provider responsible for this backend.
target (Target) – initial target for backend
backend_options (dict or None) – Optional set custom backend options.
- Raises:
AerError – if there is no name in the configuration
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.
- 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#
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 theBackend
abstract interface.
Methods
- acquire_channel(qubit: int)[source]#
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:
AcquireChannel
- Raises:
NotImplementedError – if the backend doesn’t support querying the measurement mapping
- configuration()[source]#
Return the simulator backend configuration.
- Returns:
the configuration for the backend.
- Return type:
BackendConfiguration
- control_channel(qubits: Iterable[int])[source]#
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 – 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(qubit: int)[source]#
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:
DriveChannel
- Raises:
NotImplementedError – if the backend doesn’t support querying the measurement mapping
- measure_channel(qubit: int)[source]#
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:
MeasureChannel
- Raises:
NotImplementedError – if the backend doesn’t support querying the measurement mapping
- properties()[source]#
Return the simulator backend properties if set.
- Returns:
- The backend properties or
None
if the backend does not have properties set.
- The backend properties or
- Return type:
BackendProperties
- qubit_properties(qubit: int | List[int]) QubitProperties | List[QubitProperties] [source]#
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 – 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 ofQubitProperties
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 beNone
.- Raises:
NotImplementedError – if the backend doesn’t support querying the qubit properties
- run(circuits, parameter_binds=None, **run_options)[source]#
Run circuits on the backend.
- Parameters:
circuits (QuantumCircuit or list) – The QuantumCircuit (or list of QuantumCircuit objects) to run
parameter_binds (list) – A list of parameter binding dictionaries. See additional information (default: None).
run_options (kwargs) – additional run time backend options.
- Returns:
The simulation job.
- Return type:
- Raises:
TypeError – If
parameter_binds
is specified with an input or has a length mismatch with the number of circuits.
- Additional Information:
Each parameter binding dictionary is of the form:
{ param_a: [val_1, val_2], param_b: [val_3, val_1], }
for all parameters in that circuit. The length of the value list must be the same for all parameters, and the number of parameter dictionaries in the list must match the length of
circuits
(ifcircuits
is a singleQuantumCircuit
object it should a list of length 1).kwarg options specified in
run_options
will temporarily override any set options of the same name for the current run.
- Raises:
ValueError – if run is not implemented