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

add synthesis plugin docs #11763

Merged
merged 11 commits into from
Feb 15, 2024
1 change: 0 additions & 1 deletion docs/apidoc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ API Reference
transpiler_preset
transpiler_plugins
transpiler_synthesis_plugins
transpiler_builtin_plugins
utils
exceptions
6 changes: 0 additions & 6 deletions docs/apidoc/synthesis_aqc.rst

This file was deleted.

10 changes: 0 additions & 10 deletions docs/apidoc/transpiler_builtin_plugins.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/apidoc/transpiler_synthesis_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.. automodule:: qiskit.transpiler.passes.synthesis.plugin
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
7 changes: 6 additions & 1 deletion qiskit/synthesis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@

.. autofunction:: qs_decomposition

The Approximate Quantum Compiler is available here: :mod:`qiskit.synthesis.unitary.aqc`
The Approximate Quantum Compiler is available here:

.. autosummary::
:toctree: ../stubs/

qiskit.synthesis.unitary.aqc

One-Qubit Synthesis
===================
Expand Down
5 changes: 3 additions & 2 deletions qiskit/transpiler/passes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
Synthesis
=========

The synthesis transpiler plugin documentation can be found in the
:mod:`qiskit.transpiler.passes.synthesis.plugin` page.

.. autosummary::
:toctree: ../stubs/

Expand All @@ -147,8 +150,6 @@
HighLevelSynthesis
HLSConfig
SolovayKitaev
SolovayKitaevSynthesis
AQCSynthesisPlugin

Post Layout (Post transpile qubit selection)
============================================
Expand Down
9 changes: 8 additions & 1 deletion qiskit/transpiler/passes/synthesis/aqc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
An AQC synthesis plugin to Qiskit's transpiler.
==============================================================================
AQC Synthesis Plugin (in :mod:`qiskit.transpiler.passes.synthesis.aqc_plugin`)
==============================================================================
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried removing these titles for the aqc/solovay-kitaev/unitary synthesis plugins but I think the result looks a bit strange:

Screenshot 2024-02-14 at 15 46 08

So I decided to leave the titles, but either way is possible:

Screenshot 2024-02-14 at 15 47 56


.. autosummary::
:toctree: ../stubs/

AQCSynthesisPlugin
"""
from functools import partial
import numpy as np
Expand Down
122 changes: 121 additions & 1 deletion qiskit/transpiler/passes/synthesis/high_level_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,127 @@
# that they have been altered from the originals.


"""Synthesize higher-level objects and unroll custom definitions."""
"""

High Level Synthesis Plugins
-----------------------------

Clifford Synthesis
''''''''''''''''''

.. list-table:: Plugins for :class:`qiskit.quantum_info.Clifford` (key = ``"clifford"``)
:header-rows: 1

* - Plugin name
- Plugin class
- Targeted connectivity
- Description
* - ``"ag"``
- :class:`~.AGSynthesisClifford`
- all-to-all
-
* - ``"bm"``
- :class:`~.BMSynthesisClifford`
- all-to-all
-
* - ``"greedy"``
- :class:`~.GreedySynthesisClifford`
- all-to-all
-
* - ``"layers"``
- :class:`~.LayerSynthesisClifford`
- all-to-all
-
* - ``"lnn"``
- :class:`~.LayerLnnSynthesisClifford`
- linear
-
* - ``"default"``
- :class:`~.DefaultSynthesisClifford`
- all-to-all
-

.. autosummary::
:toctree: ../stubs/

AGSynthesisClifford
BMSynthesisClifford
GreedySynthesisClifford
LayerSynthesisClifford
LayerLnnSynthesisClifford
DefaultSynthesisClifford


Linear Function Synthesis
'''''''''''''''''''''''''

.. list-table:: Plugins for :class:`.LinearFunction` (key = ``"linear"``)
:header-rows: 1

* - Plugin name
- Plugin class
- Targeted connectivity
- Description
* - ``"kms"``
- :class:`~.KMSSynthesisLinearFunction`
- linear
-
* - ``"pmh"``
- :class:`~.PMHSynthesisLinearFunction`
- all-to-all
-
* - ``"default"``
- :class:`~.DefaultSynthesisLinearFunction`
- all-to-all
-

.. autosummary::
:toctree: ../stubs/

KMSSynthesisLinearFunction
PMHSynthesisLinearFunction
DefaultSynthesisLinearFunction


