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

Use InverseCancellation in opt level 1 instead of CXCancellation #11210

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

mtreinish
Copy link
Member

@mtreinish mtreinish commented Nov 7, 2023

Summary

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 from the standard gate library.

Details and comments

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

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 mtreinish added Changelog: None Do not include in changelog mod: transpiler Issues and PRs related to Transpiler labels Nov 7, 2023
@mtreinish mtreinish added this to the 1.0.0 milestone Nov 7, 2023
@mtreinish mtreinish requested a review from a team as a code owner November 7, 2023 18:58
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Nov 7, 2023

Pull Request Test Coverage Report for Build 6798322136

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 86.948%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 90.66%
Totals Coverage Status
Change from base Build 6774672560: 0.02%
Covered Lines: 74352
Relevant Lines: 85513

💛 - Coveralls

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a sensible, logical improvement overall. With #11211 also in place, are we expecting any meaningful slowdown from switching to this?

I suspect that this switch will help out the quality of discrete-basis transpilation to the Clifford set in the short term.

qiskit/transpiler/preset_passmanagers/builtin_plugins.py Outdated Show resolved Hide resolved
@mtreinish
Copy link
Member Author

This seems like a sensible, logical improvement overall. With #11211 also in place, are we expecting any meaningful slowdown from switching to this?

I wasn't expecting a significant slowdown it's just in the worst case we go from 1 unconditional call to DAGCircuit.collect_runs() to 11 (and 12 after I add (sx, sxdg)) which does call the filter function number of node times. I was expecting it to be measurable but not a bottleneck. So I after looking at the code I pushed up #11211 because it was easy to reduce this constant overhead.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, and that matches with what I'd have expected from the changeset as well.

@jakelishman jakelishman enabled auto-merge November 8, 2023 13:05
@jakelishman jakelishman added this pull request to the merge queue Nov 8, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 8, 2023
@jakelishman jakelishman added this pull request to the merge queue Nov 8, 2023
Merged via the queue into Qiskit:main with commit 940ccab Nov 8, 2023
@mtreinish mtreinish deleted the use-inverse-cancellation branch November 8, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog mod: transpiler Issues and PRs related to Transpiler
Projects
None yet
4 participants