-
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.
Ensure
translation
stage always outputs ISA circuits
This shifts the responsibility of the `translation` stage slightly to always output ISA circuits. It previously was not 100% required that they did this, at least implicitly because Qiskit's built-in plugins didn't always respect 2q direction. The builtin translation plugins now always respect 2q direction, which removes the need for the `pre_optimization` implicit stage, freeing it up for better user customisation. This (in theory) shouldn't have runtime impacts because the optimisation loop was already having to do this afterwards anyway. For potential plugins that _do_ respect gate direction (like the upcoming `BasisConstructor`), it can be a speedup in the default pipeline, since they won't need to run the gate-direction check any more.
- Loading branch information
1 parent
397e66e
commit 0caf0c9
Showing
7 changed files
with
84 additions
and
49 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
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
39 changes: 39 additions & 0 deletions
39
releasenotes/notes/translation-direction-40059e267f77e178.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,39 @@ | ||
--- | ||
upgrade_transpiler: | ||
- | | ||
Plugins for the :ref:`translation stage of the preset compiler <transpiler-preset-stage-translation>` | ||
are now required to respect gate directionality in the :class:`.Target` in their output. | ||
Previously, :func:`.transpile` and :func:`.generate_preset_pass_manager` would generate a | ||
:class:`.PassManager` that contained fix-up passes if needed. You must now include these in | ||
your own custom stage, if your stage does not guarantee that it respects directionality. | ||
You can use the :class:`.GateDirection` pass to perform the same fix-ups that Qiskit used to do. | ||
For example:: | ||
from qiskit.transpiler import PassManager | ||
from qiskit.transpiler.passes import GateDirection | ||
from qiskit.transpiler.preset_passmanagers.plugin import PassManagerStagePlugin | ||
class YourTranslationPlugin(PassManagerStagePlugin): | ||
def pass_manager(self, pass_manager_config, optimization_level): | ||
pm = PassManager([ | ||
# ... whatever your current setup is ... | ||
]) | ||
# Add the two-qubit directionality-fixing pass. | ||
pm.append(GateDirection( | ||
pass_manager_config.coupling_map, | ||
pass_manager_config.target, | ||
)) | ||
return pm | ||
- | | ||
The :ref:`preset pass managers <transpiler-preset>` no longer populate the implicit ``pre_optimization`` | ||
stage of their output :class:`.StagedPassManager`. You can now safely assign your own | ||
:class:`.PassManager` to this field. You could previously only append to the existing | ||
:class:`.PassManager`. | ||
deprecations_transpiler: | ||
- | | ||
The function :func:`.generate_pre_op_passmanager` is deprecated. It is no longer used in the | ||
Qiskit preset pass managers, and its purpose is defunct; it originally generated a fix-up stage | ||
for translation plugins that did not respect ISA directionality. Translation stages are now | ||
required to respect directionality, so the functionality is not needed, and most likely, | ||
no replacement is required. |