-
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.
Token swapper permutation synthesis plugin (#10657)
* trying to implement permutation synthesis plugin based on token swapper * improving plugin and tests * pylint fixes * exposing seed and parallel_threshold * release notes * clarification comment * improved support for disconnected coupling maps * unused import * fix arxiv reference * minor fix * fix merge * more merge fixes * fixing imports * updating toml file * additional fixes * better way to find the position in the circuit * bump rustworkx version to 0.14.0 * doc and autosummary improvements * Update plugin docs configuration * Remove autosummary for available plugins list This commit removes the autosummary directives for building the documentation for the plugin classes. In the interest of time and combining it with the existing aqc docs we'll do this in a follow up for 1.0.0 after 1.0.0rc1 has been tagged. --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
- Loading branch information
1 parent
d033e8a
commit 738d3e4
Showing
6 changed files
with
344 additions
and
6 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
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
44 changes: 44 additions & 0 deletions
44
releasenotes/notes/add-token-swapper-synthesis-plugin-4ed5009f5f21519d.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,44 @@ | ||
--- | ||
upgrade: | ||
- | | ||
Qiskit 1.0 now requires version 0.14.0 of ``rustworkx``. | ||
features: | ||
- | | ||
Added a new :class:`.HighLevelSynthesisPlugin` for :class:`.PermutationGate` | ||
objects based on Qiskit's token swapper algorithm. To use this plugin, | ||
specify ``token_swapper`` when defining high-level-synthesis config. | ||
This synthesis plugin is able to run before or after the layout is set. | ||
When synthesis succeeds, the plugin outputs a quantum circuit consisting only of | ||
swap gates. When synthesis does not succeed, the plugin outputs `None`. | ||
The following code illustrates how the new plugin can be run:: | ||
from qiskit.circuit import QuantumCircuit | ||
from qiskit.circuit.library import PermutationGate | ||
from qiskit.transpiler import PassManager, CouplingMap | ||
from qiskit.transpiler.passes.synthesis.high_level_synthesis import HighLevelSynthesis, HLSConfig | ||
# This creates a circuit with a permutation gate. | ||
qc = QuantumCircuit(8) | ||
perm_gate = PermutationGate([0, 1, 4, 3, 2]) | ||
qc.append(perm_gate, [3, 4, 5, 6, 7]) | ||
# This defines the coupling map. | ||
coupling_map = CouplingMap.from_ring(8) | ||
# This high-level-synthesis config specifies that we want to use | ||
# the "token_swapper" plugin for synthesizing permutation gates, | ||
# with the option to use 10 trials. | ||
synthesis_config = HLSConfig(permutation=[("token_swapper", {"trials": 10})]) | ||
# This creates the pass manager that runs high-level-synthesis on our circuit. | ||
# The option use_qubit_indices=True indicates that synthesis run after the layout is set, | ||
# and hence should preserve the specified coupling map. | ||
pm = PassManager( | ||
HighLevelSynthesis( | ||
synthesis_config, coupling_map=coupling_map, target=None, use_qubit_indices=True | ||
) | ||
) | ||
qc_transpiled = pm.run(qc) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
rustworkx>=0.13.0 | ||
rustworkx>=0.14.0 | ||
numpy>=1.17,<2 | ||
scipy>=1.5 | ||
sympy>=1.3 | ||
|
Oops, something went wrong.