qiskit 1.2.0__cp38-abi3-win32.whl → 1.2.0rc1__cp38-abi3-win32.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 (29) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/_accelerate.pyd +0 -0
  3. qiskit/circuit/__init__.py +2 -5
  4. qiskit/circuit/quantumcircuit.py +4 -4
  5. qiskit/compiler/transpiler.py +1 -1
  6. qiskit/providers/basic_provider/basic_simulator.py +1 -1
  7. qiskit/providers/fake_provider/fake_openpulse_2q.py +3 -3
  8. qiskit/providers/fake_provider/fake_openpulse_3q.py +3 -2
  9. qiskit/providers/fake_provider/fake_pulse_backend.py +1 -2
  10. qiskit/providers/fake_provider/fake_qasm_backend.py +1 -2
  11. qiskit/providers/fake_provider/generic_backend_v2.py +18 -434
  12. qiskit/providers/models/__init__.py +21 -47
  13. qiskit/qasm3/exporter.py +1 -7
  14. qiskit/qpy/__init__.py +1 -1
  15. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +1 -1
  16. qiskit/transpiler/passes/basis/basis_translator.py +1 -2
  17. qiskit/transpiler/passes/optimization/consolidate_blocks.py +1 -7
  18. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +1 -1
  19. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +3 -9
  20. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +1 -1
  21. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +54 -10
  22. qiskit/visualization/bloch.py +1 -44
  23. qiskit/visualization/dag_visualization.py +3 -10
  24. {qiskit-1.2.0.dist-info → qiskit-1.2.0rc1.dist-info}/METADATA +20 -20
  25. {qiskit-1.2.0.dist-info → qiskit-1.2.0rc1.dist-info}/RECORD +29 -29
  26. {qiskit-1.2.0.dist-info → qiskit-1.2.0rc1.dist-info}/WHEEL +1 -1
  27. {qiskit-1.2.0.dist-info → qiskit-1.2.0rc1.dist-info}/LICENSE.txt +0 -0
  28. {qiskit-1.2.0.dist-info → qiskit-1.2.0rc1.dist-info}/entry_points.txt +0 -0
  29. {qiskit-1.2.0.dist-info → qiskit-1.2.0rc1.dist-info}/top_level.txt +0 -0
qiskit/VERSION.txt CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.0rc1
qiskit/_accelerate.pyd CHANGED
Binary file
@@ -301,10 +301,9 @@ assist compilation workflows. These include:
301
301
  * :data:`SessionEquivalenceLibrary`, a mutable instance of :class:`EquivalenceLibrary` which is used
302
302
  by default by the compiler's :class:`.BasisTranslator`.
303
303
 
304
- There are also utilities for generating random circuits:
304
+ There is also a utility for generating random circuits:
305
305
 
306
- * :func:`.random_circuit`
307
- * :func:`.random_clifford_circuit`
306
+ * :func:`random.random_circuit`
308
307
 
309
308
  Finally, the circuit module has its own exception class, to indicate when things went wrong in
310
309
  circuit-specific manners:
@@ -1005,7 +1004,6 @@ Generating random circuits
1005
1004
 
1006
1005
  .. currentmodule:: qiskit.circuit.random
1007
1006
  .. autofunction:: random_circuit
1008
- .. autofunction:: random_clifford_circuit
1009
1007
  .. currentmodule:: qiskit.circuit
1010
1008
 
1011
1009
 
@@ -1252,4 +1250,3 @@ from .controlflow import (
1252
1250
  )
1253
1251
 
1254
1252
  from .annotated_operation import AnnotatedOperation, InverseModifier, ControlModifier, PowerModifier
1255
- from .random import random_circuit, random_clifford_circuit
@@ -4188,7 +4188,7 @@ class QuantumCircuit:
4188
4188
  @overload
