Closed
Description
Environment
- Qiskit version:
2.0.0.dev0+5de0232
What is happening?
In #11212 we decided to "stop using CXCancellation
as part of the preset pass managers as it's been superseded by InverseCancellation
". However, CXCancellation
runs inside flow controlled blocks but InverseCancellation
does not.
How can we reproduce the issue?
- Create a circuit with control flow:
from qiskit import QuantumCircuit
inner = QuantumCircuit(2,1)
inner.cx(0, 1)
inner.cx(0, 1)
qc = QuantumCircuit(2, 1)
qc.cx(0, 1)
qc.cx(0, 1)
qc.if_else((0, True), inner.copy(), inner.copy(), range(2), [0])
qc.draw()
- Run
InverseCancellation
on it
from qiskit.transpiler.passes import InverseCancellation
from qiskit.circuit.library.standard_gates import CXGate
InverseCancellation([CXGate()])(qc).draw()
Notice that the CX outside got cancelled, but not those inside.
What should happen?
It should be like CXCancellation
from qiskit.transpiler.passes import CXCancellation
CXCancellation()(qc).draw()
Any suggestions?
Apply InverseCancellation
recursively inside the code blocks.
Metadata
Metadata
Assignees
Type
Projects
Status
Done