UnitarySimulator
class UnitarySimulator(configuration=None, properties=None, provider=None, **backend_options)
Bases: qiskit.providers.aer.backends.aerbackend.AerBackend
Ideal quantum circuit unitary simulator.
Configurable Options
The UnitarySimulator 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 = UnitarySimulator(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"unitary"
for CPU simulation, and"unitary_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_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).max_shot_size
(int or None): If the number of shots with a noise model exceeds this value, simulation will split the experiments into sub experiments in the qobj. IfNone
simulator does nothing (Default: None)."initial_unitary"
(matrix_like): Sets a custom initial unitary matrix for the simulation instead of identity (Default: None)."validation_threshold"
(double): Sets the threshold for checking if initial unitary and target unitary are unitary matrices. (Default: 1e-8)."zero_threshold"
(double): Sets the threshold for truncating small values to zero in the result data (Default: 1e-10)."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 qobj 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 2 * “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: 7]
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 (BackendConfiguration) – backend configuration.
- properties (BackendProperties or None) – Optional, backend properties.
- defaults (PulseDefaults or None) – Optional, backend pulse defaults.
- provider (Provider) – Optional, provider responsible for this backend.
- backend_options (dict or None) – Optional set custom backend options.
Raises
AerError – if there is no name in the configuration
Methods
available_devices
UnitarySimulator.available_devices()
Return the available simulation methods.
available_methods
UnitarySimulator.available_methods()
Return the available simulation methods.
clear_options
UnitarySimulator.clear_options()
Reset the simulator options to default values.
configuration
UnitarySimulator.configuration()
Return the simulator backend configuration.
Returns
the configuration for the backend.
Return type
defaults
UnitarySimulator.defaults()
Return the simulator backend pulse defaults.
Returns
The backend pulse defaults or None
if the
backend does not support pulse.
Return type
name
UnitarySimulator.name()
Return the backend name.
Returns
the name of the backend.
Return type
str
properties
UnitarySimulator.properties()
Return the simulator backend properties if set.
Returns
The backend properties or None
if the
backend does not have properties set.
Return type
provider
UnitarySimulator.provider()
Return the backend Provider.
Returns
the Provider responsible for the backend.
Return type
run
UnitarySimulator.run(circuits, validate=False, parameter_binds=None, **run_options)
Run a qobj on the backend.
Parameters
- circuits (QuantumCircuit or list) – The QuantumCircuit (or list of QuantumCircuit objects) to run
- validate (bool) – validate the Qobj before running (default: False).
- 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
AerError – If parameter_binds
is specified with a qobj 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
set_option
UnitarySimulator.set_option(key, value)
Special handling for setting backend options.
This method should be extended by sub classes to update special option values.
Parameters
- key (str) – key to update
- value (any) – value to update.
Raises
AerError – if key is ‘method’ and val isn’t in available methods.
set_options
UnitarySimulator.set_options(**fields)
Set the simulator options
status
UnitarySimulator.status()
Return backend status.
Returns
the status of the backend.
Return type
Attributes
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.
version
Default value: 1