qiskit 1.3.2__cp39-abi3-win32.whl → 1.4.0__cp39-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 (65) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +1 -0
  3. qiskit/_accelerate.pyd +0 -0
  4. qiskit/circuit/__init__.py +5 -2
  5. qiskit/circuit/bit.py +12 -0
  6. qiskit/circuit/classicalfunction/__init__.py +13 -1
  7. qiskit/circuit/classicalfunction/boolean_expression.py +10 -1
  8. qiskit/circuit/classicalfunction/classicalfunction.py +10 -1
  9. qiskit/circuit/classicalfunction/exceptions.py +7 -1
  10. qiskit/circuit/delay.py +5 -0
  11. qiskit/circuit/library/generalized_gates/mcmt.py +5 -6
  12. qiskit/circuit/library/phase_oracle.py +24 -17
  13. qiskit/circuit/library/standard_gates/rz.py +7 -7
  14. qiskit/circuit/library/standard_gates/xx_minus_yy.py +0 -30
  15. qiskit/circuit/parametervector.py +25 -5
  16. qiskit/circuit/quantumcircuit.py +68 -2
  17. qiskit/circuit/register.py +13 -0
  18. qiskit/compiler/assembler.py +16 -8
  19. qiskit/compiler/transpiler.py +1 -1
  20. qiskit/dagcircuit/dagdependency_v2.py +4 -2
  21. qiskit/passmanager/passmanager.py +19 -1
  22. qiskit/primitives/backend_estimator_v2.py +17 -0
  23. qiskit/primitives/backend_sampler_v2.py +15 -0
  24. qiskit/providers/backend_compat.py +46 -11
  25. qiskit/providers/basic_provider/basic_simulator.py +15 -3
  26. qiskit/providers/exceptions.py +23 -2
  27. qiskit/providers/models/backendproperties.py +19 -1
  28. qiskit/providers/models/backendstatus.py +10 -0
  29. qiskit/providers/models/jobstatus.py +11 -0
  30. qiskit/pulse/schedule.py +1 -1
  31. qiskit/quantum_info/operators/channel/transformations.py +15 -0
  32. qiskit/result/result.py +109 -20
  33. qiskit/synthesis/evolution/product_formula.py +1 -2
  34. qiskit/synthesis/evolution/qdrift.py +1 -2
  35. qiskit/synthesis/evolution/suzuki_trotter.py +1 -2
  36. qiskit/transpiler/__init__.py +772 -542
  37. qiskit/transpiler/layout.py +6 -6
  38. qiskit/transpiler/passes/calibration/rzx_templates.py +7 -0
  39. qiskit/transpiler/passes/layout/dense_layout.py +12 -0
  40. qiskit/transpiler/passes/layout/sabre_layout.py +13 -0
  41. qiskit/transpiler/passes/layout/vf2_layout.py +11 -0
  42. qiskit/transpiler/passes/layout/vf2_post_layout.py +22 -0
  43. qiskit/transpiler/passes/optimization/normalize_rx_angle.py +8 -0
  44. qiskit/transpiler/passes/optimization/remove_identity_equiv.py +2 -3
  45. qiskit/transpiler/passes/routing/star_prerouting.py +17 -2
  46. qiskit/transpiler/passes/scheduling/scheduling/alap.py +1 -1
  47. qiskit/transpiler/passes/scheduling/scheduling/asap.py +1 -1
  48. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +11 -0
  49. qiskit/transpiler/passmanager_config.py +11 -0
  50. qiskit/transpiler/preset_passmanagers/__init__.py +26 -6
  51. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +188 -118
  52. qiskit/transpiler/preset_passmanagers/common.py +133 -83
  53. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +29 -3
  54. qiskit/transpiler/preset_passmanagers/plugin.py +33 -42
  55. qiskit/transpiler/target.py +41 -9
  56. qiskit/visualization/circuit/text.py +3 -2
  57. qiskit/visualization/gate_map.py +50 -0
  58. qiskit/visualization/pulse_v2/interface.py +0 -2
  59. qiskit/visualization/timeline/interface.py +3 -3
  60. {qiskit-1.3.2.dist-info → qiskit-1.4.0.dist-info}/METADATA +4 -7
  61. {qiskit-1.3.2.dist-info → qiskit-1.4.0.dist-info}/RECORD +65 -65
  62. {qiskit-1.3.2.dist-info → qiskit-1.4.0.dist-info}/LICENSE.txt +0 -0
  63. {qiskit-1.3.2.dist-info → qiskit-1.4.0.dist-info}/WHEEL +0 -0
  64. {qiskit-1.3.2.dist-info → qiskit-1.4.0.dist-info}/entry_points.txt +0 -0
  65. {qiskit-1.3.2.dist-info → qiskit-1.4.0.dist-info}/top_level.txt +0 -0
