diff --git a/qiskit/transpiler/passes/analysis/count_ops_longest_path.py b/qiskit/transpiler/passes/analysis/count_ops_longest_path.py index 4e06a2e6dd0a..fb3918bfed12 100644 --- a/qiskit/transpiler/passes/analysis/count_ops_longest_path.py +++ b/qiskit/transpiler/passes/analysis/count_ops_longest_path.py @@ -10,13 +10,13 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Count the operations on the longest path in a DAGcircuit.""" +"""Count the operations on the longest path in a DAGCircuit.""" from qiskit.transpiler.basepasses import AnalysisPass class CountOpsLongestPath(AnalysisPass): - """Count the operations on the longest path in a DAGcircuit. + """Count the operations on the longest path in a :class:`.DAGCircuit`. The result is saved in ``property_set['count_ops_longest_path']`` as an integer. """ diff --git a/qiskit/transpiler/passes/analysis/dag_longest_path.py b/qiskit/transpiler/passes/analysis/dag_longest_path.py index e35d86ca63ba..691910d2628f 100644 --- a/qiskit/transpiler/passes/analysis/dag_longest_path.py +++ b/qiskit/transpiler/passes/analysis/dag_longest_path.py @@ -10,13 +10,14 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Return the longest path in a DAGcircuit as a list of DAGNodes.""" +"""Return the longest path in a :class:`.DAGCircuit` as a list of DAGNodes.""" from qiskit.transpiler.basepasses import AnalysisPass class DAGLongestPath(AnalysisPass): - """Return the longest path in a DAGcircuit as a list of DAGOpNodes, DAGInNodes, and DAGOutNodes.""" + """Return the longest path in a :class:`.DAGCircuit` as a list of + :class:`.DAGOpNode`\\ s, :class:`.DAGInNode`\\ s, and :class:`.DAGOutNode`\\ s.""" def run(self, dag): """Run the DAGLongestPath pass on `dag`.""" diff --git a/qiskit/transpiler/passes/basis/unroll_3q_or_more.py b/qiskit/transpiler/passes/basis/unroll_3q_or_more.py index ed6400dce94a..36433c71d1da 100644 --- a/qiskit/transpiler/passes/basis/unroll_3q_or_more.py +++ b/qiskit/transpiler/passes/basis/unroll_3q_or_more.py @@ -27,7 +27,7 @@ def __init__(self, target=None, basis_gates=None): Args: target (Target): The target object representing the compilation - target. If specified any multiqubit instructions in the + target. If specified any multi-qubit instructions in the circuit when the pass is run that are supported by the target device will be left in place. If both this and ``basis_gates`` are specified only the target will be checked. diff --git a/qiskit/transpiler/passes/basis/unroll_custom_definitions.py b/qiskit/transpiler/passes/basis/unroll_custom_definitions.py index 20e96f127d05..12e6811a2f03 100644 --- a/qiskit/transpiler/passes/basis/unroll_custom_definitions.py +++ b/qiskit/transpiler/passes/basis/unroll_custom_definitions.py @@ -29,7 +29,7 @@ def __init__(self, equivalence_library, basis_gates=None, target=None, min_qubit equivalence_library (EquivalenceLibrary): The equivalence library which will be used by the BasisTranslator pass. (Instructions in this library will not be unrolled by this pass.) - basis_gates (Optional[list[str]]): Target basis names to unroll to, e.g. `['u3', 'cx']`. + basis_gates (Optional[list[str]]): Target basis names to unroll to, e.g. ``['u3', 'cx']``. Ignored if ``target`` is also specified. target (Optional[Target]): The :class:`~.Target` object corresponding to the compilation target. When specified, any argument specified for ``basis_gates`` is ignored. diff --git a/qiskit/transpiler/passes/calibration/pulse_gate.py b/qiskit/transpiler/passes/calibration/pulse_gate.py index 9bfd3c544779..eacabbe89057 100644 --- a/qiskit/transpiler/passes/calibration/pulse_gate.py +++ b/qiskit/transpiler/passes/calibration/pulse_gate.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Instruction scheduel map reference pass.""" +"""Instruction schedule map reference pass.""" from typing import List, Union @@ -57,7 +57,7 @@ def __init__( Args: inst_map: Instruction schedule map that user may override. target: The :class:`~.Target` representing the target backend, if both - ``inst_map`` and this are specified then it updates instructions + ``inst_map`` and ``target`` are specified then it updates instructions in the ``target`` with ``inst_map``. """ super().__init__() diff --git a/qiskit/transpiler/passes/layout/apply_layout.py b/qiskit/transpiler/passes/layout/apply_layout.py index b6b7282e304e..8c6ed2cfec3a 100644 --- a/qiskit/transpiler/passes/layout/apply_layout.py +++ b/qiskit/transpiler/passes/layout/apply_layout.py @@ -36,7 +36,7 @@ class ApplyLayout(TransformationPass): """ def run(self, dag): - """Run the ApplyLayout pass on `dag`. + """Run the ApplyLayout pass on ``dag``. Args: dag (DAGCircuit): DAG to map. @@ -45,7 +45,7 @@ def run(self, dag): DAGCircuit: A mapped DAG (with physical qubits). Raises: - TranspilerError: if no layout is found in `property_set` or no full physical qubits. + TranspilerError: if no layout is found in ``property_set`` or no full physical qubits. """ layout = self.property_set["layout"] if not layout: @@ -77,7 +77,7 @@ def run(self, dag): new_dag.apply_operation_back(node.op, qargs, node.cargs, check=False) else: # First build a new layout object going from: - # old virtual -> old phsyical -> new virtual -> new physical + # old virtual -> old physical -> new virtual -> new physical # to: # old virtual -> new physical full_layout = Layout() diff --git a/qiskit/transpiler/passes/layout/dense_layout.py b/qiskit/transpiler/passes/layout/dense_layout.py index 973947420680..71c69739990d 100644 --- a/qiskit/transpiler/passes/layout/dense_layout.py +++ b/qiskit/transpiler/passes/layout/dense_layout.py @@ -31,9 +31,9 @@ class DenseLayout(AnalysisPass): of the circuit (Qubit). Note: - Even though a 'layout' is not strictly a property of the DAG, + Even though a ``'layout'`` is not strictly a property of the DAG, in the transpiler architecture it is best passed around between passes - by being set in `property_set`. + by being set in ``property_set``. """ def __init__(self, coupling_map=None, backend_prop=None, target=None): diff --git a/qiskit/transpiler/passes/layout/enlarge_with_ancilla.py b/qiskit/transpiler/passes/layout/enlarge_with_ancilla.py index 025f846b054b..fb0b24016f66 100644 --- a/qiskit/transpiler/passes/layout/enlarge_with_ancilla.py +++ b/qiskit/transpiler/passes/layout/enlarge_with_ancilla.py @@ -34,7 +34,7 @@ def run(self, dag): DAGCircuit: An extended DAG. Raises: - TranspilerError: If there is not layout in the property set or not set at init time. + TranspilerError: If there is no layout in the property set or not set at init time. """ layout = self.property_set["layout"] diff --git a/qiskit/transpiler/passes/layout/full_ancilla_allocation.py b/qiskit/transpiler/passes/layout/full_ancilla_allocation.py index 81ae7922806e..72d2c6f2c4d0 100644 --- a/qiskit/transpiler/passes/layout/full_ancilla_allocation.py +++ b/qiskit/transpiler/passes/layout/full_ancilla_allocation.py @@ -107,7 +107,7 @@ def run(self, dag): @staticmethod def validate_layout(layout_qubits, dag_qubits): """ - Checks if all the qregs in layout_qregs already exist in dag_qregs. Otherwise, raise. + Checks if all the qregs in ``layout_qregs`` already exist in ``dag_qregs``. Otherwise, raise. """ for qreg in layout_qubits: if qreg not in dag_qubits: diff --git a/qiskit/transpiler/passes/layout/layout_2q_distance.py b/qiskit/transpiler/passes/layout/layout_2q_distance.py index 6af709851702..fa1759a845f0 100644 --- a/qiskit/transpiler/passes/layout/layout_2q_distance.py +++ b/qiskit/transpiler/passes/layout/layout_2q_distance.py @@ -25,7 +25,7 @@ class Layout2qDistance(AnalysisPass): """Evaluate how good the layout selection was. - Saves in `property_set['layout_score']` (or the property name in property_name) + Saves in ``property_set['layout_score']`` (or the property name in property_name) the sum of distances for each circuit CX. The lower the number, the better the selection. Therefore, 0 is a perfect layout selection. No CX direction is considered. diff --git a/qiskit/transpiler/passes/layout/sabre_layout.py b/qiskit/transpiler/passes/layout/sabre_layout.py index 0d70650e0eda..ca71ebee2777 100644 --- a/qiskit/transpiler/passes/layout/sabre_layout.py +++ b/qiskit/transpiler/passes/layout/sabre_layout.py @@ -60,7 +60,7 @@ class SabreLayout(TransformationPass): This method exploits the reversibility of quantum circuits, and tries to include global circuit information in the choice of initial_layout. - By default this pass will run both layout and routing and will transform the + By default, this pass will run both layout and routing and will transform the circuit so that the layout is applied to the input dag (meaning that the output circuit will have ancilla qubits allocated for unused qubits on the coupling map and the qubits will be reordered to match the mapped physical qubits) and then @@ -152,7 +152,7 @@ def __init__( will be raised if both are used. skip_routing (bool): If this is set ``True`` and ``routing_pass`` is not used then routing will not be applied to the output circuit. Only the layout - will be returned in the property set. This is a tradeoff to run custom + will be set in the property set. This is a tradeoff to run custom routing with multiple layout trials, as using this option will cause SabreLayout to run the routing stage internally but not use that result. @@ -440,7 +440,7 @@ def _compose_layouts(self, initial_layout, pass_final_layout, qregs): The routing passes internally start with a trivial layout, as the layout gets applied to the circuit prior to running them. So the - "final_layout" they report must be amended to account for the actual + ``"final_layout"`` they report must be amended to account for the actual initial_layout that was selected. """ trivial_layout = Layout.generate_trivial_layout(*qregs) diff --git a/qiskit/transpiler/passes/layout/vf2_layout.py b/qiskit/transpiler/passes/layout/vf2_layout.py index 5fd6e08ab2fb..4e3077eb1d4d 100644 --- a/qiskit/transpiler/passes/layout/vf2_layout.py +++ b/qiskit/transpiler/passes/layout/vf2_layout.py @@ -37,7 +37,7 @@ class VF2LayoutStopReason(Enum): class VF2Layout(AnalysisPass): - """A pass for choosing a Layout of a circuit onto a Coupling graph, as a + """A pass for choosing a Layout of a circuit onto a Coupling graph, as a subgraph isomorphism problem, solved by VF2++. If a solution is found that means there is a "perfect layout" and that no @@ -52,7 +52,7 @@ class VF2Layout(AnalysisPass): * ``"nonexistent solution"``: If no perfect layout was found. * ``">2q gates in basis"``: If VF2Layout can't work with basis - By default this pass will construct a heuristic scoring map based on the + By default, this pass will construct a heuristic scoring map based on the error rates in the provided ``target`` (or ``properties`` if ``target`` is not provided). However, analysis passes can be run prior to this pass and set ``vf2_avg_error_map`` in the property set with a :class:`~.ErrorMap` diff --git a/qiskit/transpiler/passes/layout/vf2_post_layout.py b/qiskit/transpiler/passes/layout/vf2_post_layout.py index 28d9c397fa34..1acb8a3b90fc 100644 --- a/qiskit/transpiler/passes/layout/vf2_post_layout.py +++ b/qiskit/transpiler/passes/layout/vf2_post_layout.py @@ -40,7 +40,7 @@ class VF2PostLayoutStopReason(Enum): def _target_match(node_a, node_b): # Node A is the set of operations in the target. Node B is the count dict - # of oeprations on the node or edge in the circuit. + # of operations on the node or edge in the circuit. if isinstance(node_a, set): return node_a.issuperset(node_b.keys()) # Node A is the count dict of operations on the node or edge in the circuit @@ -75,7 +75,7 @@ class VF2PostLayout(AnalysisPass): * ``"nonexistent solution"``: If no solution was found. * ``">2q gates in basis"``: If VF2PostLayout can't work with basis - By default this pass will construct a heuristic scoring map based on the + By default, this pass will construct a heuristic scoring map based on the error rates in the provided ``target`` (or ``properties`` if ``target`` is not provided). However, analysis passes can be run prior to this pass and set ``vf2_avg_error_map`` in the property set with a :class:`~.ErrorMap` @@ -180,7 +180,7 @@ def run(self, dag): else: cm_graph = PyGraph(multigraph=False) # If None is present in qargs there are globally defined ideal operations - # we should add these to all entries based on the number of qubits so we + # we should add these to all entries based on the number of qubits, so we # treat that as a valid operation even if there is no scoring for the # strict direction case global_ops = None diff --git a/qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py b/qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py index b3e3f27b89ef..51b39d7e961b 100644 --- a/qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +++ b/qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py @@ -19,11 +19,11 @@ class CollectMultiQBlocks(AnalysisPass): """Collect sequences of uninterrupted gates acting on groups of qubits. - max_block_size specifies the maximum number of qubits that can be acted upon + ``max_block_size`` specifies the maximum number of qubits that can be acted upon by any single group of gates Traverse the DAG and find blocks of gates that act consecutively on - groups of qubits. Write the blocks to propert_set as a list of blocks + groups of qubits. Write the blocks to ``property_set`` as a list of blocks of the form:: [[g0, g1, g2], [g4, g5]] @@ -31,7 +31,7 @@ class CollectMultiQBlocks(AnalysisPass): Blocks are reported in a valid topological order. Further, the gates within each block are also reported in topological order Some gates may not be present in any block (e.g. if the number - of operands is greater than max_block_size) + of operands is greater than ``max_block_size``) A Disjoint Set Union data structure (DSU) is used to maintain blocks as gates are processed. This data structure points each qubit to a set at all diff --git a/qiskit/transpiler/passes/optimization/commutation_analysis.py b/qiskit/transpiler/passes/optimization/commutation_analysis.py index 0963a645c7b3..8c34c911a6ca 100644 --- a/qiskit/transpiler/passes/optimization/commutation_analysis.py +++ b/qiskit/transpiler/passes/optimization/commutation_analysis.py @@ -22,7 +22,7 @@ class CommutationAnalysis(AnalysisPass): """Analysis pass to find commutation relations between DAG nodes. - Property_set['commutation_set'] is a dictionary that describes + ``property_set['commutation_set']`` is a dictionary that describes the commutation relations on a given wire, all the gates on a wire are grouped into a set of gates that commute. """ @@ -35,7 +35,7 @@ def run(self, dag): """Run the CommutationAnalysis pass on `dag`. Run the pass on the DAG, and write the discovered commutation relations - into the property_set. + into the ``property_set``. """ # Initiate the commutation set self.property_set["commutation_set"] = defaultdict(list) diff --git a/qiskit/transpiler/passes/optimization/commutative_cancellation.py b/qiskit/transpiler/passes/optimization/commutative_cancellation.py index 777c4ff3dc48..b0eb6bd24137 100644 --- a/qiskit/transpiler/passes/optimization/commutative_cancellation.py +++ b/qiskit/transpiler/passes/optimization/commutative_cancellation.py @@ -50,7 +50,7 @@ def __init__(self, basis_gates=None, target=None): the set intersection between the ``basis_gates`` parameter and the gates in the dag. target (Target): The :class:`~.Target` representing the target backend, if both - ``basis_gates`` and this are specified then this argument will take + ``basis_gates`` and ``target`` are specified then this argument will take precedence and ``basis_gates`` will be ignored. """ super().__init__() diff --git a/qiskit/transpiler/passes/optimization/consolidate_blocks.py b/qiskit/transpiler/passes/optimization/consolidate_blocks.py index 6f973ee3fd6f..71065113bb5a 100644 --- a/qiskit/transpiler/passes/optimization/consolidate_blocks.py +++ b/qiskit/transpiler/passes/optimization/consolidate_blocks.py @@ -55,15 +55,15 @@ def __init__( ): """ConsolidateBlocks initializer. - If `kak_basis_gate` is not `None` it will be used as the basis gate for KAK decomposition. - Otherwise, if `basis_gates` is not `None` a basis gate will be chosen from this list. - Otherwise the basis gate will be `CXGate`. + If ``kak_basis_gate`` is not ``None`` it will be used as the basis gate for KAK decomposition. + Otherwise, if ``basis_gates`` is not ``None`` a basis gate will be chosen from this list. + Otherwise, the basis gate will be :class:`.CXGate`. Args: kak_basis_gate (Gate): Basis gate for KAK decomposition. force_consolidate (bool): Force block consolidation. basis_gates (List(str)): Basis gates from which to choose a KAK gate. - approximation_degree (float): a float between [0.0, 1.0]. Lower approximates more. + approximation_degree (float): a float between $[0.0, 1.0]$. Lower approximates more. target (Target): The target object for the compilation target backend. """ super().__init__() diff --git a/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py b/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py index 387bdc3ba4e0..cfde23061020 100644 --- a/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py +++ b/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py @@ -23,8 +23,8 @@ with simultaneous two-qubit and one-qubit gates. The method ignores crosstalk between pairs of single qubit gates. -The method assumes that all qubits get measured simultaneously whether or not -they need a measurement. This assumption is based on current device properties +The method assumes that all qubits get measured simultaneously, whether +they need a measurement or not. This assumption is based on current device properties and may need to be revised for future device generations. """ @@ -89,7 +89,7 @@ def __init__( inserts the measure gates. If CrosstalkAdaptiveSchedule is made aware of those measurements, it is included in the optimization. target (Target): A target representing the target backend, if both - ``backend_prop`` and this are specified then this argument will take + ``backend_prop`` and ``target`` are specified then this argument will take precedence and ``coupling_map`` will be ignored. Raises: ImportError: if unable to import z3 solver diff --git a/qiskit/transpiler/passes/optimization/cx_cancellation.py b/qiskit/transpiler/passes/optimization/cx_cancellation.py index 6dd4a5364552..df1ffc8ebe23 100644 --- a/qiskit/transpiler/passes/optimization/cx_cancellation.py +++ b/qiskit/transpiler/passes/optimization/cx_cancellation.py @@ -10,14 +10,14 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Cancel back-to-back `cx` gates in dag.""" +"""Cancel back-to-back ``cx`` gates in dag.""" from qiskit.transpiler.basepasses import TransformationPass from qiskit.transpiler.passes.utils import control_flow class CXCancellation(TransformationPass): - """Cancel back-to-back `cx` gates in dag.""" + """Cancel back-to-back ``cx`` gates in dag.""" @control_flow.trivial_recurse def run(self, dag): diff --git a/qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py b/qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py index 5f4be27d220e..9352ce08f365 100644 --- a/qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +++ b/qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py @@ -41,7 +41,7 @@ def __init__(self, instruction_schedule_map=None, target=None): instruction_schedule_map (InstructionScheduleMap): the mapping from circuit :class:`~.circuit.Instruction` names and arguments to :class:`.Schedule`\\ s. target (Target): The :class:`~.Target` representing the target backend, if both - ``instruction_schedule_map`` and this are specified then this argument will take + ``instruction_schedule_map`` and ``target`` are specified then this argument will take precedence and ``instruction_schedule_map`` will be ignored. """ super().__init__() diff --git a/qiskit/transpiler/passes/optimization/normalize_rx_angle.py b/qiskit/transpiler/passes/optimization/normalize_rx_angle.py index ad39cbc229c5..4d5b711eadb7 100644 --- a/qiskit/transpiler/passes/optimization/normalize_rx_angle.py +++ b/qiskit/transpiler/passes/optimization/normalize_rx_angle.py @@ -57,7 +57,7 @@ def __init__(self, target=None, resolution_in_radian=0): corresponding RX gates with SX and X gates. resolution_in_radian (float): Resolution for RX rotation angle quantization. If set to zero, this pass won't modify the rotation angles in the given DAG. - (=Provides aribitary-angle RX) + (=Provides arbitrary-angle RX) """ super().__init__() self.target = target diff --git a/qiskit/transpiler/passes/optimization/optimize_1q_commutation.py b/qiskit/transpiler/passes/optimization/optimize_1q_commutation.py index fea459b41b9e..450490734e46 100644 --- a/qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +++ b/qiskit/transpiler/passes/optimization/optimize_1q_commutation.py @@ -46,10 +46,10 @@ class Optimize1qGatesSimpleCommutation(TransformationPass): """ - Optimizes 1Q gate strings interrupted by 2Q gates by commuting the components and re- - synthesizing the results. The commutation rules are stored in `commutation_table`. + Optimizes 1Q gate strings interrupted by 2Q gates by commuting the components and + resynthesizing the results. The commutation rules are stored in ``commutation_table``. - NOTE: In addition to those mentioned in `commutation_table`, this pass has some limitations: + NOTE: In addition to those mentioned in ``commutation_table``, this pass has some limitations: + Does not handle multiple commutations in a row without intermediate progress. + Can only commute into positions where there are pre-existing runs. + Does not exhaustively test all the different ways commuting gates can be assigned to @@ -58,7 +58,7 @@ class Optimize1qGatesSimpleCommutation(TransformationPass): barriers.) """ - # NOTE: A run from `dag.collect_1q_runs` is always nonempty, so we sometimes use an empty list + # NOTE: A run from dag.collect_1q_runs is always nonempty, so we sometimes use an empty list # to signify the absence of a run. def __init__(self, basis=None, run_to_completion=False, target=None): @@ -83,7 +83,7 @@ def _find_adjoining_run(dag, runs, run, front=True): Finds the run which abuts `run` from the front (or the rear if `front == False`), separated by a blocking node. - Returns a pair of the abutting multi-qubit gate and the run which it separates from this + Returns a pair of the abutting multiqubit gate and the run which it separates from this one. The next run can be the empty list `[]` if it is absent. """ edge_node = run[0] if front else run[-1] diff --git a/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py b/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py index 854fe8204551..f96ed999061d 100644 --- a/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +++ b/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py @@ -59,9 +59,9 @@ class Optimize1qGatesDecomposition(TransformationPass): """Optimize chains of single-qubit gates by combining them into a single gate. - The decision to replace the original chain with a new resynthesis depends on: + The decision to replace the original chain with a new re-synthesis depends on: - whether the original chain was out of basis: replace - - whether the original chain was in basis but resynthesis is lower error: replace + - whether the original chain was in basis but re-synthesis is lower error: replace - whether the original chain contains a pulse gate: do not replace - whether the original chain amounts to identity: replace with null @@ -110,12 +110,12 @@ def _build_error_map(self): def _resynthesize_run(self, matrix, qubit=None): """ - Resynthesizes one 2x2 `matrix`, typically extracted via `dag.collect_1q_runs`. + Re-synthesizes one 2x2 `matrix`, typically extracted via `dag.collect_1q_runs`. Returns the newly synthesized circuit in the indicated basis, or None if no synthesis routine applied. - When multiple synthesis options are available, it prefers the one with lowest + When multiple synthesis options are available, it prefers the one with the lowest error when the circuit is applied to `qubit`. """ if self._target: diff --git a/qiskit/transpiler/passes/optimization/optimize_1q_gates.py b/qiskit/transpiler/passes/optimization/optimize_1q_gates.py index 1dd03a738e32..3d080219274b 100644 --- a/qiskit/transpiler/passes/optimization/optimize_1q_gates.py +++ b/qiskit/transpiler/passes/optimization/optimize_1q_gates.py @@ -43,7 +43,7 @@ def __init__(self, basis=None, eps=1e-15, target=None): the set `{'u1','u2','u3', 'u', 'p'}`. eps (float): EPS to check against target (Target): The :class:`~.Target` representing the target backend, if both - ``basis`` and this are specified then this argument will take + ``basis`` and ``target`` are specified then this argument will take precedence and ``basis`` will be ignored. """ super().__init__() @@ -61,7 +61,7 @@ def run(self, dag): DAGCircuit: the optimized DAG. Raises: - TranspilerError: if YZY and ZYZ angles do not give same rotation matrix. + TranspilerError: if ``YZY`` and ``ZYZ`` angles do not give same rotation matrix. """ use_u = "u" in self.basis use_p = "p" in self.basis diff --git a/qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py b/qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py index d49485784026..faf0ed8de6b0 100644 --- a/qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +++ b/qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py @@ -26,7 +26,7 @@ class ResetAfterMeasureSimplification(TransformationPass): This optimization is suitable for use on IBM Quantum systems where the reset operation is performed by a measurement followed by a conditional - x-gate. It might not be desireable on other backends if reset is implemented + x-gate. It might not be desirable on other backends if reset is implemented differently. """ diff --git a/qiskit/transpiler/passes/optimization/template_optimization.py b/qiskit/transpiler/passes/optimization/template_optimization.py index 0aeea99ab3c6..f4274d2331ec 100644 --- a/qiskit/transpiler/passes/optimization/template_optimization.py +++ b/qiskit/transpiler/passes/optimization/template_optimization.py @@ -57,16 +57,16 @@ def __init__( heuristics_backward_param (list[int]): [length, survivor] Those are the parameters for applying heuristics on the backward part of the algorithm. This part of the algorithm creates a tree of matching scenario. This tree grows exponentially. The - heuristics evaluates which scenarios have the longest match and keep only those. + heuristics evaluate which scenarios have the longest match and keep only those. The length is the interval in the tree for cutting it and survivor is the number - of scenarios that are kept. We advice to use l=3 and s=1 to have serious time + of scenarios that are kept. We advise to use l=3 and s=1 to have serious time advantage. We remind that the heuristics implies losing a part of the maximal matches. Check reference for more details. heuristics_qubits_param (list[int]): [length] The heuristics for the qubit choice make guesses from the dag dependency of the circuit in order to limit the number of qubit configurations to explore. The length is the number of successors or not predecessors that will be explored in the dag dependency of the circuit, each - qubits of the nodes are added to the set of authorized qubits. We advice to use + qubits of the nodes are added to the set of authorized qubits. We advise to use length=1. Check reference for more details. user_cost_dict (Dict[str, int]): quantum cost dictionary passed to TemplateSubstitution to configure its behavior. This will override any default values if None diff --git a/qiskit/transpiler/passes/routing/basic_swap.py b/qiskit/transpiler/passes/routing/basic_swap.py index af721ee51c7d..c73b2fb009c6 100644 --- a/qiskit/transpiler/passes/routing/basic_swap.py +++ b/qiskit/transpiler/passes/routing/basic_swap.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Map (with minimum effort) a DAGCircuit onto a `coupling_map` adding swap gates.""" +"""Map (with minimum effort) a DAGCircuit onto a ``coupling_map`` adding swap gates.""" from qiskit.transpiler.basepasses import TransformationPass from qiskit.transpiler.exceptions import TranspilerError @@ -22,7 +22,7 @@ class BasicSwap(TransformationPass): - """Map (with minimum effort) a DAGCircuit onto a `coupling_map` adding swap gates. + """Map (with minimum effort) a DAGCircuit onto a ``coupling_map`` adding swap gates. The basic mapper is a minimum effort to insert swap gates to map the DAG onto a coupling map. When a cx is not in the coupling map possibilities, it inserts @@ -34,7 +34,7 @@ def __init__(self, coupling_map, fake_run=False): Args: coupling_map (Union[CouplingMap, Target]): Directed graph represented a coupling map. - fake_run (bool): if true, it only pretend to do routing, i.e., no + fake_run (bool): if true, it will only pretend to do routing, i.e., no swap is effectively added. """ super().__init__() @@ -57,7 +57,7 @@ def run(self, dag): Raises: TranspilerError: if the coupling map or the layout are not - compatible with the DAG, or if the coupling_map=None. + compatible with the DAG, or if the ``coupling_map=None``. """ if self.fake_run: return self._fake_run(dag) diff --git a/qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py b/qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py index 60b5cf9e3ad3..65d39abf1ab7 100644 --- a/qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +++ b/qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py @@ -33,7 +33,7 @@ class Commuting2qGateRouter(TransformationPass): The mapping to the coupling map is done using swap strategies, see :class:`.SwapStrategy`. The swap strategy should suit the problem and the coupling map. This transpiler pass should ideally be executed before the quantum circuit is enlarged with any idle ancilla - qubits. Otherwise we may swap qubits outside of the portion of the chip we want to use. + qubits. Otherwise, we may swap qubits outside the portion of the chip we want to use. Therefore, the swap strategy and its associated coupling map do not represent physical qubits. Instead, they represent an intermediate mapping that corresponds to the physical qubits once the initial layout is applied. The example below shows how to map a four @@ -111,7 +111,7 @@ def __init__( Args: swap_strategy: An instance of a :class:`.SwapStrategy` that holds the swap layers that are used, and the order in which to apply them, to map the instruction to - the hardware. If this field is not given if should be contained in the + the hardware. If this field is not given, it should be contained in the property set of the pass. This allows other passes to determine the most appropriate swap strategy at run-time. edge_coloring: An optional edge coloring of the coupling map (I.e. no two edges that diff --git a/qiskit/transpiler/passes/routing/layout_transformation.py b/qiskit/transpiler/passes/routing/layout_transformation.py index 218e6ca958d3..42bf44e13f2a 100644 --- a/qiskit/transpiler/passes/routing/layout_transformation.py +++ b/qiskit/transpiler/passes/routing/layout_transformation.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Map (with minimum effort) a DAGCircuit onto a `coupling_map` adding swap gates.""" +"""Map (with minimum effort) a DAGCircuit onto a ``coupling_map`` adding swap gates.""" from __future__ import annotations import numpy as np @@ -49,7 +49,7 @@ def __init__( to_layout (Union[Layout, str]): The final layout of qubits on physical qubits. - If the type is str, look up `property_set` when this pass runs. + If the type is str, look up ``property_set`` when this pass runs. seed (Union[int, np.random.default_rng]): Seed to use for random trials. diff --git a/qiskit/transpiler/passes/routing/lookahead_swap.py b/qiskit/transpiler/passes/routing/lookahead_swap.py index 0893736a2aca..a961162ab802 100644 --- a/qiskit/transpiler/passes/routing/lookahead_swap.py +++ b/qiskit/transpiler/passes/routing/lookahead_swap.py @@ -90,7 +90,7 @@ def __init__(self, coupling_map, search_depth=4, search_width=4, fake_run=False) coupling_map (Union[CouplingMap, Target]): CouplingMap of the target backend. search_depth (int): lookahead tree depth when ranking best SWAP options. search_width (int): lookahead tree width when ranking best SWAP options. - fake_run (bool): if true, it only pretend to do routing, i.e., no + fake_run (bool): if true, it will only pretend to do routing, i.e., no swap is effectively added. """ diff --git a/qiskit/transpiler/passes/routing/stochastic_swap.py b/qiskit/transpiler/passes/routing/stochastic_swap.py index 90001bb06cc8..52f0d569931d 100644 --- a/qiskit/transpiler/passes/routing/stochastic_swap.py +++ b/qiskit/transpiler/passes/routing/stochastic_swap.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Map a DAGCircuit onto a `coupling_map` adding swap gates.""" +"""Map a DAGCircuit onto a ``coupling_map`` adding swap gates.""" import itertools import logging @@ -72,7 +72,7 @@ def __init__(self, coupling_map, trials=20, seed=None, fake_run=False, initial_l map. trials (int): maximum number of iterations to attempt seed (int): seed for random number generator - fake_run (bool): if true, it only pretend to do routing, i.e., no + fake_run (bool): if true, it will only pretend to do routing, i.e., no swap is effectively added. initial_layout (Layout): starting layout at beginning of pass. """ diff --git a/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py b/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py index 2d4114f3cfc7..d1687ab05273 100644 --- a/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +++ b/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py @@ -42,7 +42,7 @@ class PadDynamicalDecoupling(BasePadding): so do not alter the logical action of the circuit, but have the effect of mitigating decoherence in those idle periods. - As a special case, the pass allows a length-1 sequence (e.g. [XGate()]). + As a special case, the pass allows a length-1 sequence (e.g. ``[XGate()]``). In this case the DD insertion happens only when the gate inverse can be absorbed into a neighboring gate in the circuit (so we would still be replacing Delay with something that is equivalent to the identity). diff --git a/qiskit/transpiler/passes/scheduling/padding/pad_delay.py b/qiskit/transpiler/passes/scheduling/padding/pad_delay.py index f1517900874f..886bb6a37974 100644 --- a/qiskit/transpiler/passes/scheduling/padding/pad_delay.py +++ b/qiskit/transpiler/passes/scheduling/padding/pad_delay.py @@ -57,7 +57,7 @@ def __init__(self, fill_very_end: bool = True, target: Target = None): Args: fill_very_end: Set ``True`` to fill the end of circuit with delay. target: The :class:`~.Target` representing the target backend. - If it supplied and it does not support delay instruction on a qubit, + If it is supplied and does not support delay instruction on a qubit, padding passes do not pad any idle time of the qubit. """ super().__init__(target=target) diff --git a/qiskit/transpiler/passes/scheduling/scheduling/asap.py b/qiskit/transpiler/passes/scheduling/scheduling/asap.py index ce0e1d1948a0..fa07ae0c5f61 100644 --- a/qiskit/transpiler/passes/scheduling/scheduling/asap.py +++ b/qiskit/transpiler/passes/scheduling/scheduling/asap.py @@ -18,7 +18,7 @@ class ASAPScheduleAnalysis(BaseScheduler): - """ASAP Scheduling pass, which schedules the start time of instructions as early as possible.. + """ASAP Scheduling pass, which schedules the start time of instructions as early as possible. See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler` module documentation for the detailed behavior of the control flow diff --git a/qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py b/qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py index 1116123cfa51..3b0ed1692f07 100644 --- a/qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +++ b/qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py @@ -19,7 +19,7 @@ class SetIOLatency(AnalysisPass): """Set IOLatency information to the input circuit. The ``clbit_write_latency`` and ``conditional_latency`` are added to - the property set of pass manager. These information can be shared among the passes + the property set of pass manager. This information can be shared among the passes that perform scheduling on instructions acting on classical registers. Once these latencies are added to the property set, this information diff --git a/qiskit/transpiler/passes/scheduling/time_unit_conversion.py b/qiskit/transpiler/passes/scheduling/time_unit_conversion.py index c75e22f285b8..d53c3fc4ef6a 100644 --- a/qiskit/transpiler/passes/scheduling/time_unit_conversion.py +++ b/qiskit/transpiler/passes/scheduling/time_unit_conversion.py @@ -25,15 +25,15 @@ class TimeUnitConversion(TransformationPass): """Choose a time unit to be used in the following time-aware passes, and make all circuit time units consistent with that. - This pass will add a .duration metadata to each op whose duration is known, + This pass will add a :attr:`.Instruction.duration` metadata to each op whose duration is known which will be used by subsequent scheduling passes for scheduling. - If dt (dt in seconds) is known to transpiler, the unit 'dt' is chosen. Otherwise, + If ``dt`` (in seconds) is known to transpiler, the unit ``'dt'`` is chosen. Otherwise, the unit to be selected depends on what units are used in delays and instruction durations: - * 's': if they are all in SI units. - * 'dt': if they are all in the unit 'dt'. - * raise error: if they are a mix of SI units and 'dt'. + * ``'s'``: if they are all in SI units. + * ``'dt'``: if they are all in the unit ``'dt'``. + * raise error: if they are a mix of SI units and ``'dt'``. """ def __init__(self, inst_durations: InstructionDurations = None, target: Target = None): @@ -42,7 +42,7 @@ def __init__(self, inst_durations: InstructionDurations = None, target: Target = Args: inst_durations (InstructionDurations): A dictionary of durations of instructions. target: The :class:`~.Target` representing the target backend, if both - ``inst_durations`` and this are specified then this argument will take + ``inst_durations`` and ``target`` are specified then this argument will take precedence and ``inst_durations`` will be ignored. diff --git a/qiskit/transpiler/passes/utils/check_map.py b/qiskit/transpiler/passes/utils/check_map.py index d56a709253c9..61ddc71d131e 100644 --- a/qiskit/transpiler/passes/utils/check_map.py +++ b/qiskit/transpiler/passes/utils/check_map.py @@ -21,7 +21,7 @@ class CheckMap(AnalysisPass): """Check if a DAG circuit is already mapped to a coupling map. - Check if a DAGCircuit is mapped to `coupling_map` by checking that all + Check if a DAGCircuit is mapped to ``coupling_map`` by checking that all 2-qubit interactions are laid out to be on adjacent qubits in the global coupling map of the device, setting the property set field (either specified with ``property_set_field`` or the default ``is_swap_mapped``) to ``True`` or ``False`` accordingly. Note this does not diff --git a/qiskit/transpiler/passes/utils/dag_fixed_point.py b/qiskit/transpiler/passes/utils/dag_fixed_point.py index 2f9f486545b5..60da251b3099 100644 --- a/qiskit/transpiler/passes/utils/dag_fixed_point.py +++ b/qiskit/transpiler/passes/utils/dag_fixed_point.py @@ -21,7 +21,7 @@ class DAGFixedPoint(AnalysisPass): """Check if the DAG has reached a fixed point. A dummy analysis pass that checks if the DAG a fixed point (the DAG is not - modified anymore). The results is saved in + modified anymore). The result is saved in ``property_set['dag_fixed_point']`` as a boolean. """ diff --git a/qiskit/transpiler/passes/utils/error.py b/qiskit/transpiler/passes/utils/error.py index 445b1d21d565..f2659ec052ff 100644 --- a/qiskit/transpiler/passes/utils/error.py +++ b/qiskit/transpiler/passes/utils/error.py @@ -31,9 +31,9 @@ def __init__(self, msg=None, action="raise"): will be used. This can be either a raw string, or a callback function that accepts the current ``property_set`` and returns the desired message. action (str): the action to perform. Default: 'raise'. The options are: - * 'raise': Raises a `TranspilerError` exception with msg - * 'warn': Raises a non-fatal warning with msg - * 'log': logs in `logging.getLogger(__name__)` + * ``'raise'``: Raises a ``TranspilerError`` exception with msg + * ``'warn'``: Raises a non-fatal warning with msg + * ``'log'``: logs in ``logging.getLogger(__name__)`` Raises: TranspilerError: if action is not valid. diff --git a/qiskit/transpiler/passes/utils/fixed_point.py b/qiskit/transpiler/passes/utils/fixed_point.py index 34fa1faabe3b..fbef9d0a85ef 100644 --- a/qiskit/transpiler/passes/utils/fixed_point.py +++ b/qiskit/transpiler/passes/utils/fixed_point.py @@ -21,7 +21,7 @@ class FixedPoint(AnalysisPass): """Check if a property reached a fixed point. A dummy analysis pass that checks if a property reached a fixed point. - The results is saved in ``property_set['_fixed_point']`` + The result is saved in ``property_set['_fixed_point']`` as a boolean. """ diff --git a/qiskit/transpiler/passes/utils/minimum_point.py b/qiskit/transpiler/passes/utils/minimum_point.py index 8ccfa4a7f951..1dcef0db2181 100644 --- a/qiskit/transpiler/passes/utils/minimum_point.py +++ b/qiskit/transpiler/passes/utils/minimum_point.py @@ -44,7 +44,7 @@ class MinimumPoint(TransformationPass): Fields used by this pass in the property set are (all relative to the ``prefix`` argument): - * ``{prefix}_minimum_point_state`` - Used to track the state of the minimpoint search + * ``{prefix}_minimum_point_state`` - Used to track the state of the minimum point search * ``{prefix}_minimum_point`` - This value gets set to ``True`` when either a fixed point is reached over the ``backtrack_depth`` executions, or ``backtrack_depth`` was exceeded and an earlier minimum is restored. diff --git a/qiskit/transpiler/passes/utils/remove_final_measurements.py b/qiskit/transpiler/passes/utils/remove_final_measurements.py index 3c60adeabbba..c3179e204cd4 100644 --- a/qiskit/transpiler/passes/utils/remove_final_measurements.py +++ b/qiskit/transpiler/passes/utils/remove_final_measurements.py @@ -26,7 +26,7 @@ class RemoveFinalMeasurements(TransformationPass): Classical registers are removed iff they reference at least one bit that has become unused by the circuit as a result of the operation, and all - of their other bits are also unused. Seperately, classical bits are removed + of their other bits are also unused. Separately, classical bits are removed iff they have become unused by the circuit as a result of the operation, or they appear in a removed classical register, but do not appear in a classical register that will remain. diff --git a/qiskit/transpiler/passes/utils/unroll_forloops.py b/qiskit/transpiler/passes/utils/unroll_forloops.py index 8cde3874adcb..b8ebe853f1e0 100644 --- a/qiskit/transpiler/passes/utils/unroll_forloops.py +++ b/qiskit/transpiler/passes/utils/unroll_forloops.py @@ -22,8 +22,8 @@ class UnrollForLoops(TransformationPass): """``UnrollForLoops`` transpilation pass unrolls for-loops when possible.""" def __init__(self, max_target_depth=-1): - """Things like `for x in {0, 3, 4} {rx(x) qr[1];}` will turn into - `rx(0) qr[1]; rx(3) qr[1]; rx(4) qr[1];`. + """Things like ``for x in {0, 3, 4} {rx(x) qr[1];}`` will turn into + ``rx(0) qr[1]; rx(3) qr[1]; rx(4) qr[1];``. .. note:: The ``UnrollForLoops`` unrolls only one level of block depth. No inner loop will @@ -38,7 +38,7 @@ def __init__(self, max_target_depth=-1): @control_flow.trivial_recurse def run(self, dag): - """Run the UnrollForLoops pass on `dag`. + """Run the UnrollForLoops pass on ``dag``. Args: dag (DAGCircuit): the directed acyclic graph to run on.