-
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.
Fix
QuantumCircuit.decompose
for high-level objects (#13311)
* Fix decompose for HLS objects * add reno * rm old comments
- Loading branch information
Showing
4 changed files
with
131 additions
and
32 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
42 changes: 42 additions & 0 deletions
42
releasenotes/notes/fix-decompose-hls-5019793177136024.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,42 @@ | ||
--- | ||
features_circuits: | ||
- | | ||
Added a new argument ``"apply_synthesis"`` to :class:`.Decompose`, which allows | ||
the transpiler pass to apply high-level synthesis to decompose objects that are only | ||
defined by a synthesis routine. For example:: | ||
from qiskit import QuantumCircuit | ||
from qiskit.quantum_info import Clifford | ||
from qiskit.transpiler.passes import Decompose | ||
cliff = Clifford(HGate()) | ||
circuit = QuantumCircuit(1) | ||
circuit.append(cliff, [0]) | ||
# Clifford has no .definition, it is only defined by synthesis | ||
nothing_happened = Decompose()(circuit) | ||
# this internally runs the HighLevelSynthesis pass to decompose the Clifford | ||
decomposed = Decompose(apply_synthesis=True)(circuit) | ||
fixes: | ||
- | | ||
Fixed a bug in :meth:`.QuantumCircuit.decompose` where objects that could be synthesized | ||
with :class:`.HighLevelSynthesis` were first synthesized and then decomposed immediately | ||
(i.e., they were decomposed twice instead of once). This affected, e.g., :class:`.MCXGate` | ||
or :class:`.Clifford`, among others. | ||
- | | ||
Fixed a bug in :meth:`.QuantumCircuit.decompose`, where high-level objects without a definition | ||
were not decomposed if they were explicitly set via the ``"gates_to_decompose"`` argument. | ||
For example, previously the following did not perform a decomposition but now works as | ||
expected:: | ||
from qiskit import QuantumCircuit | ||
from qiskit.quantum_info import Clifford | ||
from qiskit.transpiler.passes import Decompose | ||
cliff = Clifford(HGate()) | ||
circuit = QuantumCircuit(1) | ||
circuit.append(cliff, [0]) | ||
decomposed = Decompose(gates_to_decompose=["clifford"])(circuit) |
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