@@ -445,10 +445,10 @@ class TranspileLayout:
445
445
 
446
446
  The :mod:`~qiskit.transpiler` is unitary-preserving up to the "initial layout"
447
447
  and "final layout" permutations. The initial layout permutation is caused by
448
- setting and applying the initial layout during the :ref:`layout_stage`.
448
+ setting and applying the initial layout during the :ref:`transpiler-preset-stage-layout`.
449
449
  The final layout permutation is caused by :class:`~.SwapGate` insertion during
450
- the :ref:`routing_stage`. This class provides an interface to reason about these
451
- permutations using a variety of helper methods.
450
+ the :ref:`transpiler-preset-stage-routing`. This class provides an interface to reason about
451
+ these permutations using a variety of helper methods.
452
452
 
453
453
  During the layout stage, the transpiler can potentially remap the order of the
454
454
  qubits in the circuit as it fits the circuit to the target backend. For example,
@@ -524,7 +524,7 @@ class TranspileLayout:
524
524
  state from the transpiler. They are defined as:
525
525
 
526
526
  * :attr:`initial_layout` - This attribute is used to model the
527
- permutation caused by the :ref:`layout_stage`. It is a
527
+ permutation caused by the :ref:`transpiler-preset-stage-layout`. It is a
528
528
  :class:`~.Layout` object that maps the input :class:`~.QuantumCircuit`\s
529
529
  :class:`~.circuit.Qubit` objects to the position in the output
530
530
  :class:`.QuantumCircuit.qubits` list.
@@ -536,12 +536,12 @@ class TranspileLayout:
536
536
  is needed when computing the permutation of the :class:`Operator` of
537
537
  the circuit (and used by :meth:`.Operator.from_circuit`).
538
538
  * :attr:`final_layout` - This attribute is used to model the
539
- permutation caused by the :ref:`routing_stage`. It is a
539
+ permutation caused by the :ref:`transpiler-preset-stage-routing`. It is a
540
540
  :class:`~.Layout` object that maps the output circuit's qubits from
541
541
  :class:`.QuantumCircuit.qubits` in the output circuit to their final
542
542
  positions after routing. Importantly, this only represents the
543
543
  permutation caused by inserting :class:`~.SwapGate`\s into
544
- the :class:`~.QuantumCircuit` during the :ref:`routing_stage`.
544
+ the :class:`~.QuantumCircuit` during the :ref:`transpiler-preset-stage-routing`.
545
545
  It is **not** a mapping from the original input circuit's position
546
546
  to the final position at the end of the transpiled circuit.
547
547
  If you need this, you can use the :meth:`.final_index_layout` to generate this.
@@ -16,10 +16,17 @@ Convenience function to load RZXGate based templates.
16
16
 
17
17
  from enum import Enum
18
18
  from typing import List, Dict
19
+ from qiskit.utils import deprecate_func
19
20
 
20
21
  from qiskit.circuit.library.templates import rzx
21
22
 
22
23
 
24
+ @deprecate_func(
25
+ since="1.4",
26
+ removal_timeline="in Qiskit 2.0",
27
+ additional_msg="Use the functions in "
28
+ "qiskit.circuit.library.templates.rzx instead to generate rzx templates",
29
+ )
23
30
  def rzx_templates(template_list: List[str] = None) -> Dict:
24
31
  """Convenience function to get the cost_dict and templates for template matching.
25
32
 
@@ -21,6 +21,8 @@ from qiskit.transpiler.basepasses import AnalysisPass
21
21
  from qiskit.transpiler.exceptions import TranspilerError
22
22
  from qiskit.transpiler.passes.layout import disjoint_utils
23
23
 
24
+ from qiskit.utils import deprecate_arg
25
+
24
26
  from qiskit._accelerate.dense_layout import best_subset
25
27
 
26
28
 
@@ -36,6 +38,16 @@ class DenseLayout(AnalysisPass):
36
38
  by being set in ``property_set``.
37
39
  """
38
40
 
41
+ @deprecate_arg(
42
+ name="backend_prop",
43
+ since="1.4",
44
+ package_name="Qiskit",
45
+ removal_timeline="in Qiskit 2.0",
46
+ additional_msg="The BackendProperties data structure has been deprecated and will be "
47
+ "removed in Qiskit 2.0. The `target` input argument should be used instead. "
48
+ "You can use Target.from_configuration() to build the target from the properties "
49
+ "object, but in 2.0 you will need to generate a target directly.",
50
+ )
39
51
  def __init__(self, coupling_map=None, backend_prop=None, target=None):
