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 unitary synthesis plugin interface #6124

Merged
merged 60 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ad04aaa
Add unitary synthesis plugin interface
mtreinish Mar 30, 2021
1fb017b
Also add qubits in payload with coupling map
mtreinish Apr 13, 2021
1da2d87
Fix lint
mtreinish Apr 13, 2021
0532a1e
Fix logic
mtreinish Apr 13, 2021
19bb0c8
Add documentation about the plugin interface
mtreinish Apr 14, 2021
fece875
Export get_unitary_synthesis_plugin_names from qiskit.transpiler.passes
mtreinish Apr 14, 2021
d9eda3b
Merge branch 'master' into synthesis-plugins
mtreinish Apr 14, 2021
b7678cf
Fix lint
mtreinish Apr 15, 2021
5622895
Tweak doc organization slightly
mtreinish Apr 15, 2021
566ebcf
Merge branch 'synthesis-plugins' of github.com:mtreinish/qiskit-core …
mtreinish Apr 15, 2021
0bb935e
Merge branch 'master' into synthesis-plugins
mtreinish Apr 15, 2021
faa260a
Use UnitarySynthesis for unroll3q step
mtreinish Apr 19, 2021
7808223
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish May 28, 2021
dd9211f
Run black
mtreinish May 28, 2021
20c10b7
Tweak doc organization slightly
mtreinish May 28, 2021
bd5c2ae
Merge branch 'main' into synthesis-plugins
mtreinish May 28, 2021
8f44c92
Merge branch 'main' into synthesis-plugins
mtreinish Jun 14, 2021
bb10dcc
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish Jul 28, 2021
04b72bc
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish Aug 3, 2021
291457a
Fix lint
mtreinish Aug 3, 2021
9557aaf
Fix pylint errors
mtreinish Aug 3, 2021
b7a9873
Merge branch 'main' into synthesis-plugins
mtreinish Aug 5, 2021
bf8a6e5
Merge branch 'main' into synthesis-plugins
mtreinish Aug 9, 2021
4c52bfc
Merge branch 'main' into synthesis-plugins
mtreinish Aug 16, 2021
35709d5
Apply suggestions from code review
mtreinish Aug 26, 2021
449b6ac
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish Aug 26, 2021
78f84b4
Update plugin interface docs
mtreinish Aug 26, 2021
1dd25b4
Review comment updates on UnitarySynthesis pass
mtreinish Aug 26, 2021
935ac01
Fix typos
jakelishman Aug 26, 2021
44a186c
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish Aug 26, 2021
c161b9d
Include release notes
mtreinish Aug 26, 2021
373f43d
Fix docstring typo
mtreinish Aug 26, 2021
def0a66
Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py
mtreinish Aug 30, 2021
46db9ec
Merge branch 'main' into synthesis-plugins
mtreinish Aug 30, 2021
9c64267
Merge branch 'main' into synthesis-plugins
mtreinish Sep 4, 2021
9a0b941
Merge remote-tracking branch 'ibm/main' into synthesis-plugins
jakelishman Sep 20, 2021
f83c841
Ignore deprecation warnings from importlib metadata
mtreinish Sep 20, 2021
2e1726c
Pin importlib-metadata
mtreinish Sep 20, 2021
6b9d550
Add length units to docstring
mtreinish Sep 21, 2021
db38b8d
Add min and max qubit abstract properties
mtreinish Sep 21, 2021
5e35056
Merge branch 'main' into synthesis-plugins
mtreinish Sep 21, 2021
3d9b783
Add option to automatically find basis for a run() call
mtreinish Sep 21, 2021
c5f6f7f
Merge branch 'synthesis-plugins' of github.com:mtreinish/qiskit-core …
mtreinish Sep 21, 2021
e65c01a
Fix typo
mtreinish Sep 23, 2021
ac9f85d
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish Sep 23, 2021
6f1eb05
Update gate errors docstring
mtreinish Sep 28, 2021
303eb29
Merge remote-tracking branch 'origin/main' into synthesis-plugins
mtreinish Sep 28, 2021
cc9fe27
Remove approximation degree from plugin interface
mtreinish Sep 28, 2021
d57351e
Fix docstring typos
mtreinish Sep 28, 2021
43c46f5
Merge branch 'main' into synthesis-plugins
mtreinish Sep 28, 2021
0e06b7d
Apply suggestions from code review
mtreinish Sep 29, 2021
d9f6884
Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py
mtreinish Sep 29, 2021
0e5c637
Merge branch 'main' into synthesis-plugins
mtreinish Sep 29, 2021
5d8539a
Update docstrings and naming and default to 'default' plugin in kwarg
mtreinish Sep 29, 2021
aa2af0f
Make coupling_map run() kwarg a tuple
mtreinish Sep 29, 2021
ba6a4a0
Add comment on why we don't use a shared global instance
mtreinish Sep 29, 2021
66bb763
Fix straggler basis->bases typos
jakelishman Sep 30, 2021
7240065
Apply suggestions from code review
mtreinish Sep 30, 2021
9ca591a
Document supported_bases handling of no matching basis
mtreinish Sep 30, 2021
9c12540
Merge remote-tracking branch 'ibm/main' into pr/6124
jakelishman Sep 30, 2021
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
1 change: 1 addition & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ decorator==4.4.2
jax==0.2.13
jaxlib==0.1.67
networkx==2.5
importlib-metadata==4.6.4
1 change: 1 addition & 0 deletions docs/apidocs/terra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Qiskit Terra API Reference
transpiler
transpiler_passes
transpiler_preset
transpiler_plugins
utils
opflow
algorithms
6 changes: 6 additions & 0 deletions docs/apidocs/transpiler_plugins.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _qiskit-transpiler-plugins:

