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 average gate fidelity in the commutation checker #13874

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Feb 18, 2025

Summary

The commutation checker currently uses a different metric to check when gates commute than other places in Qiskit, such as the RemoveIdentityEquivalent. This leads to strange behavior, where one gate is treated as identity in the commutation, but is subsequently not removed as other passes do not treat it as identity. This is what causes #13547.

This PR updates the commutation checker to use the same average gate fidelity and thus the transpiler to handle almost-identity gates more consistently.

Closes #13547.

Details and comments

  • Still needs a reno.
  • This has one small caveat: the definition of the average gate fidelity is global phase agnostic, but our commutation rules are not. I.e. we currently do not want to commute two gates, if doing that introduces a global phase. We could extend this in the future, but this is outside the scope of this PR.
  • This PR increases the threshold for gates to commute (== rotation angles must now be smaller than before in order to commute). This means the #gates we transpile a QFT to increases, see the benchmark below. However, @ElePT ran benchpress and this didn't seem to cause a noticable regression overall.

Here's a small benchmark comparing transpile time, CX depth and count for the (1) the QFT, (2) an efficient SU2 circuit with log(num qubits) depth and (3) a Heisenberg Trotter evolution on a line.

image

@Cryoris Cryoris requested a review from a team as a code owner February 18, 2025 17:36
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@Cryoris Cryoris added this to the 2.0.0 milestone Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect transpilation with RY gate with a small angle
3 participants