40
52
  """DenseLayout initializer.
41
53
 
@@ -328,6 +328,19 @@ class SabreLayout(TransformationPass):
328
328
  for initial, final in enumerate(component.final_permutation)
329
329
  }
330
330
  )
331
+
332
+ # The coupling map may have been split into more components than the DAG. In this case,
333
+ # there will be some physical qubits unaccounted for in our `final_layout`. Strictly the
334
+ # `if` check is unnecessary, but we can avoid the loop for most circuits and backends.
335
+ if len(final_layout) != len(physical_qubits):
336
+ used_qubits = {
337
+ qubit for component in components for qubit in component.coupling_map.graph.nodes()
338
+ }
339
+ for index, qubit in enumerate(physical_qubits):
340
+ if index in used_qubits:
341
+ continue
342
+ final_layout[qubit] = index
343
+
331
344
  if self.property_set["final_layout"] is None:
332
345
  self.property_set["final_layout"] = final_layout
333
346
  else:
@@ -24,6 +24,7 @@ from qiskit.transpiler.basepasses import AnalysisPass
24
24
  from qiskit.transpiler.exceptions import TranspilerError
25
25
  from qiskit.transpiler.passes.layout import vf2_utils
26
26
 
27
+ from qiskit.utils import deprecate_arg
27
28
 
28
29
  logger = logging.getLogger(__name__)
29
30
 
@@ -73,6 +74,16 @@ class VF2Layout(AnalysisPass):
73
74
  ``vf2_avg_error_map`` key in the property set when :class:`~.VF2Layout` is run.
74
75
  """
75
76
 
77
+ @deprecate_arg(
78
+ name="properties",
79
+ since="1.4",
80
+ package_name="Qiskit",
81
+ removal_timeline="in Qiskit 2.0",
82
+ additional_msg="The BackendProperties data structure has been deprecated and will be "
83
+ "removed in Qiskit 2.0. The `target` input argument should be used instead. "
84
+ "You can use Target.from_configuration() to build the target from the properties "
85
+ "object, but in 2.0 you will need to generate a target directly.",
86
+ )
76
87
  def __init__(
77
88
  self,
78
89
  coupling_map=None,
@@ -26,6 +26,7 @@ from qiskit.transpiler.exceptions import TranspilerError
26
26
  from qiskit.providers.exceptions import BackendPropertyError
27
27
  from qiskit.transpiler.passes.layout import vf2_utils
28
28
 
29
+ from qiskit.utils import deprecate_arg
29
30
 
30
31
  logger = logging.getLogger(__name__)
31
32
 
@@ -99,6 +100,27 @@ class VF2PostLayout(AnalysisPass):
99
100
  is run.
100
101
  """
101
102
 
103
+ @deprecate_arg(
104
+ name="properties",
105
+ since="1.4",
106
+ package_name="Qiskit",
107
+ removal_timeline="in Qiskit 2.0",
108
+ additional_msg="The BackendProperties data structure has been deprecated and will be "
109
+ "removed in Qiskit 2.0. The `target` input argument should be used instead. "
110
+ "You can use Target.from_configuration() to build the target from the properties "
111
+ "object, but in 2.0 you will need to generate a target directly.",
112
+ )
113
+ @deprecate_arg(
114
+ name="coupling_map",
115
+ since="1.4",
116
+ package_name="Qiskit",
117
+ removal_timeline="in Qiskit 2.0",
118
+ additional_msg="This argument was only used with `properties`, which relied on "
119
+ "the deprecated BackendProperties data structure. The `target` input argument "
120
+ "should be used instead. "
121
+ "You can use Target.from_configuration() to build the target from coupling "
122
+ "map + properties, but in 2.0 you will need to generate a target directly.",
123
+ )
102
124
  def __init__(
103
125
  self,
104
126
  target=None,
@@ -20,6 +20,8 @@ that differ within a resolution provided by the user.
20
20
 
21
21
  import numpy as np
22
22
 
23
+ from qiskit.utils import deprecate_func
24
+
23
25
  from qiskit.transpiler.basepasses import TransformationPass
24
26
  from qiskit.dagcircuit import DAGCircuit
25
27
  from qiskit.circuit.library.standard_gates import RXGate, RZGate, SXGate, XGate
@@ -48,6 +50,12 @@ class NormalizeRXAngle(TransformationPass):
48
50
  Note that pulse calibration might be attached per each rotation angle.
49
51
  """
50
52
 
53
+ @deprecate_func(
54
+ since="1.4",
55
+ removal_timeline="in Qiskit 2.0",
56
+ additional_msg="This pass was used as pre-processing step of ``RXCalibrationBuilder``."
57
+ " With the removal of Pulse in Qiskit 2.0, this pass is no longer needed.",
58
+ )
51
59
  def __init__(self, target=None, resolution_in_radian=0):
52
60
  """NormalizeRXAngle initializer.
53
61
 
@@ -23,9 +23,8 @@ from qiskit._accelerate.remove_identity_equiv import remove_identity_equiv
23
23
  class RemoveIdentityEquivalent(TransformationPass):
24
24
  r"""Remove gates with negligible effects.
25
25
 
26
- Removes gates whose effect is close to an identity operation, up to the specified
27
- tolerance. Zero qubit gates such as :class:`.GlobalPhaseGate` are not considered
28
- by this pass.
26
+ Removes gates whose effect is close to an identity operation up to a global phase
27
+ and up to the specified tolerance. Parameterized gates are not considered by this pass.
29
28
 
30
29
  For a cutoff fidelity :math:`f`, this pass removes gates whose average
31
30
  gate fidelity with respect to the identity is below :math:`f`. Concretely,
@@ -11,12 +11,20 @@
11
11
  # that they have been altered from the originals.
12
12
 
13
13
  """Search for star connectivity patterns and replace them with."""
14
+ import itertools
14
15
  from typing import Iterable, Union, Optional, List, Tuple
15
16
  from math import floor, log10
16
17
 
17
18
  from qiskit.circuit import SwitchCaseOp, Clbit, ClassicalRegister, Barrier
18
19
  from qiskit.circuit.controlflow import condition_resources, node_resources
19
- from qiskit.dagcircuit import DAGOpNode, DAGDepNode, DAGDependency, DAGCircuit
20
+ from qiskit.dagcircuit import (
21
+ DAGOpNode,
22
+ DAGDepNode,
23
+ DAGDependency,
24
+ DAGCircuit,
25
+ DAGOutNode,
26
+ DAGInNode,
27
+ )
20
28
  from qiskit.transpiler.basepasses import TransformationPass
21
29
  from qiskit.transpiler.layout import Layout
22
30
  from qiskit.transpiler.passes.routing.sabre_swap import _build_sabre_dag, _apply_sabre_result
@@ -331,7 +339,14 @@ class StarPreRouting(TransformationPass):
331
339
  }
