-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HLSConfig option to run multiple plugins and to choose the best decom…
…position (#12108) * fix docstring * import * exposing additional plugin arguments * tests * lint * release notes * HLS config option to run all specified plugins + tests * lint" * removing todo * release notes * fixes --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
- Loading branch information
1 parent
a65c9e6
commit cd03721
Showing
3 changed files
with
163 additions
and
10 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
51 changes: 51 additions & 0 deletions
51
releasenotes/notes/add-run-all-plugins-option-ba8806a269e5713c.yaml
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,51 @@ | ||
--- | ||
features: | ||
- | | ||
The :class:`~.HLSConfig` now has two additional optional arguments. The argument | ||
``plugin_selection`` can be set either to ``"sequential"`` or to ``"all"``. | ||
If set to "sequential" (default), for every higher-level-object | ||
the :class:`~qiskit.transpiler.passes.HighLevelSynthesis` pass will consider the | ||
specified methods sequentially, in the order they appear in the list, stopping | ||
at the first method that is able to synthesize the object. If set to "all", | ||
all the specified methods will be considered, and the best synthesized circuit, | ||
according to ``plugin_evaluation_fn`` will be chosen. The argument | ||
``plugin_evaluation_fn`` is an optional callable that evaluates the quality of | ||
the synthesized quantum circuit; a smaller value means a better circuit. When | ||
set to ``None``, the quality of the circuit is its size (i.e. the number of gates | ||
that it contains). | ||
The following example illustrates the new functionality:: | ||
from qiskit import QuantumCircuit | ||
from qiskit.circuit.library import LinearFunction | ||
from qiskit.synthesis.linear import random_invertible_binary_matrix | ||
from qiskit.transpiler.passes import HighLevelSynthesis, HLSConfig | ||
# Create a circuit with a linear function | ||
mat = random_invertible_binary_matrix(7, seed=37) | ||
qc = QuantumCircuit(7) | ||
qc.append(LinearFunction(mat), [0, 1, 2, 3, 4, 5, 6]) | ||
# Run different methods with different parameters, | ||
# choosing the best result in terms of depth. | ||
hls_config = HLSConfig( | ||
linear_function=[ | ||
("pmh", {}), | ||
("pmh", {"use_inverted": True}), | ||
("pmh", {"use_transposed": True}), | ||
("pmh", {"use_inverted": True, "use_transposed": True}), | ||
("pmh", {"section_size": 1}), | ||
("pmh", {"section_size": 3}), | ||
("kms", {}), | ||
("kms", {"use_inverted": True}), | ||
], | ||
plugin_selection="all", | ||
plugin_evaluation_fn=lambda circuit: circuit.depth(), | ||
) | ||
# synthesize | ||
qct = HighLevelSynthesis(hls_config=hls_config)(qc) | ||
In the example, we run multiple synthesis methods with different parameters, | ||
choosing the best circuit in terms of depth. Note that optimizing | ||
``circuit.size()`` instead would pick a different circuit. |
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