-
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.
Make GatesInBasis transpiler pass Target aware (#7548)
* Make GatesInBasis transpiler pass Target aware This commit makes the GatesInBasis transpiler pass target aware. It adds a new kwarg, target, which optionally takes a Target object. If it's specified the basis_gates required field will be ignored and the pass will check that the gates and their qargs are valid in the target. Part of #7113 * Update qiskit/transpiler/passes/utils/gates_basis.py Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * No longer make basis_gates a required argument Now that we can specify a target or basis_gates it's probably best that we don't require basis_gates is always set, especially since a target will always take precedence over the basis_gates list. This commit makes basis_gates optional, but explicitly raises an error if neither basis_gates or target is set on the constructor. * Switch to op_nodes() for internal loop This commit tweaks the internal loop to be over dag.op_nodes() instead of dag.topological_op_nodes() which was used in earlier iterations. In local benchmarking dag.op_nodes() is on average 2x faster than dag.topological_op_nodes(). * Improve performance of basis_gates path This commit improves the performance of the basis_gates code path by combining the basis_gates set with the built-in directives and doing only one set lookup per iteration instead of two. Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix support of ideal operations in target This commit fixes the handling of ideal operations in a target. If an operation is listed as ideal (where it applies on all qubits and doesn't have any error or duration information) in a target then the instruction properties inner dict is set to `{None: None}` to indicate this. For the gates in basis pass this just means it needs to check if the qubits for a particular instruction are None, and if it is we can treat it as a match. * Use target instruction_supported() method In #7778 a new target method, instruction_supported(), was added to simplify checking if an instruction (operation + qubits) is supported on a target object. This commit switches the GatesInBasis pass to use this internally instead of manually querying the target. Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
25be8a2
commit c28fe7b
Showing
3 changed files
with
159 additions
and
8 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
9 changes: 9 additions & 0 deletions
9
releasenotes/notes/gates_in_basis_target_aware-9bcd698adc3ecc28.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,9 @@ | ||
--- | ||
features: | ||
- | | ||
Added a new kwarg, ``target``, to the constructor for the | ||
:class:`.GatesInBasis` transpiler pass. This new argument can be used to | ||
optionally specify a :class:`.Target` object that represents the backend. | ||
When set this :class:`.Target` will be used for determining whether | ||
a :class:`.DAGCircuit` contains gates outside the basis set. | ||
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