.. automodule:: qiskit.transpiler.passes.synthesis.plugin
:no-members:
:no-inherited-members:
:no-special-members:
19 changes: 19 additions & 0 deletions qiskit/compiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def transpile(
pass_manager: Optional[PassManager] = None,
callback: Optional[Callable[[BasePass, DAGCircuit, float, PropertySet, int], Any]] = None,
output_name: Optional[Union[str, List[str]]] = None,
unitary_synthesis_method: Optional[str] = None,
) -> Union[QuantumCircuit, List[QuantumCircuit]]:
"""Transpile one or more circuits, according to some desired transpilation targets.

Expand Down Expand Up @@ -215,6 +216,10 @@ def callback_func(**kwargs):

output_name: A list with strings to identify the output circuits. The length of
the list should be exactly the length of the ``circuits`` parameter.
unitary_synthesis_method (str): The name of the unitary synthesis
method to use. By default 'default' is used, which is the only
method included with qiskit. If you have installed any unitary
synthesis plugins you can use the name exported by the plugin.

Returns:
The transpiled circuit(s).
Expand Down Expand Up @@ -249,6 +254,7 @@ def callback_func(**kwargs):
routing_method=routing_method,
translation_method=translation_method,
approximation_degree=approximation_degree,
unitary_synthesis_method=unitary_synthesis_method,
backend=backend,
)

Expand Down Expand Up @@ -294,6 +300,7 @@ def callback_func(**kwargs):
callback,
output_name,
timing_constraints,
unitary_synthesis_method,
)

_check_circuits_coupling_map(circuits, transpile_args, backend)
Expand Down Expand Up @@ -476,6 +483,7 @@ def _parse_transpile_args(
callback,
output_name,
timing_constraints,
unitary_synthesis_method,
) -> List[Dict]:
"""Resolve the various types of args allowed to the transpile() function through
duck typing, overriding args, etc. Refer to the transpile() docstring for details on
Expand Down Expand Up @@ -508,6 +516,9 @@ def _parse_transpile_args(
routing_method = _parse_routing_method(routing_method, num_circuits)
translation_method = _parse_translation_method(translation_method, num_circuits)
approximation_degree = _parse_approximation_degree(approximation_degree, num_circuits)
unitary_synthesis_method = _parse_unitary_synthesis_method(
unitary_synthesis_method, num_circuits
)
seed_transpiler = _parse_seed_transpiler(seed_transpiler, num_circuits)
optimization_level = _parse_optimization_level(optimization_level, num_circuits)
output_name = _parse_output_name(output_name, circuits)
Expand Down Expand Up @@ -542,6 +553,7 @@ def _parse_transpile_args(
"callback": callback,
"backend_num_qubits": backend_num_qubits,
"faulty_qubits_map": faulty_qubits_map,
"unitary_synthesis_method": unitary_synthesis_method,
}
):
transpile_args = {
Expand All @@ -559,6 +571,7 @@ def _parse_transpile_args(
approximation_degree=kwargs["approximation_degree"],
timing_constraints=kwargs["timing_constraints"],
seed_transpiler=kwargs["seed_transpiler"],
unitary_synthesis_method=kwargs["unitary_synthesis_method"],
),
"optimization_level": kwargs["optimization_level"],
"output_name": kwargs["output_name"],
Expand Down Expand Up @@ -818,6 +831,12 @@ def _parse_approximation_degree(approximation_degree, num_circuits):
return approximation_degree


def _parse_unitary_synthesis_method(unitary_synthesis_method, num_circuits):
if not isinstance(unitary_synthesis_method, list):
unitary_synthesis_method = [unitary_synthesis_method] * num_circuits
return unitary_synthesis_method


def _parse_seed_transpiler(seed_transpiler, num_circuits):
if not isinstance(seed_transpiler, list):
seed_transpiler = [seed_transpiler] * num_circuits
Expand Down
1 change: 1 addition & 0 deletions qiskit/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def setUpClass(cls):
"test.python.quantum_info.operators.channel.test_stinespring",
"test.python.quantum_info.operators.symplectic.test_sparse_pauli_op",
"test.python.quantum_info.operators.channel.test_ptm",
"importlib_metadata",
]
for mod in allow_DeprecationWarning_modules:
warnings.filterwarnings("default", category=DeprecationWarning, module=mod)
Expand Down
1 change: 1 addition & 0 deletions qiskit/transpiler/passes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@

# synthesis
from .synthesis import UnitarySynthesis
from .synthesis import unitary_synthesis_plugin_names

# calibration
from .calibration import PulseGates
Expand Down
1 change: 1 addition & 0 deletions qiskit/transpiler/passes/synthesis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
"""Module containing transpiler synthesis passes."""

from .unitary_synthesis import UnitarySynthesis
from .plugin import unitary_synthesis_plugin_names
Loading