332
340
 
333
341
  def tie_breaker_key(node):
334
- return processing_order_index_map.get(node, node.sort_key)
342
+ processing_order = processing_order_index_map.get(node, None)
343
+ if processing_order is not None:
344
+ return processing_order
345
+ if isinstance(node, (DAGInNode, DAGOutNode)):
346
+ return str(node.wire)
347
+ return ",".join(
348
+ f"{dag.find_bit(q).index:04d}" for q in itertools.chain(node.qargs, node.cargs)
349
+ )
335
350
 
336
351
  rust_processing_order = _extract_nodes(dag.topological_op_nodes(key=tie_breaker_key), dag)
337
352
 
@@ -20,7 +20,7 @@ from qiskit.transpiler.passes.scheduling.scheduling.base_scheduler import BaseSc
20
20
  class ALAPScheduleAnalysis(BaseScheduler):
21
21
  """ALAP Scheduling pass, which schedules the **stop** time of instructions as late as possible.
22
22
 
23
- See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler`
23
+ See the :ref:`transpiler-scheduling-description` section in the :mod:`qiskit.transpiler`
24
24
  module documentation for the detailed behavior of the control flow
25
25
  operation, i.e. ``c_if``.
26
26
  """
@@ -20,7 +20,7 @@ from qiskit.transpiler.passes.scheduling.scheduling.base_scheduler import BaseSc
20
20
  class ASAPScheduleAnalysis(BaseScheduler):
21
21
  """ASAP Scheduling pass, which schedules the start time of instructions as early as possible.
22
22
 
23
- See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler`
23
+ See the :ref:`transpiler-scheduling-description` section in the :mod:`qiskit.transpiler`
24
24
  module documentation for the detailed behavior of the control flow
25
25
  operation, i.e. ``c_if``.
26
26
  """