Permutation Synthesis
'''''''''''''''''''''

.. list-table:: Plugins for :class:`.PermutationGate` (key = ``"permutation"``)
:header-rows: 1

* - Plugin name
- Plugin class
- Targeted connectivity
- Description
* - ``"basic"``
- :class:`~.BasicSynthesisPermutation`
- all-to-all
- optimal swap count
* - ``"acg"``
- :class:`~.ACGSynthesisPermutation`
- all-to-all
- swap depth of at most `2`
* - ``"kms"``
- :class:`~.KMSSynthesisPermutation`
- linear
- swap depth of at most `n`
* - ``"token_swapper"``
- :class:`~.TokenSwapperSynthesisPermutation`
- any
-
* - ``"default"``
- :class:`~.BasicSynthesisPermutation`
- all-to-all
- same as ``"basic"``

.. autosummary::
:toctree: ../stubs/

BasicSynthesisPermutation
ACGSynthesisPermutation
KMSSynthesisPermutation
TokenSwapperSynthesisPermutation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried integrating these with little success, but I think that having 2 tables is not that bad

Uploading Screenshot 2024-02-14 at 14.44.53.png…

"""

from typing import Optional, Union, List, Tuple

Expand Down
76 changes: 61 additions & 15 deletions qiskit/transpiler/passes/synthesis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@
See :mod:`qiskit.transpiler.preset_passmanagers.plugin` for details on how
to write plugins for transpiler stages.

Synthesis Plugin API
====================

Unitary Synthesis Plugin API
----------------------------

.. autosummary::
:toctree: ../stubs/

UnitarySynthesisPlugin
UnitarySynthesisPluginManager
unitary_synthesis_plugin_names

High-Level Synthesis Plugin API
-------------------------------

.. autosummary::
:toctree: ../stubs/

HighLevelSynthesisPlugin
HighLevelSynthesisPluginManager
high_level_synthesis_plugin_names

Writing Plugins
===============
Expand Down Expand Up @@ -285,7 +307,7 @@ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **
will return a list of all the installed Clifford synthesis plugins.

Available Plugins
-----------------
=================

High-level synthesis plugins that are directly available in Qiskit include plugins
for synthesizing :class:`.Clifford` objects, :class:`.LinearFunction` objects, and
Expand Down Expand Up @@ -314,28 +336,52 @@ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **
with respect to arbitrary coupling maps.
For more detail, please refer to description of each individual plugin.

Plugin API
==========
Below are the synthesis plugin classes available in Qiskit. These classes should not be
used directly, but instead should be used through the plugin interface documented
above. The classes are listed here to ease finding the documentation for each of the
included plugins and to ease the comparison between different synthesis methods for
a given object.


Unitary Synthesis Plugins
-------------------------

.. autosummary::
:toctree: ../stubs/
.. automodule:: qiskit.transpiler.passes.synthesis.aqc_plugin
:no-members:
:no-inherited-members:
:no-special-members:

UnitarySynthesisPlugin
UnitarySynthesisPluginManager
unitary_synthesis_plugin_names
.. automodule:: qiskit.transpiler.passes.synthesis.unitary_synthesis
:no-members:
:no-inherited-members:
:no-special-members:

High-Level Synthesis Plugins
----------------------------
.. automodule:: qiskit.transpiler.passes.synthesis.solovay_kitaev_synthesis
:no-members:
:no-inherited-members:
:no-special-members:

.. autosummary::
:toctree: ../stubs/

HighLevelSynthesisPlugin
HighLevelSynthesisPluginManager
high_level_synthesis_plugin_names
High Level Synthesis
--------------------

For each high-level object we give a table that lists all of its plugins available
directly in Qiskit. We include the name of the plugin, the class of the plugin,
the targeted connectivity map and optionally additional information. Recall the plugins
should be used via the previously described :class:`.HLSConfig`, for example::

HLSConfig(permutation=["kms"])

creates a high-level synthesis configuration that uses the ``kms`` plugin
for synthesizing :class:`.PermutationGate` objects -- i.e. those with
``name = "permutation"``. In this case, the plugin name is "kms", the plugin class
is :class:`~.KMSSynthesisPermutation`. This particular synthesis algorithm created
a circuit adhering to the linear nearest-neighbor connectivity.

.. automodule:: qiskit.transpiler.passes.synthesis.high_level_synthesis
:no-members:
:no-inherited-members:
:no-special-members:
"""

import abc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
A Solovay-Kitaev synthesis plugin to Qiskit's transpiler.
=======================================================================================================
Solovay-Kitaev Synthesis Plugin (in :mod:`qiskit.transpiler.passes.synthesis.solovay_kitaev_synthesis`)
=======================================================================================================

.. autosummary::
:toctree: ../stubs/

SolovayKitaevSynthesis
"""

from __future__ import annotations
Expand Down
12 changes: 11 additions & 1 deletion qiskit/transpiler/passes/synthesis/unitary_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Synthesize UnitaryGates."""
"""
=========================================================================================
Unitary Synthesis Plugin (in :mod:`qiskit.transpiler.passes.synthesis.unitary_synthesis`)
=========================================================================================

.. autosummary::
:toctree: ../stubs/

DefaultUnitarySynthesis
"""

from __future__ import annotations
from math import pi, inf, isclose
from typing import Any
Expand Down
Loading