4189
4189
  def assign_parameters(
4190
4190
  self,
4191
- parameters: Union[Mapping[Parameter, ParameterValueType], Iterable[ParameterValueType]],
4191
+ parameters: Union[Mapping[Parameter, ParameterValueType], Sequence[ParameterValueType]],
4192
4192
  inplace: Literal[False] = ...,
4193
4193
  *,
4194
4194
  flat_input: bool = ...,
@@ -4198,7 +4198,7 @@ class QuantumCircuit:
4198
4198
  @overload
4199
4199
  def assign_parameters(
4200
4200
  self,
4201
- parameters: Union[Mapping[Parameter, ParameterValueType], Iterable[ParameterValueType]],
4201
+ parameters: Union[Mapping[Parameter, ParameterValueType], Sequence[ParameterValueType]],
4202
4202
  inplace: Literal[True] = ...,
4203
4203
  *,
4204
4204
  flat_input: bool = ...,
@@ -4207,7 +4207,7 @@ class QuantumCircuit:
4207
4207
 
4208
4208
  def assign_parameters( # pylint: disable=missing-raises-doc
4209
4209
  self,
4210
- parameters: Union[Mapping[Parameter, ParameterValueType], Iterable[ParameterValueType]],
4210
+ parameters: Union[Mapping[Parameter, ParameterValueType], Sequence[ParameterValueType]],
4211
4211
  inplace: bool = False,
4212
4212
  *,
4213
4213
  flat_input: bool = False,
@@ -4317,7 +4317,7 @@ class QuantumCircuit:
4317
4317
  target._data.assign_parameters_mapping(parameter_binds)
4318
4318
  else:
4319
4319
  parameter_binds = _ParameterBindsSequence(target._data.parameters, parameters)
4320
- target._data.assign_parameters_iterable(parameters)
4320
+ target._data.assign_parameters_sequence(parameters)
4321
4321
 
4322
4322
  # Finally, assign the parameters inside any of the calibrations. We don't track these in
4323
4323
  # the `ParameterTable`, so we manually reconstruct things.
@@ -23,7 +23,7 @@ from qiskit.circuit.quantumcircuit import QuantumCircuit
23
23
  from qiskit.dagcircuit import DAGCircuit
24
24
  from qiskit.providers.backend import Backend
25
25
  from qiskit.providers.backend_compat import BackendV2Converter
26
- from qiskit.providers.models.backendproperties import BackendProperties
26
+ from qiskit.providers.models import BackendProperties
27
27
  from qiskit.pulse import Schedule, InstructionScheduleMap
28
28
  from qiskit.transpiler import Layout, CouplingMap, PropertySet
29
29
  from qiskit.transpiler.basepasses import BasePass
@@ -43,7 +43,7 @@ from qiskit.circuit.library import UnitaryGate
43
43
  from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping, GlobalPhaseGate
44
44
  from qiskit.providers import Provider
45
45
  from qiskit.providers.backend import BackendV2
46
- from qiskit.providers.models.backendconfiguration import BackendConfiguration
46
+ from qiskit.providers.models import BackendConfiguration
47
47
  from qiskit.providers.options import Options
48
48
  from qiskit.qobj import QasmQobj, QasmQobjConfig, QasmQobjExperiment
49
49
  from qiskit.result import Result
@@ -16,14 +16,14 @@ Fake backend supporting OpenPulse.
16
16
  import datetime
17
17
  import warnings
18
18
 
19
- from qiskit.providers.models.backendconfiguration import (
19
+ from qiskit.providers.models import (
20
20
  GateConfig,
21
21
  PulseBackendConfiguration,
22
+ PulseDefaults,
23
+ Command,
22
24
  UchannelLO,
23
25
  )
24
-
25
26
  from qiskit.providers.models.backendproperties import Nduv, Gate, BackendProperties
26
- from qiskit.providers.models.pulsedefaults import PulseDefaults, Command
27
27
  from qiskit.qobj import PulseQobjInstruction
28
28
 
29
29
  from .fake_backend import FakeBackend
@@ -15,12 +15,13 @@ Fake backend supporting OpenPulse.
15
15
  """
16
16
  import warnings
17
17
 
18
- from qiskit.providers.models.backendconfiguration import (
18
+ from qiskit.providers.models import (
19
19
  GateConfig,
20
20
  PulseBackendConfiguration,
21
+ PulseDefaults,
22
+ Command,
21
23
  UchannelLO,
22
24
  )
23
- from qiskit.providers.models.pulsedefaults import PulseDefaults, Command
24
25
  from qiskit.qobj import PulseQobjInstruction
25
26
 
26
27
  from .fake_backend import FakeBackend
@@ -15,8 +15,7 @@ Fake backend abstract class for mock backends supporting OpenPulse.
15
15
  """
16
16
 
17
17
  from qiskit.exceptions import QiskitError
18
- from qiskit.providers.models.backendconfiguration import PulseBackendConfiguration
19
- from qiskit.providers.models.pulsedefaults import PulseDefaults
18
+ from qiskit.providers.models import PulseBackendConfiguration, PulseDefaults
20
19
 
21
20
  from .fake_qasm_backend import FakeQasmBackend
22
21
  from .utils.json_decoder import decode_pulse_defaults
@@ -19,8 +19,7 @@ import os
19
19
  import warnings
20
20
 
21
21
  from qiskit.exceptions import QiskitError
22
- from qiskit.providers.models.backendproperties import BackendProperties
23
- from qiskit.providers.models.backendconfiguration import QasmBackendConfiguration
22
+ from qiskit.providers.models import BackendProperties, QasmBackendConfiguration
24
23
 
25
24
  from .utils.json_decoder import (
26
25
  decode_backend_configuration,
@@ -16,7 +16,6 @@ from __future__ import annotations
16
16
  import warnings
17
17
 
18
18
  from collections.abc import Iterable
19
- from typing import List, Dict, Any, Union
20
19
  import numpy as np
21
20
 
22
21
  from qiskit import pulse
@@ -36,12 +35,12 @@ from qiskit.transpiler import CouplingMap, Target, InstructionProperties, QubitP
36
35
  from qiskit.providers import Options
37
36
  from qiskit.providers.basic_provider import BasicSimulator
38
37
  from qiskit.providers.backend import BackendV2
38
+ from qiskit.providers.models import (
39
+ PulseDefaults,
40
+ Command,
41
+ )
42
+ from qiskit.qobj import PulseQobjInstruction, PulseLibraryItem
39
43
  from qiskit.utils import optionals as _optionals
40
- from qiskit.providers.models.pulsedefaults import Command
41
- from qiskit.qobj.converters.pulse_instruction import QobjToInstructionConverter
42
- from qiskit.pulse.calibration_entries import PulseQobjDef
43
- from qiskit.providers.models.pulsedefaults import MeasurementKernel, Discriminator
44
- from qiskit.qobj.pulse_qobj import QobjMeasurementOption
45
44
 
46
45
  # Noise default values/ranges for duration and error of supported
47
46
  # instructions. There are two possible formats:
@@ -75,432 +74,17 @@ _QUBIT_PROPERTIES = {
75
74
  "frequency": (5e9, 5.5e9),
76
75
  }
77
76
 
78
-
79
- class PulseDefaults:
80
- """Internal - Description of default settings for Pulse systems. These are instructions
81
- or settings that
82
- may be good starting points for the Pulse user. The user may modify these defaults for custom
83
- scheduling.
84
- """
85
-
86
- # Copy from the deprecated from qiskit.providers.models.pulsedefaults.PulseDefaults
87
-
88
- _data = {}
89
-
90
- def __init__(
91
- self,
92
- qubit_freq_est: List[float],
93
- meas_freq_est: List[float],
94
- buffer: int,
95
- pulse_library: List[PulseLibraryItem],
96
- cmd_def: List[Command],
97
- meas_kernel: MeasurementKernel = None,
98
- discriminator: Discriminator = None,
99
- **kwargs: Dict[str, Any],
100
- ):
101
- """
102
- Validate and reformat transport layer inputs to initialize.
103
- Args:
104
- qubit_freq_est: Estimated qubit frequencies in GHz.
105
- meas_freq_est: Estimated measurement cavity frequencies in GHz.
106
- buffer: Default buffer time (in units of dt) between pulses.
107
- pulse_library: Pulse name and sample definitions.
108
- cmd_def: Operation name and definition in terms of Commands.
109
- meas_kernel: The measurement kernels
110
- discriminator: The discriminators
111
- **kwargs: Other attributes for the super class.
112
- """
113
- self._data = {}
114
- self.buffer = buffer
115
- self.qubit_freq_est = [freq * 1e9 for freq in qubit_freq_est]
116
- """Qubit frequencies in Hertz."""
117
- self.meas_freq_est = [freq * 1e9 for freq in meas_freq_est]
118
- """Measurement frequencies in Hertz."""
119
- self.pulse_library = pulse_library
120
- self.cmd_def = cmd_def
121
- self.instruction_schedule_map = InstructionScheduleMap()
122
- self.converter = QobjToInstructionConverter(pulse_library)
123
-
124
- for inst in cmd_def:
125
- entry = PulseQobjDef(converter=self.converter, name=inst.name)
126
- entry.define(inst.sequence, user_provided=False)
127
- self.instruction_schedule_map._add(
128
- instruction_name=inst.name,
129
- qubits=tuple(inst.qubits),
130
- entry=entry,
131
- )
132
-
133
- if meas_kernel is not None:
134
- self.meas_kernel = meas_kernel
135
- if discriminator is not None:
136
- self.discriminator = discriminator
137
-
138
- self._data.update(kwargs)
139
-
140
- def __getattr__(self, name):
141
- try:
142
- return self._data[name]
143
- except KeyError as ex:
144
- raise AttributeError(f"Attribute {name} is not defined") from ex
145
-
146
- def to_dict(self):
147
- """Return a dictionary format representation of the PulseDefaults.
148
- Returns:
149
- dict: The dictionary form of the PulseDefaults.
150
- """
151
- out_dict = {
152
- "qubit_freq_est": self.qubit_freq_est,
153
- "meas_freq_est": self.qubit_freq_est,
154
- "buffer": self.buffer,
155
- "pulse_library": [x.to_dict() for x in self.pulse_library],
156
- "cmd_def": [x.to_dict() for x in self.cmd_def],
157
- }
158
- if hasattr(self, "meas_kernel"):
159
- out_dict["meas_kernel"] = self.meas_kernel.to_dict()
160
- if hasattr(self, "discriminator"):
161
- out_dict["discriminator"] = self.discriminator.to_dict()
162
- for key, value in self.__dict__.items():
163
- if key not in [
164
- "qubit_freq_est",
165
- "meas_freq_est",
166
- "buffer",
167
- "pulse_library",
168
- "cmd_def",
169
- "meas_kernel",
170
- "discriminator",
171
- "converter",
172
- "instruction_schedule_map",
173
- ]:
174
- out_dict[key] = value
175
- out_dict.update(self._data)
176
-
177
- out_dict["qubit_freq_est"] = [freq * 1e-9 for freq in self.qubit_freq_est]
178
- out_dict["meas_freq_est"] = [freq * 1e-9 for freq in self.meas_freq_est]
179
- return out_dict
180
-
181
- @classmethod
182
- def from_dict(cls, data):
183
- """Create a new PulseDefaults object from a dictionary.
184
-
185
- Args:
186
- data (dict): A dictionary representing the PulseDefaults
187
- to create. It will be in the same format as output by
188
- :meth:`to_dict`.
189
- Returns:
190
- PulseDefaults: The PulseDefaults from the input dictionary.
191
- """
192
- schema = {
193
- "pulse_library": PulseLibraryItem, # The class PulseLibraryItem is deprecated
194
- "cmd_def": Command,
195
- "meas_kernel": MeasurementKernel,
196
- "discriminator": Discriminator,
197
- }
198
-
199
- # Pulse defaults data is nested dictionary.
200
- # To avoid deepcopy and avoid mutating the source object, create new dict here.
201
- in_data = {}
202
- for key, value in data.items():
203
- if key in schema:
204
- with warnings.catch_warnings():
205
- # The class PulseLibraryItem is deprecated
206
- warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
207
- if isinstance(value, list):
208
- in_data[key] = list(map(schema[key].from_dict, value))
209
- else:
210
- in_data[key] = schema[key].from_dict(value)
211
- else:
212
- in_data[key] = value
213
-
214
- return cls(**in_data)
215
-
216
- def __str__(self):
217
- qubit_freqs = [freq / 1e9 for freq in self.qubit_freq_est]
218
- meas_freqs = [freq / 1e9 for freq in self.meas_freq_est]
219
- qfreq = f"Qubit Frequencies [GHz]\n{qubit_freqs}"
220
- mfreq = f"Measurement Frequencies [GHz]\n{meas_freqs} "
221
- return f"<{self.__class__.__name__}({str(self.instruction_schedule_map)}{qfreq}\n{mfreq})>"
222
-
223
-
224
- def _to_complex(value: Union[List[float], complex]) -> complex:
225
- """Convert the input value to type ``complex``.
226
- Args:
227
- value: Value to be converted.
228
- Returns:
229
- Input value in ``complex``.
230
- Raises:
231
- TypeError: If the input value is not in the expected format.
232
- """
233
- if isinstance(value, list) and len(value) == 2:
234
- return complex(value[0], value[1])
235
- elif isinstance(value, complex):
236
- return value
237
-
238
- raise TypeError(f"{value} is not in a valid complex number format.")
239
-
240
-
241
- class PulseLibraryItem:
242
- """INTERNAL - An item in a pulse library."""
243
-
244
- # Copy from the deprecated from qiskit.qobj.PulseLibraryItem
245
- def __init__(self, name, samples):
246
- """Instantiate a pulse library item.
247
-
248
- Args:
249
- name (str): A name for the pulse.
250
- samples (list[complex]): A list of complex values defining pulse
251
- shape.
252
- """
253
- self.name = name
254
- if isinstance(samples[0], list):
255
- self.samples = np.array([complex(sample[0], sample[1]) for sample in samples])
256
- else:
257
- self.samples = samples
258
-
259
- def to_dict(self):
260
- """Return a dictionary format representation of the pulse library item.
261
-
262
- Returns:
263
- dict: The dictionary form of the PulseLibraryItem.
264
- """
265
- return {"name": self.name, "samples": self.samples}
266
-
267
- @classmethod
268
- def from_dict(cls, data):
269
- """Create a new PulseLibraryItem object from a dictionary.
270
-
271
- Args:
272
- data (dict): A dictionary for the experiment config
273
-
274
- Returns:
275
- PulseLibraryItem: The object from the input dictionary.
276
- """
277
- return cls(**data)
278
-
279
- def __repr__(self):
280
- return f"PulseLibraryItem({self.name}, {repr(self.samples)})"
281
-
282
- def __str__(self):
283
- return f"Pulse Library Item:\n\tname: {self.name}\n\tsamples: {self.samples}"
284
-
285
- def __eq__(self, other):
286
- if isinstance(other, PulseLibraryItem):
287
- if self.to_dict() == other.to_dict():
288
- return True
289
- return False
290
-
291
-
292
- class PulseQobjInstruction:
293
- """Internal - A class representing a single instruction in a PulseQobj Experiment."""
294
-
295
- # Copy from the deprecated from qiskit.qobj.PulseQobjInstruction
296
-
297
- _COMMON_ATTRS = [
298
- "ch",
299
- "conditional",
300
- "val",
301
- "phase",
302
- "frequency",
303
- "duration",
304
- "qubits",
305
- "memory_slot",
306
- "register_slot",
307
- "label",
308
- "type",
309
- "pulse_shape",
310
- "parameters",
311
- ]
312
-
313
- def __init__(
314
- self,
315
- name,
316
- t0,
317
- ch=None,
318
- conditional=None,
319
- val=None,
320
- phase=None,
321
- duration=None,
322
- qubits=None,
323
- memory_slot=None,
324
- register_slot=None,
325
- kernels=None,
326
- discriminators=None,
327
- label=None,
328
- type=None, # pylint: disable=invalid-name,redefined-builtin
329
- pulse_shape=None,
330
- parameters=None,
331
- frequency=None,
332
- ):
333
- """Instantiate a new PulseQobjInstruction object.
334
-
335
- Args:
336
- name (str): The name of the instruction
337
- t0 (int): Pulse start time in integer **dt** units.
338
- ch (str): The channel to apply the pulse instruction.
339
- conditional (int): The register to use for a conditional for this
340
- instruction
341
- val (complex): Complex value to apply, bounded by an absolute value
342
- of 1.
343
- phase (float): if a ``fc`` instruction, the frame change phase in
344
- radians.
345
- frequency (float): if a ``sf`` instruction, the frequency in Hz.
346
- duration (int): The duration of the pulse in **dt** units.
347
- qubits (list): A list of ``int`` representing the qubits the
348
- instruction operates on
349
- memory_slot (list): If a ``measure`` instruction this is a list
350
- of ``int`` containing the list of memory slots to store the
351
- measurement results in (must be the same length as qubits).
352
- If a ``bfunc`` instruction this is a single ``int`` of the
353
- memory slot to store the boolean function result in.
354
- register_slot (list): If a ``measure`` instruction this is a list
355
- of ``int`` containing the list of register slots in which to
356
- store the measurement results (must be the same length as
357
- qubits). If a ``bfunc`` instruction this is a single ``int``
358
- of the register slot in which to store the result.
359
- kernels (list): List of :class:`QobjMeasurementOption` objects
360
- defining the measurement kernels and set of parameters if the
361
- measurement level is 1 or 2. Only used for ``acquire``
362
- instructions.
363
- discriminators (list): A list of :class:`QobjMeasurementOption`
364
- used to set the discriminators to be used if the measurement
365
- level is 2. Only used for ``acquire`` instructions.
366
- label (str): Label of instruction
367
- type (str): Type of instruction
368
- pulse_shape (str): The shape of the parametric pulse
369
- parameters (dict): The parameters for a parametric pulse
370
- """
371
- self.name = name
372
- self.t0 = t0
373
- if ch is not None:
374
- self.ch = ch
375
- if conditional is not None:
376
- self.conditional = conditional
377
- if val is not None:
378
- self.val = val
379
- if phase is not None:
380
- self.phase = phase
381
- if frequency is not None:
382
- self.frequency = frequency
383
- if duration is not None:
384
- self.duration = duration
385
- if qubits is not None:
386
- self.qubits = qubits
387
- if memory_slot is not None:
388
- self.memory_slot = memory_slot
389
- if register_slot is not None:
390
- self.register_slot = register_slot
391
- if kernels is not None:
392
- self.kernels = kernels
393
- if discriminators is not None:
394
- self.discriminators = discriminators
395
- if label is not None:
396
- self.label = label
397
- if type is not None:
398
- self.type = type
399
- if pulse_shape is not None:
400
- self.pulse_shape = pulse_shape
401
- if parameters is not None:
402
- self.parameters = parameters
403
-
404
- def to_dict(self):
405
- """Return a dictionary format representation of the Instruction.
406
-
407
- Returns:
408
- dict: The dictionary form of the PulseQobjInstruction.
409
- """
410
- out_dict = {"name": self.name, "t0": self.t0}
411
- for attr in self._COMMON_ATTRS:
412
- if hasattr(self, attr):
413
- out_dict[attr] = getattr(self, attr)
414
- if hasattr(self, "kernels"):
415
- out_dict["kernels"] = [x.to_dict() for x in self.kernels]
416
- if hasattr(self, "discriminators"):
417
- out_dict["discriminators"] = [x.to_dict() for x in self.discriminators]
418
- return out_dict
419
-
420
- def __repr__(self):
421
- out = f'PulseQobjInstruction(name="{self.name}", t0={self.t0}'
422
- for attr in self._COMMON_ATTRS:
423
- attr_val = getattr(self, attr, None)
424
- if attr_val is not None:
425
- if isinstance(attr_val, str):
426
- out += f', {attr}="{attr_val}"'
427
- else:
428
- out += f", {attr}={attr_val}"
429
- out += ")"
430
- return out
431
-
432
- def __str__(self):
433
- out = f"Instruction: {self.name}\n"
434
- out += f"\t\tt0: {self.t0}\n"
435
- for attr in self._COMMON_ATTRS:
436
- if hasattr(self, attr):
437
- out += f"\t\t{attr}: {getattr(self, attr)}\n"
438
- return out
439
-
440
- @classmethod
441
- def from_dict(cls, data):
442
- """Create a new PulseQobjExperimentConfig object from a dictionary.
443
-
444
- Args:
445
- data (dict): A dictionary for the experiment config
446
-
447
- Returns:
448
- PulseQobjInstruction: The object from the input dictionary.
449
- """
450
- schema = {
451
- "discriminators": QobjMeasurementOption,
452
- "kernels": QobjMeasurementOption,
453
- }
454
- skip = ["t0", "name"]
455
-
456
- # Pulse instruction data is nested dictionary.
457
- # To avoid deepcopy and avoid mutating the source object, create new dict here.
458
- in_data = {}
459
- for key, value in data.items():
460
- if key in skip:
461
- continue
462
- if key == "parameters":
463
- # This is flat dictionary of parametric pulse parameters
464
- formatted_value = value.copy()
465
- if "amp" in formatted_value:
466
- formatted_value["amp"] = _to_complex(formatted_value["amp"])
467
- in_data[key] = formatted_value
468
- continue
469
- if key in schema:
470
- if isinstance(value, list):
471
- in_data[key] = list(map(schema[key].from_dict, value))
472
- else:
473
- in_data[key] = schema[key].from_dict(value)
474
- else:
475
- in_data[key] = value
476
-
477
- return cls(data["name"], data["t0"], **in_data)
478
-
479
- def __eq__(self, other):
480
- if isinstance(other, PulseQobjInstruction):
481
- if self.to_dict() == other.to_dict():
482
- return True
483
- return False
484
-
485
-
486
- def _pulse_library():
487
- # The number of samples determines the pulse durations of the corresponding
488
- # instructions. This default defines pulses with durations in multiples of
489
- # 16 dt for consistency with the pulse granularity of real IBM devices, but
490
- # keeps the number smaller than what would be realistic for
491
- # manageability. If needed, more realistic durations could be added in the
492
- # future (order of 160dt for 1q gates, 1760dt for 2q gates and measure).
493
- return [
494
- PulseLibraryItem(
495
- name="pulse_1", samples=np.linspace(0, 1.0, 16, dtype=np.complex128)
496
- ), # 16dt
497
- PulseLibraryItem(
498
- name="pulse_2", samples=np.linspace(0, 1.0, 32, dtype=np.complex128)
499
- ), # 32dt
500
- PulseLibraryItem(
501
- name="pulse_3", samples=np.linspace(0, 1.0, 64, dtype=np.complex128)
502
- ), # 64dt
503
- ]
77
+ # The number of samples determines the pulse durations of the corresponding
78
+ # instructions. This default defines pulses with durations in multiples of
79
+ # 16 dt for consistency with the pulse granularity of real IBM devices, but
80
+ # keeps the number smaller than what would be realistic for
81
+ # manageability. If needed, more realistic durations could be added in the
82
+ # future (order of 160dt for 1q gates, 1760dt for 2q gates and measure).
83
+ _PULSE_LIBRARY = [
84
+ PulseLibraryItem(name="pulse_1", samples=np.linspace(0, 1.0, 16, dtype=np.complex128)), # 16dt
85
+ PulseLibraryItem(name="pulse_2", samples=np.linspace(0, 1.0, 32, dtype=np.complex128)), # 32dt
86
+ PulseLibraryItem(name="pulse_3", samples=np.linspace(0, 1.0, 64, dtype=np.complex128)), # 64dt
87
+ ]
504
88
 
505
89
 
506
90
  class GenericBackendV2(BackendV2):
@@ -678,7 +262,7 @@ class GenericBackendV2(BackendV2):
678
262
  acting on qargs.
679
263
  """
680
264
 
681
- pulse_library = _pulse_library()
265
+ pulse_library = _PULSE_LIBRARY
682
266
  # Note that the calibration pulses are different for
683
267
  # 1q gates vs 2q gates vs measurement instructions.
684
268
  if inst == "measure":
@@ -768,7 +352,7 @@ class GenericBackendV2(BackendV2):
768
352
  qubit_freq_est=qubit_freq_est,
769
353
  meas_freq_est=meas_freq_est,
770
354
  buffer=0,
771
- pulse_library=_pulse_library(),
355
+ pulse_library=_PULSE_LIBRARY,
772
356
  cmd_def=cmd_def,
773
357
  )
774
358