@@ -73,6 +73,7 @@ from qiskit.transpiler.passes.optimization.optimize_1q_decomposition import (
73
73
  from qiskit.transpiler.passes.synthesis import plugin
74
74
  from qiskit.transpiler.target import Target
75
75
 
76
+ from qiskit.utils.deprecation import deprecate_arg
76
77
  from qiskit._accelerate.unitary_synthesis import run_default_main_loop
77
78
 
78
79
  GATE_NAME_MAP = {
@@ -315,6 +316,16 @@ def _preferred_direction(
315
316
  class UnitarySynthesis(TransformationPass):
316
317
  """Synthesize gates according to their basis gates."""
317
318
 
319
+ @deprecate_arg(
320
+ name="backend_props",
321
+ since="1.4",
322
+ package_name="Qiskit",
323
+ removal_timeline="in Qiskit 2.0",
324
+ additional_msg="The BackendProperties data structure has been deprecated and will be "
325
+ "removed in Qiskit 2.0. The `target` input argument should be used instead. "
326
+ "You can use Target.from_configuration() to build the target from the properties "
327
+ "object, but in 2.0 you will need to generate a target directly.",
328
+ )
318
329
  def __init__(
319
330
  self,
320
331
  basis_gates: list[str] = None,
@@ -18,11 +18,22 @@ import warnings
18
18
  from qiskit.transpiler.coupling import CouplingMap
19
19
  from qiskit.transpiler.instruction_durations import InstructionDurations
20
20
  from qiskit.utils.deprecate_pulse import deprecate_pulse_arg
21
+ from qiskit.utils.deprecation import deprecate_arg
21
22
 
22
23
 
23
24
  class PassManagerConfig:
24
25
  """Pass Manager Configuration."""
25
26
 
27
+ @deprecate_arg(
28
+ name="backend_properties",
29
+ since="1.4",
30
+ package_name="Qiskit",
31
+ removal_timeline="in Qiskit 2.0",
32
+ additional_msg="The BackendProperties data structure has been deprecated and will be "
33
+ "removed in Qiskit 2.0. The `target` input argument should be used instead. "
34
+ "You can use Target.from_configuration() to build the target from the properties "
35
+ "object, but in 2.0 you will need to generate a target directly.",
36
+ )
26
37
  @deprecate_pulse_arg("inst_map", predicate=lambda inst_map: inst_map is not None)
27
38
  def __init__(
28
39
  self,
@@ -32,21 +32,23 @@ part) the stages that comprise the preset pass managers
32
32
 
33
33
  .. _preset_pass_manager_generators:
34
34
 
35
- Preset Pass Manager Generation
36
- ------------------------------
35
+ Low-level preset pass manager generation
36
+ ----------------------------------------
37
37
 
38
- .. autofunction:: generate_preset_pass_manager
39
38
  .. autofunction:: level_0_pass_manager
40
39
  .. autofunction:: level_1_pass_manager
41
40
  .. autofunction:: level_2_pass_manager
42
41
  .. autofunction:: level_3_pass_manager
43
42
 
43
+ ..
44
+ `generate_preset_pass_manager` is not documented here because it's documented to be at the root
45
+ of `qiskit.transpiler`.
46
+
44
47
  .. _stage_generators:
45
48
 
46
- Stage Generator Functions
49
+ Stage generator functions
47
50
  -------------------------
48
51
 
49
- .. currentmodule:: qiskit.transpiler.preset_passmanagers.common
50
52
  .. autofunction:: generate_control_flow_options_check
51
53
  .. autofunction:: generate_error_on_control_flow
52
54
  .. autofunction:: generate_unroll_3q
@@ -55,8 +57,18 @@ Stage Generator Functions
55
57
  .. autofunction:: generate_pre_op_passmanager
56
58
  .. autofunction:: generate_translation_passmanager
57
59
  .. autofunction:: generate_scheduling
58
- .. currentmodule:: qiskit.transpiler.preset_passmanagers
59
60
  """
61
+
62
+ from .common import (
63
+ generate_control_flow_options_check,
64
+ generate_error_on_control_flow,
65
+ generate_unroll_3q,
66
+ generate_embed_passmanager,
67
+ generate_routing_passmanager,
68
+ generate_pre_op_passmanager,
69
+ generate_translation_passmanager,
70
+ generate_scheduling,
71
+ )
60
72
  from .generate_preset_pass_manager import generate_preset_pass_manager
61
73
  from .level0 import level_0_pass_manager
62
74
  from .level1 import level_1_pass_manager
@@ -70,4 +82,12 @@ __all__ = [
70
82
  "level_2_pass_manager",
71
83
  "level_3_pass_manager",
72
84
  "generate_preset_pass_manager",
85
+ "generate_control_flow_options_check",
86
+ "generate_error_on_control_flow",
87
+ "generate_unroll_3q",
88
+ "generate_embed_passmanager",
89
+ "generate_routing_passmanager",
90
+ "generate_pre_op_passmanager",
91
+ "generate_translation_passmanager",
92
+ "generate_scheduling",
73
93
  ]