-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unitary synthesis plugin interface
This commit adds the initial steps for a unitary synthesis plugin interface. It enables external packages to ship plugin packages that then integrate cleanly into qiskit's transpiler without any need for extra imports or qiskit changes. The user can then just specify the 'unitary_synthesis_method' kwarg on the transpile() call and use the name of the external plugin and the UnitarySynthesis pass will leverage that plugin for synthesizing the unitary.
- Loading branch information
Showing
10 changed files
with
162 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
import abc | ||
|
||
import stevedore | ||
|
||
class UnitarySynthesisPlugin(abc.ABC): | ||
"""Abstract plugin Synthesis plugin class | ||
This class abstract class is | ||
""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def supports_basis_gates(self): | ||
"""Return whether the plugin supports taking basis_gates""" | ||
pass | ||
|
||
@property | ||
@abc.abstractmethod | ||
def supports_coupling_map(self): | ||
"""Return whether the plugin supports taking coupling_map""" | ||
pass | ||
|
||
@property | ||
@abc.abstractmethod | ||
def supports_approximation_degree(self): | ||
"""Return whether the plugin supports taking approximation_degree""" | ||
pass | ||
|
||
@abc.abstractmethod | ||
def run(self, unitary, **options): | ||
"""Run synthesis for the given unitary | ||
Args: | ||
unitary (numpy.ndarray): The unitary | ||
Returns: | ||
DAGCircuit: The dag circuit representation of the unitary | ||
""" | ||
pass | ||
|
||
|
||
class UnitarySynthesisPluginManager: | ||
|
||
def __init__(self): | ||
self.ext_plugins = stevedore.ExtensionManager( | ||
'qiskit.unitary_synthesis', invoke_on_load=True, | ||
propagate_map_exceptions=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ dill>=0.3 | |
fastjsonschema>=2.10 | ||
python-constraint>=1.4 | ||
python-dateutil>=2.8.0 | ||
stevedore>=3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters