qiskit-aer 0.17.2__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. qiskit_aer/VERSION.txt +1 -0
  2. qiskit_aer/__init__.py +89 -0
  3. qiskit_aer/aererror.py +30 -0
  4. qiskit_aer/aerprovider.py +119 -0
  5. qiskit_aer/backends/__init__.py +20 -0
  6. qiskit_aer/backends/aer_compiler.py +1085 -0
  7. qiskit_aer/backends/aer_simulator.py +1025 -0
  8. qiskit_aer/backends/aerbackend.py +679 -0
  9. qiskit_aer/backends/backend_utils.py +567 -0
  10. qiskit_aer/backends/backendconfiguration.py +395 -0
  11. qiskit_aer/backends/backendproperties.py +590 -0
  12. qiskit_aer/backends/compatibility.py +287 -0
  13. qiskit_aer/backends/controller_wrappers.cp314-win_amd64.pyd +0 -0
  14. qiskit_aer/backends/libopenblas.dll +0 -0
  15. qiskit_aer/backends/name_mapping.py +306 -0
  16. qiskit_aer/backends/qasm_simulator.py +925 -0
  17. qiskit_aer/backends/statevector_simulator.py +330 -0
  18. qiskit_aer/backends/unitary_simulator.py +316 -0
  19. qiskit_aer/jobs/__init__.py +35 -0
  20. qiskit_aer/jobs/aerjob.py +143 -0
  21. qiskit_aer/jobs/utils.py +66 -0
  22. qiskit_aer/library/__init__.py +204 -0
  23. qiskit_aer/library/control_flow_instructions/__init__.py +16 -0
  24. qiskit_aer/library/control_flow_instructions/jump.py +47 -0
  25. qiskit_aer/library/control_flow_instructions/mark.py +30 -0
  26. qiskit_aer/library/control_flow_instructions/store.py +29 -0
  27. qiskit_aer/library/default_qubits.py +44 -0
  28. qiskit_aer/library/instructions_table.csv +21 -0
  29. qiskit_aer/library/save_instructions/__init__.py +44 -0
  30. qiskit_aer/library/save_instructions/save_amplitudes.py +168 -0
  31. qiskit_aer/library/save_instructions/save_clifford.py +63 -0
  32. qiskit_aer/library/save_instructions/save_data.py +129 -0
  33. qiskit_aer/library/save_instructions/save_density_matrix.py +91 -0
  34. qiskit_aer/library/save_instructions/save_expectation_value.py +257 -0
  35. qiskit_aer/library/save_instructions/save_matrix_product_state.py +71 -0
  36. qiskit_aer/library/save_instructions/save_probabilities.py +156 -0
  37. qiskit_aer/library/save_instructions/save_stabilizer.py +70 -0
  38. qiskit_aer/library/save_instructions/save_state.py +79 -0
  39. qiskit_aer/library/save_instructions/save_statevector.py +120 -0
  40. qiskit_aer/library/save_instructions/save_superop.py +62 -0
  41. qiskit_aer/library/save_instructions/save_unitary.py +63 -0
  42. qiskit_aer/library/set_instructions/__init__.py +19 -0
  43. qiskit_aer/library/set_instructions/set_density_matrix.py +78 -0
  44. qiskit_aer/library/set_instructions/set_matrix_product_state.py +83 -0
  45. qiskit_aer/library/set_instructions/set_stabilizer.py +77 -0
  46. qiskit_aer/library/set_instructions/set_statevector.py +78 -0
  47. qiskit_aer/library/set_instructions/set_superop.py +78 -0
  48. qiskit_aer/library/set_instructions/set_unitary.py +78 -0
  49. qiskit_aer/noise/__init__.py +265 -0
  50. qiskit_aer/noise/device/__init__.py +25 -0
  51. qiskit_aer/noise/device/models.py +397 -0
  52. qiskit_aer/noise/device/parameters.py +202 -0
  53. qiskit_aer/noise/errors/__init__.py +30 -0
  54. qiskit_aer/noise/errors/base_quantum_error.py +119 -0
  55. qiskit_aer/noise/errors/pauli_error.py +283 -0
  56. qiskit_aer/noise/errors/pauli_lindblad_error.py +363 -0
  57. qiskit_aer/noise/errors/quantum_error.py +451 -0
  58. qiskit_aer/noise/errors/readout_error.py +355 -0
  59. qiskit_aer/noise/errors/standard_errors.py +498 -0
  60. qiskit_aer/noise/noise_model.py +1231 -0
  61. qiskit_aer/noise/noiseerror.py +30 -0
  62. qiskit_aer/noise/passes/__init__.py +18 -0
  63. qiskit_aer/noise/passes/local_noise_pass.py +160 -0
  64. qiskit_aer/noise/passes/relaxation_noise_pass.py +137 -0
  65. qiskit_aer/primitives/__init__.py +44 -0
  66. qiskit_aer/primitives/estimator.py +751 -0
  67. qiskit_aer/primitives/estimator_v2.py +159 -0
  68. qiskit_aer/primitives/sampler.py +361 -0
  69. qiskit_aer/primitives/sampler_v2.py +256 -0
  70. qiskit_aer/quantum_info/__init__.py +32 -0
  71. qiskit_aer/quantum_info/states/__init__.py +16 -0
  72. qiskit_aer/quantum_info/states/aer_densitymatrix.py +313 -0
  73. qiskit_aer/quantum_info/states/aer_state.py +525 -0
  74. qiskit_aer/quantum_info/states/aer_statevector.py +302 -0
  75. qiskit_aer/utils/__init__.py +44 -0
  76. qiskit_aer/utils/noise_model_inserter.py +66 -0
  77. qiskit_aer/utils/noise_transformation.py +431 -0
  78. qiskit_aer/version.py +86 -0
  79. qiskit_aer-0.17.2.dist-info/METADATA +209 -0
  80. qiskit_aer-0.17.2.dist-info/RECORD +83 -0
  81. qiskit_aer-0.17.2.dist-info/WHEEL +5 -0
  82. qiskit_aer-0.17.2.dist-info/licenses/LICENSE.txt +203 -0
  83. qiskit_aer-0.17.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,395 @@
