-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathqiskit.providers.basicaer.StatevectorSimulatorPy.md
271 lines (149 loc) · 8.27 KB
/
qiskit.providers.basicaer.StatevectorSimulatorPy.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
---
title: StatevectorSimulatorPy
description: API reference for qiskit.providers.basicaer.StatevectorSimulatorPy
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.basicaer.StatevectorSimulatorPy
---
# StatevectorSimulatorPy
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy" />
`qiskit.providers.basicaer.StatevectorSimulatorPy(configuration=None, provider=None, **fields)`
Bases: [`QasmSimulatorPy`](qiskit.providers.basicaer.QasmSimulatorPy "qiskit.providers.basicaer.qasm_simulator.QasmSimulatorPy")
Python statevector simulator.
Initialize a backend class
**Parameters**
* **configuration** ([*BackendConfiguration*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")) – A backend configuration object for the backend object.
* **provider** ([*qiskit.providers.Provider*](qiskit.providers.Provider "qiskit.providers.Provider")) – Optionally, the provider object that this Backend comes from.
* **fields** – kwargs for the values to use to override the default options.
**Raises**
[**AttributeError**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.12)") – if input field not a valid options
In addition to the public abstract methods, subclasses should also implement the following private methods:
<span id="undefined" />
`classmethod _default_options()`
Return the default options
This method will return a [`qiskit.providers.Options`](qiskit.providers.Options "qiskit.providers.Options") subclass object that will be used for the default options. These should be the default parameters to use for the options of the backend.
**Returns**
**A options object with**
default values set
**Return type**
[qiskit.providers.Options](qiskit.providers.Options "qiskit.providers.Options")
## Attributes
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.DEFAULT_CONFIGURATION" />
### DEFAULT\_CONFIGURATION = \{'backend\_name'
`= {'backend_name':`
`= {'backend_name': 'statevector_simulator', 'backend_version': '1.1.0', 'basis_gates': ['u1', 'u2', 'u3', 'rz', 'sx', 'x', 'cx', 'id', 'unitary'], 'conditional': True, 'coupling_map': None, 'description': 'A Python statevector simulator for qobj files', 'gates': [{'name': 'u1', 'parameters': ['lambda'], 'qasm_def': 'gate u1(lambda) q { U(0,0,lambda) q; }'}, {'name': 'u2', 'parameters': ['phi', 'lambda'], 'qasm_def': 'gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }'}, {'name': 'u3', 'parameters': ['theta', 'phi', 'lambda'], 'qasm_def': 'gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }'}, {'name': 'rz', 'parameters': ['phi'], 'qasm_def': 'gate rz(phi) q { U(0,0,phi) q; }'}, {'name': 'sx', 'parameters': [], 'qasm_def': 'gate sx(phi) q { U(pi/2,7*pi/2,pi/2) q; }'}, {'name': 'x', 'parameters': [], 'qasm_def': 'gate x q { U(pi,7*pi/2,pi/2) q; }'}, {'name': 'cx', 'parameters': [], 'qasm_def': 'gate cx c,t { CX c,t; }'}, {'name': 'id', 'parameters': [], 'qasm_def': 'gate id a { U(0,0,0) a; }'}, {'name': 'unitary', 'parameters': ['matrix'], 'qasm_def': 'unitary(matrix) q1, q2,...'}], 'local': True, 'max_shots': 0, 'memory': True, 'n_qubits': 24, 'open_pulse': False, 'simulator': True, 'url': 'https://github.com/Qiskit/qiskit-terra'}`
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.DEFAULT_OPTIONS" />
### DEFAULT\_OPTIONS = \{'chop\_threshold'
`= {'chop_threshold':`
`= {'chop_threshold': 1e-15, 'initial_statevector': None}`
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.MAX_QUBITS_MEMORY" />
### MAX\_QUBITS\_MEMORY
`= 28`
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.SHOW_FINAL_STATE" />
### SHOW\_FINAL\_STATE
`= True`
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.options" />
### 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.basicaer.StatevectorSimulatorPy.run "qiskit.providers.basicaer.StatevectorSimulatorPy.run") method.
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.version" />
### version
`= 1`
## Methods
### configuration
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.configuration" />
`configuration()`
Return the backend configuration.
**Returns**
the configuration for the backend.
**Return type**
[BackendConfiguration](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")
### name
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.name" />
`name()`
Return the backend name.
**Returns**
the name of the backend.
**Return type**
[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")
### properties
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.properties" />
`properties()`
Return the backend properties.
**Returns**
the configuration for the backend. If the backend does not support properties, it returns `None`.
**Return type**
[BackendProperties](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")
### provider
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.provider" />
`provider()`
Return the backend Provider.
**Returns**
the Provider responsible for the backend.
**Return type**
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
### run
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.run" />
`run(run_input, **backend_options)`
Run on the backend.
**Parameters**
* **run\_input** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *or*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) – payload of the experiment
* **backend\_options** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.12)")) – backend options
**Returns**
derived from BaseJob
**Return type**
[BasicAerJob](qiskit.providers.basicaer.BasicAerJob "qiskit.providers.basicaer.BasicAerJob")
**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:
```python
backend_options = {
"initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2),
}
```
### run\_experiment
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.run_experiment" />
`run_experiment(experiment)`
Run an experiment (circuit) and return a single experiment result.
**Parameters**
**experiment** ([*QasmQobjExperiment*](qiskit.qobj.QasmQobjExperiment "qiskit.qobj.QasmQobjExperiment")) – experiment from qobj experiments list
**Returns**
A result dictionary which looks something like:
```python
{
"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
}
```
**Return type**
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.12)")
**Raises**
[**BasicAerError**](qiskit.providers.basicaer.BasicAerError "qiskit.providers.basicaer.BasicAerError") – if an error occurred.
### set\_options
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.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**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.12)") – If the field passed in is not part of the options
### status
<span id="qiskit.providers.basicaer.StatevectorSimulatorPy.status" />
`status()`
Return the backend status.
**Returns**
the status of the backend.
**Return type**
[BackendStatus](qiskit.providers.models.BackendStatus "qiskit.providers.models.BackendStatus")