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,590 @@
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 properties
14
+ """
15
+ import copy
16
+ import datetime
17
+ import warnings
18
+ from typing import Any, Iterable, Tuple, Union, Dict
19
+ import dateutil.parser
20
+ from qiskit.utils.units import apply_prefix
21
+ from qiskit.transpiler.target import Target
22
+
23
+
24
+ PropertyT = Tuple[Any, datetime.datetime]
25
+
26
+
27
+ class Nduv:
28
+ """Class representing name-date-unit-value
29
+
30
+ Attributes:
31
+ date: date.
32
+ name: name.
33
+ unit: unit.
34
+ value: value.
35
+ """
36
+
37
+ def __init__(self, date, name, unit, value):
38
+ """Initialize a new name-date-unit-value object
39
+
40
+ Args:
41
+ date (datetime.datetime): Date field
42
+ name (str): Name field
43
+ unit (str): Nduv unit
44
+ value (float): The value of the Nduv
45
+ """
46
+ self.date = date
47
+ self.name = name
48
+ self.unit = unit
49
+ self.value = value
50
+
51
+ @classmethod
52
+ def from_dict(cls, data):
53
+ """Create a new Nduv object from a dictionary.
54
+
55
+ Args:
56
+ data (dict): A dictionary representing the Nduv to create.
57
+ It will be in the same format as output by
58
+ :func:`to_dict`.
59
+
60
+ Returns:
61
+ Nduv: The Nduv from the input dictionary.
62
+ """
63
+ return cls(**data)
64
+
65
+ def to_dict(self):
66
+ """Return a dictionary format representation of the object.
67
+
68
+ Returns:
69
+ dict: The dictionary form of the Nduv.
70
+ """
71
+ out_dict = {
72
+ "date": self.date,
73
+ "name": self.name,
74
+ "unit": self.unit,
75
+ "value": self.value,
76
+ }
77
+ return out_dict
78
+
79
+ def __eq__(self, other):
80
+ if isinstance(other, Nduv):
81
+ if self.to_dict() == other.to_dict():
82
+ return True
83
+ return False
84
+
85
+ def __repr__(self):
86
+ return f"Nduv({repr(self.date)}, {self.name}, {self.unit}, {self.value})"
87
+
88
+
89
+ class GateProperties:
90
+ """Class representing a gate's properties
91
+
92
+ Attributes:
93
+ qubits: qubits.
94
+ gate: gate.
95
+ parameters: parameters.
96
+ """
97
+
98
+ _data = {}
99
+
100
+ def __init__(self, qubits, gate, parameters, **kwargs):
101
+ """Initialize a new :class:`GateProperties` object
102
+
103
+ Args:
104
+ qubits (list): A list of integers representing qubits
105
+ gate (str): The gates name
106
+ parameters (list): List of :class:`Nduv` objects for the
107
+ name-date-unit-value for the gate
108
+ kwargs: Optional additional fields
109
+ """
110
+ self._data = {}
111
+ self.qubits = qubits
112
+ self.gate = gate
113
+ self.parameters = parameters
114
+ self._data.update(kwargs)
115
+
116
+ def __getattr__(self, name):
117
+ try:
118
+ return self._data[name]
119
+ except KeyError as ex:
120
+ raise AttributeError(f"Attribute {name} is not defined") from ex
121
+
122
+ @classmethod
123
+ def from_dict(cls, data):
124
+ """Create a new Gate object from a dictionary.
125
+
126
+ Args:
127
+ data (dict): A dictionary representing the Gate to create.
128
+ It will be in the same format as output by
129
+ :func:`to_dict`.
130
+
131
+ Returns:
132
+ GateProperties: The Nduv from the input dictionary.
133
+ """
134
+ in_data = {}
135
+ for key, value in data.items():
136
+ if key == "parameters":
137
+ in_data[key] = list(map(Nduv.from_dict, value))
138
+ else:
139
+ in_data[key] = value
140
+ return cls(**in_data)
141
+
142
+ def to_dict(self):
143
+ """Return a dictionary format representation of the BackendStatus.
144
+
145
+ Returns:
146
+ dict: The dictionary form of the Gate.
147
+ """
148
+ out_dict = {}
149
+ out_dict["qubits"] = self.qubits
150
+ out_dict["gate"] = self.gate
151
+ out_dict["parameters"] = [x.to_dict() for x in self.parameters]
152
+ out_dict.update(self._data)
153
+ return out_dict
154
+
155
+ def __eq__(self, other):
156
+ if isinstance(other, GateProperties):
157
+ if self.to_dict() == other.to_dict():
158
+ return True
159
+ return False
160
+
161
+
162
+ class AerBackendProperties:
163
+ """Class representing Aer backend properties
164
+
165
+ This holds backend properties measured by the provider. All properties
166
+ which are provided optionally. These properties may describe qubits, gates,
167
+ or other general properties of the backend.
168
+ """
169
+
170
+ _data = {}
171
+
172
+ def __init__(
173
+ self, backend_name, backend_version, last_update_date, qubits, gates, general, **kwargs
174
+ ):
175
+ """Initialize a BackendProperties instance.
176
+
177
+ Args:
178
+ backend_name (str): Backend name.
179
+ backend_version (str): Backend version in the form X.Y.Z.
180
+ last_update_date (datetime.datetime or str): Last date/time that a property was
181
+ updated. If specified as a ``str``, it must be in ISO format.
182
+ qubits (list): System qubit parameters as a list of lists of
183
+ :class:`Nduv` objects
184
+ gates (list): System gate parameters as a list of :class:`GateProperties`
185
+ objects
186
+ general (list): General parameters as a list of :class:`Nduv`
187
+ objects
188
+ kwargs: optional additional fields
189
+ """
190
+ self._data = {}
191
+ self.backend_name = backend_name
192
+ self.backend_version = backend_version
193
+ if isinstance(last_update_date, str):
194
+ last_update_date = dateutil.parser.isoparse(last_update_date)
195
+ self.last_update_date = last_update_date
196
+ self.general = general
197
+ self.qubits = qubits
198
+ self.gates = gates
199
+
200
+ self._qubits = {}
201
+ for qubit, props in enumerate(qubits):
202
+ formatted_props = {}
203
+ for prop in props:
204
+ value = self._apply_prefix(prop.value, prop.unit)
205
+ formatted_props[prop.name] = (value, prop.date)
206
+ self._qubits[qubit] = formatted_props
207
+
208
+ self._gates = {}
209
+ for gate in gates:
210
+ if gate.gate not in self._gates:
211
+ self._gates[gate.gate] = {}
212
+ formatted_props = {}
213
+ for param in gate.parameters:
214
+ value = self._apply_prefix(param.value, param.unit)
215
+ formatted_props[param.name] = (value, param.date)
216
+ self._gates[gate.gate][tuple(gate.qubits)] = formatted_props
217
+ self._data.update(kwargs)
218
+
219
+ def __getattr__(self, name):
220
+ try:
221
+ return self._data[name]
222
+ except KeyError as ex:
223
+ raise AttributeError(f"Attribute {name} is not defined") from ex
224
+
225
+ @classmethod
226
+ def from_dict(cls, data):
227
+ """Create a new BackendProperties object from a dictionary.
228
+
229
+ Args:
230
+ data (dict): A dictionary representing the BackendProperties to create. It will be in
231
+ the same format as output by :meth:`to_dict`.
232
+
233
+ Returns:
234
+ BackendProperties: The BackendProperties from the input dictionary.
235
+ """
236
+ in_data = copy.copy(data)
237
+ backend_name = in_data.pop("backend_name")
238
+ backend_version = in_data.pop("backend_version")
239
+ last_update_date = in_data.pop("last_update_date")
240
+ qubits = []
241
+ for qubit in in_data.pop("qubits"):
242
+ nduvs = []
243
+ for nduv in qubit:
244
+ nduvs.append(Nduv.from_dict(nduv))
245
+ qubits.append(nduvs)
246
+ gates = [GateProperties.from_dict(x) for x in in_data.pop("gates")]
247
+ general = [Nduv.from_dict(x) for x in in_data.pop("general")]
248
+
249
+ return cls(
250
+ backend_name, backend_version, last_update_date, qubits, gates, general, **in_data
251
+ )
252
+
253
+ def to_dict(self):
254
+ """Return a dictionary format representation of the BackendProperties.
255
+
256
+ Returns:
257
+ dict: The dictionary form of the BackendProperties.
258
+ """
259
+ out_dict = {
260
+ "backend_name": self.backend_name,
261
+ "backend_version": self.backend_version,
262
+ "last_update_date": self.last_update_date,
263
+ }
264
+ out_dict["qubits"] = []
265
+ for qubit in self.qubits:
266
+ qubit_props = []
267
+ for item in qubit:
268
+ qubit_props.append(item.to_dict())
269
+ out_dict["qubits"].append(qubit_props)
270
+ out_dict["gates"] = [x.to_dict() for x in self.gates]
271
+ out_dict["general"] = [x.to_dict() for x in self.general]
272
+ out_dict.update(self._data)
273
+ return out_dict
274
+
275
+ def __eq__(self, other):
276
+ if isinstance(other, AerBackendProperties):
277
+ if self.to_dict() == other.to_dict():
278
+ return True
279
+ return False
280
+
281
+ def gate_property(
282
+ self,
283
+ gate: str,
284
+ qubits: Union[int, Iterable[int]] = None,
285
+ name: str = None,
286
+ ) -> Union[
287
+ Dict[Tuple[int, ...], Dict[str, PropertyT]],
288
+ Dict[str, PropertyT],
289
+ PropertyT,
290
+ ]:
291
+ """
292
+ Return the property of the given gate.
293
+
294
+ Args:
295
+ gate: Name of the gate.
296
+ qubits: The qubit to find the property for.
297
+ name: Optionally used to specify which gate property to return.
298
+
299
+ Returns:
300
+ Gate property as a tuple of the value and the time it was measured.
301
+
302
+ Raises:
303
+ ValueError: If the property is not found or name is
304
+ specified but qubit is not.
305
+ """
306
+ try:
307
+ result = self._gates[gate]
308
+ if qubits is not None:
309
+ if isinstance(qubits, int):
310
+ qubits = (qubits,)
311
+ result = result[tuple(qubits)]
312
+ if name:
313
+ result = result[name]
314
+ elif name:
315
+ raise ValueError(f"Provide qubits to get {name} of {gate}")
316
+ except KeyError as ex:
317
+ raise ValueError(f"Could not find the desired property for {gate}") from ex
318
+ return result
319
+
320
+ def faulty_qubits(self):
321
+ """Return a list of faulty qubits."""
322
+ faulty = []
323
+ for qubit in self._qubits:
324
+ if not self.is_qubit_operational(qubit):
325
+ faulty.append(qubit)
326
+ return faulty
327
+
328
+ def faulty_gates(self):
329
+ """Return a list of faulty gates."""
330
+ faulty = []
331
+ for gate in self.gates:
332
+ if not self.is_gate_operational(gate.gate, gate.qubits):
333
+ faulty.append(gate)
334
+ return faulty
335
+
336
+ def is_gate_operational(self, gate: str, qubits: Union[int, Iterable[int]] = None) -> bool:
337
+ """
338
+ Return the operational status of the given gate.
339
+
340
+ Args:
341
+ gate: Name of the gate.
342
+ qubits: The qubit to find the operational status for.
343
+
344
+ Returns:
345
+ bool: Operational status of the given gate. True if the gate is operational,
346
+ False otherwise.
347
+ """
348
+ properties = self.gate_property(gate, qubits)
349
+ if "operational" in properties:
350
+ return bool(properties["operational"][0])
351
+ return True # if property operational not existent, then True.
352
+
353
+ def gate_error(self, gate: str, qubits: Union[int, Iterable[int]]) -> float:
354
+ """
355
+ Return gate error estimates from backend properties.
356
+
357
+ Args:
358
+ gate: The gate for which to get the error.
359
+ qubits: The specific qubits for the gate.
360
+
361
+ Returns:
362
+ Gate error of the given gate and qubit(s).
363
+ """
364
+ return self.gate_property(gate, qubits, "gate_error")[0] # Throw away datetime at index 1
365
+
366
+ def gate_length(self, gate: str, qubits: Union[int, Iterable[int]]) -> float:
367
+ """
368
+ Return the duration of the gate in units of seconds.
369
+
370
+ Args:
371
+ gate: The gate for which to get the duration.
372
+ qubits: The specific qubits for the gate.
373
+
374
+ Returns:
375
+ Gate length of the given gate and qubit(s).
376
+ """
377
+ return self.gate_property(gate, qubits, "gate_length")[0] # Throw away datetime at index 1
378
+
379
+ def qubit_property(
380
+ self,
381
+ qubit: int,
382
+ name: str = None,
383
+ ) -> Union[
384
+ Dict[str, PropertyT],
385
+ PropertyT,
386
+ ]:
387
+ """
388
+ Return the property of the given qubit.
389
+
390
+ Args:
391
+ qubit: The property to look for.
392
+ name: Optionally used to specify within the hierarchy which property to return.
393
+
394
+ Returns:
395
+ Qubit property as a tuple of the value and the time it was measured.
396
+
397
+ Raises:
398
+ ValueError: If the property is not found.
399
+ """
400
+ try:
401
+ result = self._qubits[qubit]
402
+ if name is not None:
403
+ result = result[name]
404
+ except KeyError as ex:
405
+ formatted_name = "y '" + name + "'" if name else "ies"
406
+ raise ValueError(
407
+ f"Couldn't find the propert{formatted_name} for qubit {qubit}."
408
+ ) from ex
409
+ return result
410
+
411
+ def t1(self, qubit: int) -> float: # pylint: disable=invalid-name
412
+ """
413
+ Return the T1 time of the given qubit.
414
+
415
+ Args:
416
+ qubit: Qubit for which to return the T1 time of.
417
+
418
+ Returns:
419
+ T1 time of the given qubit.
420
+ """
421
+ return self.qubit_property(qubit, "T1")[0] # Throw away datetime at index 1
422
+
423
+ def t2(self, qubit: int) -> float: # pylint: disable=invalid-name
424
+ """
425
+ Return the T2 time of the given qubit.
426
+
427
+ Args:
428
+ qubit: Qubit for which to return the T2 time of.
429
+
430
+ Returns:
431
+ T2 time of the given qubit.
432
+ """
433
+ return self.qubit_property(qubit, "T2")[0] # Throw away datetime at index 1
434
+
435
+ def frequency(self, qubit: int) -> float:
436
+ """
437
+ Return the frequency of the given qubit.
438
+
439
+ Args:
440
+ qubit: Qubit for which to return frequency of.
441
+
442
+ Returns:
443
+ Frequency of the given qubit.
444
+ """
445
+ return self.qubit_property(qubit, "frequency")[0] # Throw away datetime at index 1
446
+
447
+ def readout_error(self, qubit: int) -> float:
448
+ """
449
+ Return the readout error of the given qubit.
450
+
451
+ Args:
452
+ qubit: Qubit for which to return the readout error of.
453
+
454
+ Return:
455
+ Readout error of the given qubit.
456
+ """
457
+ return self.qubit_property(qubit, "readout_error")[0] # Throw away datetime at index 1
458
+
459
+ def readout_length(self, qubit: int) -> float:
460
+ """
461
+ Return the readout length [sec] of the given qubit.
462
+
463
+ Args:
464
+ qubit: Qubit for which to return the readout length of.
465
+
466
+ Return:
467
+ Readout length of the given qubit.
468
+ """
469
+ return self.qubit_property(qubit, "readout_length")[0] # Throw away datetime at index 1
470
+
471
+ def is_qubit_operational(self, qubit: int) -> bool:
472
+ """
473
+ Return the operational status of the given qubit.
474
+
475
+ Args:
476
+ qubit: Qubit for which to return operational status of.
477
+
478
+ Returns:
479
+ Operational status of the given qubit.
480
+ """
481
+ properties = self.qubit_property(qubit)
482
+ if "operational" in properties:
483
+ return bool(properties["operational"][0])
484
+ return True # if property operational not existent, then True.
485
+
486
+ def _apply_prefix(self, value: float, unit: str) -> float:
487
+ """
488
+ Given a SI unit prefix and value, apply the prefix to convert to
489
+ standard SI unit.
490
+
491
+ Args:
492
+ value: The number to apply prefix to.
493
+ unit: String prefix.
494
+
495
+ Returns:
496
+ Converted value.
497
+
498
+ Raises:
499
+ ValueError: If the units aren't recognized.
500
+ """
501
+ try:
502
+ return apply_prefix(value, unit)
503
+ except Exception as ex:
504
+ raise ValueError(f"Could not understand units: {unit}") from ex
505
+
506
+
507
+ def target_to_backend_properties(target: Target):
508
+ """Convert a :class:`qiskit.transpiler.Target` into a legacy :class:`~.AerBackendProperties`"""
509
+
510
+ properties_dict: dict[str, Any] = {
511
+ "backend_name": "",
512
+ "backend_version": "",
513
+ "last_update_date": None,
514
+ "general": [],
515
+ }
516
+ gates = []
517
+ qubits = []
518
+ for gate, qargs_list in target.items():
519
+ if gate != "measure":
520
+ for qargs, props in qargs_list.items():
521
+ property_list = []
522
+ if getattr(props, "duration", None) is not None:
523
+ property_list.append(
524
+ {
525
+ "date": datetime.datetime.now(datetime.timezone.utc),
526
+ "name": "gate_length",
527
+ "unit": "s",
528
+ "value": props.duration,
529
+ }
530
+ )
531
+ if getattr(props, "error", None) is not None:
532
+ property_list.append(
533
+ {
534
+ "date": datetime.datetime.now(datetime.timezone.utc),
535
+ "name": "gate_error",
536
+ "unit": "",
537
+ "value": props.error,
538
+ }
539
+ )
540
+ if property_list:
541
+ gates.append(
542
+ {
543
+ "gate": gate,
544
+ "qubits": list(qargs),
545
+ "parameters": property_list,
546
+ "name": gate + "_".join([str(x) for x in qargs]),
547
+ }
548
+ )
549
+ else:
550
+ qubit_props: dict[int, Any] = {}
551
+ if target.num_qubits is not None:
552
+ qubit_props = {x: None for x in range(target.num_qubits)}
553
+ for qargs, props in qargs_list.items():
554
+ if qargs is None:
555
+ continue
556
+ qubit = qargs[0]
557
+ props_list = []
558
+ if getattr(props, "error", None) is not None:
559
+ props_list.append(
560
+ {
561
+ "date": datetime.datetime.now(datetime.timezone.utc),
562
+ "name": "readout_error",
563
+ "unit": "",
564
+ "value": props.error,
565
+ }
566
+ )
567
+ if getattr(props, "duration", None) is not None:
568
+ props_list.append(
569
+ {
570
+ "date": datetime.datetime.now(datetime.timezone.utc),
571
+ "name": "readout_length",
572
+ "unit": "s",
573
+ "value": props.duration,
574
+ }
575
+ )
576
+ if not props_list:
577
+ qubit_props = {}
578
+ break
579
+ qubit_props[qubit] = props_list
580
+ if qubit_props and all(x is not None for x in qubit_props.values()):
581
+ qubits = [qubit_props[i] for i in range(target.num_qubits)]
582
+ if gates or qubits:
583
+ properties_dict["gates"] = gates
584
+ properties_dict["qubits"] = qubits
585
+ with warnings.catch_warnings():
586
+ # This raises BackendProperties internally
587
+ warnings.filterwarnings("ignore", category=DeprecationWarning)
588
+ return AerBackendProperties.from_dict(properties_dict)
589
+ else:
590
+ return None