Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gif #13616

Merged
merged 8 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed docs/source_images/depth.gif
Binary file not shown.
29 changes: 8 additions & 21 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,27 +889,6 @@ class QuantumCircuit:

assert qc.size() == 19

A particularly important circuit property is known as the circuit :meth:`depth`. The depth
of a quantum circuit is a measure of how many "layers" of quantum gates, executed in
parallel, it takes to complete the computation defined by the circuit. Because quantum
gates take time to implement, the depth of a circuit roughly corresponds to the amount of
time it takes the quantum computer to execute the circuit. Thus, the depth of a circuit
is one important quantity used to measure if a quantum circuit can be run on a device.
abbycross marked this conversation as resolved.
Show resolved Hide resolved

The depth of a quantum circuit has a mathematical definition as the longest path in a
directed acyclic graph (DAG). However, such a definition is a bit hard to grasp, even for
experts. Fortunately, the depth of a circuit can be easily understood by anyone familiar
with playing `Tetris <https://en.wikipedia.org/wiki/Tetris>`_. Lets see how to compute this
graphically:

.. image:: /source_images/depth.gif
:alt: Rotate the circuit and let each gate fall as far as possible. The gates fall \
into "layers". The depth of the circuit is the number of layers.

We can verify our graphical result using :meth:`QuantumCircuit.depth`::

assert qc.depth() == 9

.. automethod:: count_ops
.. automethod:: depth
.. automethod:: get_instructions
Expand Down Expand Up @@ -3490,6 +3469,14 @@ def depth(
) -> int:
"""Return circuit depth (i.e., length of critical path).

The depth of a quantum circuit is a measure of how many
"layers" of quantum gates, executed in parallel, it takes to
complete the computation defined by the circuit. Because
quantum gates take time to implement, the depth of a circuit
roughly corresponds to the amount of time it takes the quantum
computer to execute the circuit.


.. warning::
This operation is not well defined if the circuit contains control-flow operations.

Expand Down
Loading