-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for returning a DAGCircuit to TwoQubitBasisDecomposer (#1…
…2109) * Add support for returning a DAGCircuit to TwoQubitBasisDecomposer This commit adds a new flag, use_dag, to the constructor for the TwoQubitBasisDecomposer. When set to True, the __call__ method will return a DAGCircuit instead of a QuantumCircuit. This is useful when the two qubit basis decomposer is called from within a transpiler context, as with the UnitarySynthesis pass, to avoid an extra conversion step. * Pivot to argument on __call__ and add to XXDecomposer too This commit moves the use_dag flag to the __call__ method directly instead of storing it as an instance variable. To make the interface consistent between the 2 built-in decomposers the flag is also added to the XXDecomposer class's __call__ method too. This was needed because the unitary synthesis pass calls the decomposers interchangeably and to be able to use them without type checking they both will need the flag.
- Loading branch information
Showing
5 changed files
with
184 additions
and
43 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
18 changes: 18 additions & 0 deletions
18
releasenotes/notes/add-use-dag-flag-two-qubit-basis-decomposer-024a9ced9833289c.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,18 @@ | ||
--- | ||
features_synthesis: | ||
- | | ||
Added a new argument, ``use_dag``, to the :meth:`.TwoQubitBasisDecomposer.__call__` | ||
and :meth:`.XXDecomposer.__call__` methods. This argument is used to control whether | ||
a :class:`.DAGCircuit` is returned when calling a :class:`.TwoQubitBasisDecomposer` | ||
or :class:`.XXDecomposer` instance instead of the default :class:`.QuantumCircuit`. | ||
For example:: | ||
from qiskit.circuit.library import CXGate | ||
from qiskit.quantum_info import random_unitary | ||
from qiskit.synthesis import TwoQubitBasisDecomposer | ||
decomposer = TwoQubitBasisDecomposer(CXGate(), euler_basis="PSX") | ||
decomposer(random_unitary(4), use_dag=True) | ||
will return a :class:`.DAGCircuit` when calling the :class:`.TwoQubitBasisDecomposer` | ||
instance ``decomposer``. |
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