8000 `InverseCancellation` does not run in classical blocks like `CXCancellation` · Issue #13437 · Qiskit/qiskit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 10000
InverseCancellation does not run in classical blocks like CXCancellation #13437
Closed
@1ucian0

Description

@1ucian0

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?

  1. 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()

Image

  1. Run InverseCancellation on it
from qiskit.transpiler.passes import InverseCancellation
from qiskit.circuit.library.standard_gates import CXGate
InverseCancellation([CXGate()])(qc).draw()

Image

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()

Image

Any suggestions?

Apply InverseCancellation recursively inside the code blocks.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0