-
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.
Make ConsolidateBlocks transpiler pass target aware (#7778)
* Make ConsolidateBlocks transpiler pass target aware This commit updates the consolidate blocks pass target aware so that at its instantiation a Target object can be specified to define the target device for compilation. When specified this target will be used for all device aware operations in the pass. When a target is specified the consolidate blocks pass will only consolidate blocks with instructions outside the target (both operation and qubits). Part of #7113 * Fix typo * Add release note * Add tests for target instruction_supported() method * Add Target tests for consolidate block * Apply suggestions from code review Co-authored-by: Jake Lishman <[email protected]> * Check number of arguments in ideal operation case This commit adds a check in the ideal operation case that the number of qargs is equal to the number of qubits the operation object supports. This way if you call instruction_supported() with a qargs parameter that has the wrong number of arguments even an ideally implemented gate will return false. For example, target.instruction_supported(cx, (0, 1, 2)) will return False since a CXGate object only supports 2 qubits. * Cast qargs to tuple to prevent issues with qarg list lookups * Deduplicate qubit index map creation Co-authored-by: Jake Lishman <[email protected]>
- Loading branch information
1 parent
d255de1
commit 79c332e
Showing
9 changed files
with
121 additions
and
11 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
16 changes: 16 additions & 0 deletions
16
releasenotes/notes/consolidate-blocks-target-aware-6482e65d6ee2d18c.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,16 @@ | ||
--- | ||
|
||
features: | ||
- | | ||
The :class:`~qiskit.transpiler.ConsolidateBlocks` pass has a new keyword | ||
argument on its constructor, ``target``. This argument is used to specify a | ||
:class:`~qiskit.transpiler.Target` object representing the compilation | ||
target for the pass. If it is specified it supersedes the ``basis_gates`` | ||
kwarg. If a target is specified the pass will respect the gates and qubits | ||
when deciding which gates to consolidate into a unitary. | ||
- | | ||
The :class:`~qiskit.transpiler.Target` class has a new method, | ||
:meth:`~qiskit.transpiler.Target.instruction_supported` which is used | ||
to query the target to see if an instruction (the combination of an | ||
operation and the qubit(s) it is executed on) is supported on the backend | ||
modelled by the :class:`~qiskit.transpiler.Target`. |
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