279 lines
15 KiB
Plaintext
279 lines
15 KiB
Plaintext
---
|
||
title: UnitarySimulator (v0.26)
|
||
description: API reference for qiskit.providers.aer.UnitarySimulator in qiskit v0.26
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.providers.aer.UnitarySimulator
|
||
---
|
||
|
||
<span id="qiskit-providers-aer-unitarysimulator" />
|
||
|
||
# qiskit.providers.aer.UnitarySimulator
|
||
|
||
<Class id="qiskit.providers.aer.UnitarySimulator" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-aer/tree/stable/0.8/qiskit/providers/aer/backends/unitary_simulator.py" signature="UnitarySimulator(configuration=None, properties=None, provider=None, **backend_options)" modifiers="class">
|
||
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()`](#qiskit.providers.aer.UnitarySimulator.set_options "qiskit.providers.aer.UnitarySimulator.set_options") method.
|
||
|
||
Run-time options may also be specified as kwargs using the [`run()`](#qiskit.providers.aer.UnitarySimulator.run "qiskit.providers.aer.UnitarySimulator.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
|
||
|
||
```python
|
||
backend = UnitarySimulator(precision='single')
|
||
```
|
||
|
||
**Backend Options**
|
||
|
||
The following configurable backend options are supported
|
||
|
||
* `method` (str): Set the simulation method supported methods are `"unitary"` for CPU simulation, and `"unitary_gpu"` for GPU simulation (Default: `"unitary"`).
|
||
* `precision` (str): Set the floating point precision for certain simulation methods to either `"single"` or `"double"` precision (default: `"double"`).
|
||
* `"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*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")) – backend configuration.
|
||
* **properties** ([*BackendProperties*](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties") *or None*) – Optional, backend properties.
|
||
* **defaults** ([*PulseDefaults*](qiskit.providers.models.PulseDefaults "qiskit.providers.models.PulseDefaults") *or None*) – Optional, backend pulse defaults.
|
||
* **available\_methods** (*list or None*) – Optional, the available simulation methods if backend supports multiple methods.
|
||
* **provider** ([*Provider*](qiskit.providers.Provider "qiskit.providers.Provider")) – Optional, provider responsible for this backend.
|
||
* **backend\_options** (*dict or None*) – Optional set custom backend options.
|
||
|
||
**Raises**
|
||
|
||
[**AerError**](qiskit.providers.aer.AerError "qiskit.providers.aer.AerError") – if there is no name in the configuration
|
||
|
||
### \_\_init\_\_
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.__init__" signature="__init__(configuration=None, properties=None, provider=None, **backend_options)">
|
||
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*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")) – backend configuration.
|
||
* **properties** ([*BackendProperties*](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties") *or None*) – Optional, backend properties.
|
||
* **defaults** ([*PulseDefaults*](qiskit.providers.models.PulseDefaults "qiskit.providers.models.PulseDefaults") *or None*) – Optional, backend pulse defaults.
|
||
* **available\_methods** (*list or None*) – Optional, the available simulation methods if backend supports multiple methods.
|
||
* **provider** ([*Provider*](qiskit.providers.Provider "qiskit.providers.Provider")) – Optional, provider responsible for this backend.
|
||
* **backend\_options** (*dict or None*) – Optional set custom backend options.
|
||
|
||
**Raises**
|
||
|
||
[**AerError**](qiskit.providers.aer.AerError "qiskit.providers.aer.AerError") – if there is no name in the configuration
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
|
||
| [`__init__`](#qiskit.providers.aer.UnitarySimulator.__init__ "qiskit.providers.aer.UnitarySimulator.__init__")(\[configuration, properties, provider]) | Aer class for backends. |
|
||
| [`available_methods`](#qiskit.providers.aer.UnitarySimulator.available_methods "qiskit.providers.aer.UnitarySimulator.available_methods")() | Return the available simulation methods. |
|
||
| [`clear_options`](#qiskit.providers.aer.UnitarySimulator.clear_options "qiskit.providers.aer.UnitarySimulator.clear_options")() | Reset the simulator options to default values. |
|
||
| [`configuration`](#qiskit.providers.aer.UnitarySimulator.configuration "qiskit.providers.aer.UnitarySimulator.configuration")() | Return the simulator backend configuration. |
|
||
| [`defaults`](#qiskit.providers.aer.UnitarySimulator.defaults "qiskit.providers.aer.UnitarySimulator.defaults")() | Return the simulator backend pulse defaults. |
|
||
| [`name`](#qiskit.providers.aer.UnitarySimulator.name "qiskit.providers.aer.UnitarySimulator.name")() | Return the backend name. |
|
||
| [`properties`](#qiskit.providers.aer.UnitarySimulator.properties "qiskit.providers.aer.UnitarySimulator.properties")() | Return the simulator backend properties if set. |
|
||
| [`provider`](#qiskit.providers.aer.UnitarySimulator.provider "qiskit.providers.aer.UnitarySimulator.provider")() | Return the backend Provider. |
|
||
| [`run`](#qiskit.providers.aer.UnitarySimulator.run "qiskit.providers.aer.UnitarySimulator.run")(circuits\[, backend\_options, validate]) | Run a qobj on the backend. |
|
||
| [`set_option`](#qiskit.providers.aer.UnitarySimulator.set_option "qiskit.providers.aer.UnitarySimulator.set_option")(key, value) | Special handling for setting backend options. |
|
||
| [`set_options`](#qiskit.providers.aer.UnitarySimulator.set_options "qiskit.providers.aer.UnitarySimulator.set_options")(\*\*fields) | Set the options fields for the backend |
|
||
| [`status`](#qiskit.providers.aer.UnitarySimulator.status "qiskit.providers.aer.UnitarySimulator.status")() | Return backend status. |
|
||
|
||
## Attributes
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------- |
|
||
| [`options`](#qiskit.providers.aer.UnitarySimulator.options "qiskit.providers.aer.UnitarySimulator.options") | Return the options for the backend |
|
||
| `version` | |
|
||
|
||
### available\_methods
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.available_methods" signature="available_methods()">
|
||
Return the available simulation methods.
|
||
</Function>
|
||
|
||
### clear\_options
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.clear_options" signature="clear_options()">
|
||
Reset the simulator options to default values.
|
||
</Function>
|
||
|
||
### configuration
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.configuration" signature="configuration()">
|
||
Return the simulator backend configuration.
|
||
|
||
**Returns**
|
||
|
||
the configuration for the backend.
|
||
|
||
**Return type**
|
||
|
||
[BackendConfiguration](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")
|
||
</Function>
|
||
|
||
### defaults
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.defaults" signature="defaults()">
|
||
Return the simulator backend pulse defaults.
|
||
|
||
**Returns**
|
||
|
||
**The backend pulse defaults or `None` if the**
|
||
|
||
backend does not support pulse.
|
||
|
||
**Return type**
|
||
|
||
[PulseDefaults](qiskit.providers.models.PulseDefaults "qiskit.providers.models.PulseDefaults")
|
||
</Function>
|
||
|
||
### name
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.name" signature="name()">
|
||
Return the backend name.
|
||
|
||
**Returns**
|
||
|
||
the name of the backend.
|
||
|
||
**Return type**
|
||
|
||
str
|
||
</Function>
|
||
|
||
### options
|
||
|
||
<Attribute id="qiskit.providers.aer.UnitarySimulator.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()`](#qiskit.providers.aer.UnitarySimulator.run "qiskit.providers.aer.UnitarySimulator.run") method.
|
||
</Attribute>
|
||
|
||
### properties
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.properties" signature="properties()">
|
||
Return the simulator backend properties if set.
|
||
|
||
**Returns**
|
||
|
||
**The backend properties or `None` if the**
|
||
|
||
backend does not have properties set.
|
||
|
||
**Return type**
|
||
|
||
[BackendProperties](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")
|
||
</Function>
|
||
|
||
### provider
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.provider" signature="provider()">
|
||
Return the backend Provider.
|
||
|
||
**Returns**
|
||
|
||
the Provider responsible for the backend.
|
||
|
||
**Return type**
|
||
|
||
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
|
||
</Function>
|
||
|
||
### run
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.run" signature="run(circuits, backend_options=None, validate=False, **run_options)">
|
||
Run a qobj on the backend.
|
||
|
||
**Parameters**
|
||
|
||
* **circuits** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *or list*) – The QuantumCircuit (or list of QuantumCircuit objects) to run
|
||
* **backend\_options** (*dict or None*) – DEPRECATED dictionary of backend options for the execution (default: None).
|
||
* **validate** (*bool*) – validate the Qobj before running (default: False).
|
||
* **run\_options** (*kwargs*) – additional run time backend options.
|
||
|
||
**Returns**
|
||
|
||
The simulation job.
|
||
|
||
**Return type**
|
||
|
||
[AerJob](qiskit.providers.aer.AerJob "qiskit.providers.aer.AerJob")
|
||
|
||
**Additional Information:**
|
||
|
||
* kwarg options specified in `run_options` will temporarily override any set options of the same name for the current run.
|
||
* The entries in the `backend_options` will be combined with the `Qobj.config` dictionary with the values of entries in `backend_options` taking precedence. This kwarg is deprecated and direct kwarg’s should be used for options to pass them to `run_options`.
|
||
</Function>
|
||
|
||
### set\_option
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.set_option" signature="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**](qiskit.providers.aer.AerError "qiskit.providers.aer.AerError") – if key is ‘method’ and val isn’t in available methods.
|
||
</Function>
|
||
|
||
### set\_options
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.set_options" signature="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
|
||
</Function>
|
||
|
||
### status
|
||
|
||
<Function id="qiskit.providers.aer.UnitarySimulator.status" signature="status()">
|
||
Return backend status.
|
||
|
||
**Returns**
|
||
|
||
the status of the backend.
|
||
|
||
**Return type**
|
||
|
||
[BackendStatus](qiskit.providers.models.BackendStatus "qiskit.providers.models.BackendStatus")
|
||
</Function>
|
||
</Class>
|
||
|