Skip to content

Commit

Permalink
Document the CommutationChecker (#13303) (#13304)
Browse files Browse the repository at this point in the history
* document the commutation checker

* Review comments

(cherry picked from commit b1d6b35)

Co-authored-by: Julien Gacon <[email protected]>
  • Loading branch information
mergify[bot] and Cryoris authored Oct 10, 2024
1 parent f5c005c commit 654cdc3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions qiskit/circuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,30 @@
Consult :ref:`the control-flow construction documentation <circuit-control-flow-methods>` for more
information on how to build circuits with control flow.
Investigating commutation relations
-----------------------------------
If two operations in a circuit commute, we can swap the order in which they are applied.
This can allow for optimizations and simplifications, for example, if it allows to merge
or cancel gates:
.. code-block:: text
┌─────────┐ ┌─────────┐ ┌─────────┐
q_0: ┤ Rz(0.5) ├──■──┤ Rz(1.2) ├──■── q_0: ┤ Rz(1.7) ├
└─────────┘┌─┴─┐└──┬───┬──┘┌─┴─┐ = └──┬───┬──┘
q_1: ───────────┤ X ├───┤ X ├───┤ X ├ q_1: ───┤ X ├───
└───┘ └───┘ └───┘ └───┘
Performing these optimizations are part of the transpiler, but the tools to investigate commutations
are available in the :class:`CommutationChecker`.
.. autosummary::
:toctree: ../stubs/
CommutationChecker
.. _circuit-custom-gates:
Creating custom instructions
Expand Down

0 comments on commit 654cdc3

Please sign in to comment.