Skip to content

Commit

Permalink
small typos and spelling issues in passes docs (Qiskit#11163)
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 and jakelishman authored Nov 14, 2023
1 parent 7412951 commit 87fcd71
Show file tree
Hide file tree
Showing 43 changed files with 89 additions and 88 deletions.
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/analysis/count_ops_longest_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
5 changes: 3 additions & 2 deletions qiskit/transpiler/passes/analysis/dag_longest_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/basis/unroll_3q_or_more.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/calibration/pulse_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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__()
Expand Down
6 changes: 3 additions & 3 deletions qiskit/transpiler/passes/layout/apply_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/layout/dense_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/layout/enlarge_with_ancilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/layout/full_ancilla_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/layout/layout_2q_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions qiskit/transpiler/passes/layout/sabre_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/layout/vf2_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions qiskit/transpiler/passes/layout/vf2_post_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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
Expand Down Expand Up @@ -77,7 +77,7 @@ class VF2PostLayout(AnalysisPass):
* ``"nonexistent solution"``: If no solution was found.
* ``">2q gates in basis"``: If VF2PostLayout can't work with the basis of the circuit.
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`
Expand Down Expand Up @@ -182,7 +182,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@

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]]
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
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/optimization/commutation_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
8 changes: 4 additions & 4 deletions qiskit/transpiler/passes/optimization/consolidate_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/optimization/cx_cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions qiskit/transpiler/passes/optimization/optimize_1q_commutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 87fcd71

Please sign in to comment.