Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize CXCancellation optimization pass to generic gate-inverse pairs #6576

Closed
kdk opened this issue Jun 14, 2021 · 1 comment · Fixed by #11210
Closed

Generalize CXCancellation optimization pass to generic gate-inverse pairs #6576

kdk opened this issue Jun 14, 2021 · 1 comment · Fixed by #11210
Labels
short project type: enhancement It's working, but needs polishing

Comments

@kdk
Copy link
Member

kdk commented Jun 14, 2021

What is the expected enhancement?

The CXCancellation pass currently only looks for adjacent CX-CX gates (on the same qubits) as opportunities for optimization, but it should support a broader set of both self-inverse gates and generic gate-inverse pairs.

One option (similar to what was done for CXDirection in #5609 ) would be to include in CXCancellation additional gate-inverse rules for which it can search the circuit to find applications. It would be better though to add an optional attribute to Instruction instances to denote which Instruction (if any) is know ahead of time to be an instruction's inverse.

@kdk kdk added type: enhancement It's working, but needs polishing short project labels Jun 14, 2021
@lcapelluto lcapelluto self-assigned this Jul 1, 2021
@lcapelluto lcapelluto removed their assignment Aug 19, 2021
@lcapelluto
Copy link
Contributor

This PR #6855 can be used to complete this feature request -- all that would be required would be to search for the correct inputs for the new pass prior to running. I unlinked the PR to leave this issue open after it's merged.

@mtreinish mtreinish modified the milestone: 1.0.0 Nov 1, 2023
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Nov 7, 2023
This commit updates the default optimization stage plugin to use the
InverseCancellation pass instead of CXCancellation for optimization
level 1. The CXCancellation pass was hard coded to only cancel runs of
CX gates on the same qubits. This was fine when CX is the target, but
for other targets which aren't using CX the pass had no value. An
alternative, more general, inverse cancellation pass was added in Qiskit#6855
that enables defining arbitrary inverse cancellation rules and
simplifying a dag based on it. This commit updates the default
optimization plugin at optimization level 1 to use this with some common
inverse rules for 2q gates from the standard gate library.

Closes: Qiskit#6576
Closes: Qiskit#7016
Related-to: Qiskit#7112
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Nov 7, 2023
This commit updates the default optimization stage plugin to use the
InverseCancellation pass instead of CXCancellation for optimization
level 1. The CXCancellation pass was hard coded to only cancel runs of
CX gates on the same qubits. This was fine when CX is the target, but
for other targets which aren't using CX the pass had no value. An
alternative, more general, inverse cancellation pass was added in Qiskit#6855
that enables defining arbitrary inverse cancellation rules and
simplifying a dag based on it. This commit updates the default
optimization plugin at optimization level 1 to use this with some common
inverse rules for 2q gates from the standard gate library.

Closes: Qiskit#6576
Closes: Qiskit#7016
Related-to: Qiskit#7112
github-merge-queue bot pushed a commit that referenced this issue Nov 8, 2023
)

* Use InverseCancellation in opt level 1 instead of CXCancellation

This commit updates the default optimization stage plugin to use the
InverseCancellation pass instead of CXCancellation for optimization
level 1. The CXCancellation pass was hard coded to only cancel runs of
CX gates on the same qubits. This was fine when CX is the target, but
for other targets which aren't using CX the pass had no value. An
alternative, more general, inverse cancellation pass was added in #6855
that enables defining arbitrary inverse cancellation rules and
simplifying a dag based on it. This commit updates the default
optimization plugin at optimization level 1 to use this with some common
inverse rules for 2q gates from the standard gate library.

Closes: #6576
Closes: #7016
Related-to: #7112

* Add sx sx dagger inverse pair to pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
short project type: enhancement It's working, but needs polishing
Projects
Status: done
Development

Successfully merging a pull request may close this issue.

3 participants