1
+ # This code is part of Qiskit.
2
+ #
3
+ # (C) Copyright IBM 2018, 2019, 2024
4
+ #
5
+ # This code is licensed under the Apache License, Version 2.0. You may
6
+ # obtain a copy of this license in the LICENSE.txt file in the root directory
7
+ # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
+ #
9
+ # Any modifications or derivative works of this code must retain this
10
+ # copyright notice, and modified files need to carry a notice indicating
11
+ # that they have been altered from the originals.
12
+ """
13
+ Aer backend configuration
14
+ """
15
+ import copy
16
+
17
+
18
+ class GateConfig:
19
+ """Class representing a Gate Configuration
20
+
21
+ Attributes:
22
+ name: the gate name as it will be referred to in OpenQASM.
23
+ parameters: variable names for the gate parameters (if any).
24
+ qasm_def: definition of this gate in terms of OpenQASM 2 primitives U
25
+ and CX.
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ name,
31
+ parameters,
32
+ qasm_def,
33
+ coupling_map=None,
34
+ latency_map=None,
35
+ conditional=None,
36
+ description=None,
37
+ ):
38
+ """Initialize a GateConfig object
39
+
40
+ Args:
41
+ name (str): the gate name as it will be referred to in OpenQASM.
42
+ parameters (list): variable names for the gate parameters (if any)
43
+ as a list of strings.
44
+ qasm_def (str): definition of this gate in terms of OpenQASM 2 primitives U and CX.
45
+ coupling_map (list): An optional coupling map for the gate. In
46
+ the form of a list of lists of integers representing the qubit
47
+ groupings which are coupled by this gate.
48
+ latency_map (list): An optional map of latency for the gate. In the
49
+ the form of a list of lists of integers of either 0 or 1
50
+ representing an array of dimension
51
+ len(coupling_map) X n_registers that specifies the register
52
+ latency (1: fast, 0: slow) conditional operations on the gate
53
+ conditional (bool): Optionally specify whether this gate supports
54
+ conditional operations (true/false). If this is not specified,
55
+ then the gate inherits the conditional property of the backend.
56
+ description (str): Description of the gate operation
57
+ """
58
+
59
+ self.name = name
60
+ self.parameters = parameters
61
+ self.qasm_def = qasm_def
62
+ # coupling_map with length 0 is invalid
63
+ if coupling_map:
64
+ self.coupling_map = coupling_map
65
+ # latency_map with length 0 is invalid
66
+ if latency_map:
67
+ self.latency_map = latency_map
68
+ if conditional is not None:
69
+ self.conditional = conditional
70
+ if description is not None:
71
+ self.description = description
72
+
73
+ @classmethod
74
+ def from_dict(cls, data):
75
+ """Create a new GateConfig object from a dictionary.
76
+
77
+ Args:
78
+ data (dict): A dictionary representing the GateConfig to create.
79
+ It will be in the same format as output by
80
+ :func:`to_dict`.
81
+
82
+ Returns:
83
+ GateConfig: The GateConfig from the input dictionary.
84
+ """
85
+ return cls(**data)
86
+
87
+ def to_dict(self):
88
+ """Return a dictionary format representation of the GateConfig.
89
+
90
+ Returns:
91
+ dict: The dictionary form of the GateConfig.
92
+ """
93
+ out_dict = {
94
+ "name": self.name,
95
+ "parameters": self.parameters,
96
+ "qasm_def": self.qasm_def,
97
+ }
98
+ if hasattr(self, "coupling_map"):
99
+ out_dict["coupling_map"] = self.coupling_map
100
+ if hasattr(self, "latency_map"):
101
+ out_dict["latency_map"] = self.latency_map
102
+ if hasattr(self, "conditional"):
103
+ out_dict["conditional"] = self.conditional
104
+ if hasattr(self, "description"):
105
+ out_dict["description"] = self.description
106
+ return out_dict
107
+
108
+ def __eq__(self, other):
109
+ if isinstance(other, GateConfig):
110
+ if self.to_dict() == other.to_dict():
111
+ return True
112
+ return False
113
+
114
+ def __repr__(self):
115
+ out_str = f"GateConfig({self.name}, {self.parameters}, {self.qasm_def}"
116
+ for i in ["coupling_map", "latency_map", "conditional", "description"]:
117
+ if hasattr(self, i):
118
+ out_str += ", " + repr(getattr(self, i))
119
+ out_str += ")"
120
+ return out_str
121
+
122
+
123
+ class AerBackendConfiguration:
124
+ """Class representing an Aer Backend Configuration.
125
+
126
+ Attributes:
127
+ backend_name: backend name.
128
+ backend_version: backend version in the form X.Y.Z.
129
+ n_qubits: number of qubits.
130
+ basis_gates: list of basis gates names on the backend.
131
+ gates: list of basis gates on the backend.
132
+ max_shots: maximum number of shots supported.
133
+ """
134
+
135
+ _data = {}
136
+
137
+ def __init__(
138
+ self,
139
+ backend_name,
140
+ backend_version,
141
+ n_qubits,
142
+ basis_gates,
143
+ gates,
144
+ max_shots,
145
+ coupling_map,
146
+ supported_instructions=None,
147
+ dynamic_reprate_enabled=False,
148
+ rep_delay_range=None,
149
+ default_rep_delay=None,
150
+ max_experiments=None,
151
+ sample_name=None,
152
+ n_registers=None,
153
+ register_map=None,
154
+ configurable=None,
155
+ credits_required=None,
156
+ online_date=None,
157
+ display_name=None,
158
+ description=None,
159
+ tags=None,
160
+ dt=None,
161
+ dtm=None,
162
+ processor_type=None,
163
+ **kwargs,
164
+ ):
165
+ """Initialize a AerBackendConfiguration Object
166
+
167
+ Args:
168
+ backend_name (str): The backend name
169
+ backend_version (str): The backend version in the form X.Y.Z
170
+ n_qubits (int): the number of qubits for the backend
171
+ basis_gates (list): The list of strings for the basis gates of the
172
+ backends
173
+ gates (list): The list of GateConfig objects for the basis gates of
174
+ the backend
175
+ max_shots (int): The maximum number of shots allowed on the backend
176
+ coupling_map (list): The coupling map for the device
177
+ supported_instructions (List[str]): Instructions supported by the backend.
178
+ dynamic_reprate_enabled (bool): whether delay between programs can be set dynamically
179
+ (ie via ``rep_delay``). Defaults to False.
180
+ rep_delay_range (List[float]): 2d list defining supported range of repetition
181
+ delays for backend in μs. First entry is lower end of the range, second entry is
182
+ higher end of the range. Optional, but will be specified when
183
+ ``dynamic_reprate_enabled=True``.
184
+ default_rep_delay (float): Value of ``rep_delay`` if not specified by user and
185
+ ``dynamic_reprate_enabled=True``.
186
+ max_experiments (int): The maximum number of experiments per job
187
+ sample_name (str): Sample name for the backend
188
+ n_registers (int): Number of register slots available for feedback
189
+ (if conditional is True)
190
+ register_map (list): An array of dimension n_qubits X
191
+ n_registers that specifies whether a qubit can store a
192
+ measurement in a certain register slot.
193
+ configurable (bool): True if the backend is configurable, if the
194
+ backend is a simulator
195
+ credits_required (bool): True if backend requires credits to run a
196
+ job.
197
+ online_date (datetime.datetime): The date that the device went online
198
+ display_name (str): Alternate name field for the backend
199
+ description (str): A description for the backend
200
+ tags (list): A list of string tags to describe the backend
201
+ dt (float): Qubit drive channel timestep in nanoseconds.
202
+ dtm (float): Measurement drive channel timestep in nanoseconds.
203
+ processor_type (dict): Processor type for this backend. A dictionary of the
204
+ form ``{"family": <str>, "revision": <str>, segment: <str>}`` such as
205
+ ``{"family": "Canary", "revision": "1.0", segment: "A"}``.
206
+
207
+ - family: Processor family of this backend.
208
+ - revision: Revision version of this processor.
209
+ - segment: Segment this processor belongs to within a larger chip.
210
+
211
+ **kwargs: optional fields
212
+ """
213
+ self._data = {}
214
+
215
+ self.backend_name = backend_name
216
+ self.backend_version = backend_version
217
+ self.n_qubits = n_qubits
218
+ self.basis_gates = basis_gates
219
+ self.gates = gates
220
+ self.local = True
221
+ self.simulator = True
222
+ self.conditional = True
223
+ self.open_pulse = False
224
+ self.memory = True
225
+ self.max_shots = max_shots
226
+ self.coupling_map = coupling_map
227
+ if supported_instructions:
228
+ self.supported_instructions = supported_instructions
229
+
230
+ self.dynamic_reprate_enabled = dynamic_reprate_enabled
231
+ if rep_delay_range:
232
+ self.rep_delay_range = [_rd * 1e-6 for _rd in rep_delay_range] # convert to sec
233
+ if default_rep_delay is not None:
234
+ self.default_rep_delay = default_rep_delay * 1e-6 # convert to sec
235
+
236
+ # max_experiments must be >=1
237
+ if max_experiments:
238
+ self.max_experiments = max_experiments
239
+ if sample_name is not None:
240
+ self.sample_name = sample_name
241
+ # n_registers must be >=1
242
+ if n_registers:
243
+ self.n_registers = 1
244
+ # register_map must have at least 1 entry
245
+ if register_map:
246
+ self.register_map = register_map
247
+ if configurable is not None:
248
+ self.configurable = configurable
249
+ if credits_required is not None:
250
+ self.credits_required = credits_required
251
+ if online_date is not None:
252
+ self.online_date = online_date
253
+ if display_name is not None:
254
+ self.display_name = display_name
255
+ if description is not None:
256
+ self.description = description
257
+ if tags is not None:
258
+ self.tags = tags
259
+ # Add pulse properties here because some backends do not
260
+ # fit within the Qasm / Pulse backend partitioning in Qiskit
261
+ if dt is not None:
262
+ self.dt = dt * 1e-9
263
+ if dtm is not None:
264
+ self.dtm = dtm * 1e-9
265
+ if processor_type is not None:
266
+ self.processor_type = processor_type
267
+
268
+ # convert lo range from GHz to Hz
269
+ if "qubit_lo_range" in kwargs:
270
+ kwargs["qubit_lo_range"] = [
271
+ [min_range * 1e9, max_range * 1e9]
272
+ for (min_range, max_range) in kwargs["qubit_lo_range"]
273
+ ]
274
+
275
+ if "meas_lo_range" in kwargs:
276
+ kwargs["meas_lo_range"] = [
277
+ [min_range * 1e9, max_range * 1e9]
278
+ for (min_range, max_range) in kwargs["meas_lo_range"]
279
+ ]
280
+
281
+ # convert rep_times from μs to sec
282
+ if "rep_times" in kwargs:
283
+ kwargs["rep_times"] = [_rt * 1e-6 for _rt in kwargs["rep_times"]]
284
+
285
+ self._data.update(kwargs)
286
+
287
+ def __getattr__(self, name):
288
+ try:
289
+ return self._data[name]
290
+ except KeyError as ex:
291
+ raise AttributeError(f"Attribute {name} is not defined") from ex
292
+
293
+ @classmethod
294
+ def from_dict(cls, data):
295
+ """Create a new GateConfig object from a dictionary.
296
+
297
+ Args:
298
+ data (dict): A dictionary representing the GateConfig to create.
299
+ It will be in the same format as output by
300
+ :func:`to_dict`.
301
+ Returns:
302
+ GateConfig: The GateConfig from the input dictionary.
303
+ """
304
+ in_data = copy.copy(data)
305
+ gates = [GateConfig.from_dict(x) for x in in_data.pop("gates")]
306
+ in_data["gates"] = gates
307
+ return cls(**in_data)
308
+
309
+ def to_dict(self):
310
+ """Return a dictionary format representation of the GateConfig.
311
+
312
+ Returns:
313
+ dict: The dictionary form of the GateConfig.
314
+ """
315
+ out_dict = {
316
+ "backend_name": self.backend_name,
317
+ "backend_version": self.backend_version,
318
+ "n_qubits": self.n_qubits,
319
+ "basis_gates": self.basis_gates,
320
+ "gates": [x.to_dict() for x in self.gates],
321
+ "local": self.local,
322
+ "simulator": self.simulator,
323
+ "conditional": self.conditional,
324
+ "memory": self.memory,
325
+ "max_shots": self.max_shots,
326
+ "coupling_map": self.coupling_map,
327
+ "dynamic_reprate_enabled": self.dynamic_reprate_enabled,
328
+ }
329
+
330
+ if hasattr(self, "supported_instructions"):
331
+ out_dict["supported_instructions"] = self.supported_instructions
332
+
333
+ if hasattr(self, "rep_delay_range"):
334
+ out_dict["rep_delay_range"] = [_rd * 1e6 for _rd in self.rep_delay_range]
335
+ if hasattr(self, "default_rep_delay"):
336
+ out_dict["default_rep_delay"] = self.default_rep_delay * 1e6
337
+
338
+ for kwarg in [
339
+ "max_experiments",
340
+ "sample_name",
341
+ "n_registers",
342
+ "register_map",
343
+ "configurable",
344
+ "credits_required",
345
+ "online_date",
346
+ "display_name",
347
+ "description",
348
+ "tags",
349
+ "dt",
350
+ "dtm",
351
+ "processor_type",
352
+ ]:
353
+ if hasattr(self, kwarg):
354
+ out_dict[kwarg] = getattr(self, kwarg)
355
+
356
+ out_dict.update(self._data)
357
+
358
+ if "dt" in out_dict:
359
+ out_dict["dt"] *= 1e9
360
+ if "dtm" in out_dict:
361
+ out_dict["dtm"] *= 1e9
362
+
363
+ # Use GHz in dict
364
+ if "qubit_lo_range" in out_dict:
365
+ out_dict["qubit_lo_range"] = [
366
+ [min_range * 1e-9, max_range * 1e-9]
367
+ for (min_range, max_range) in out_dict["qubit_lo_range"]
368
+ ]
369
+
370
+ if "meas_lo_range" in out_dict:
371
+ out_dict["meas_lo_range"] = [
372
+ [min_range * 1e-9, max_range * 1e-9]
373
+ for (min_range, max_range) in out_dict["meas_lo_range"]
374
+ ]
375
+
376
+ return out_dict
377
+
378
+ @property
379
+ def num_qubits(self):
380
+ """Returns the number of qubits.
381
+
382
+ In future, `n_qubits` should be replaced in favor of `num_qubits` for consistent use
383
+ throughout Qiskit. Until this is properly refactored, this property serves as intermediate
384
+ solution.
385
+ """
386
+ return self.n_qubits
387
+
388
+ def __eq__(self, other):
389
+ if isinstance(other, AerBackendConfiguration):
390
+ if self.to_dict() == other.to_dict():
391
+ return True
392
+ return False
393
+
394
+ def __contains__(self, item):
395
+ return item in self.__dict__