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

Port RemoveDiagonalGatesBeforeMeasure to rust #13065

Merged
merged 17 commits into from
Sep 5, 2024

Conversation

ShellyGarion
Copy link
Member

Summary

close #12255

Details and comments

@ShellyGarion ShellyGarion added the Rust This PR or issue is related to Rust code in the repository label Sep 1, 2024
@ShellyGarion ShellyGarion added this to the 1.3 beta milestone Sep 1, 2024
@ShellyGarion ShellyGarion requested a review from a team as a code owner September 1, 2024 08:39
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @kevinhartman
  • @mtreinish

@ShellyGarion ShellyGarion added mod: transpiler Issues and PRs related to Transpiler performance labels Sep 1, 2024
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

This looks good, thanks for doing this. I just left a few small inline comments which I think should fix the test failures too.

StandardGate::CSGate,
StandardGate::CSdgGate,
]);

Copy link
Member Author

@ShellyGarion ShellyGarion Sep 2, 2024

Choose a reason for hiding this comment

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

Note that there are some 1-qubit and 2-qubit diagonal gates that did not appear in the original list, so I added them here (I'll add them to the tests later).

There is also a 3-qubit diagonal gate: CCZGate (which was not added in this PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, there is also an n-qubit diagonal gate: MCPhaseGate. This gate was not handled this PR.
This is since the algorithm given here that goes over all the successors of each of the predecessors would be O(n^2) and not O(n).

@ShellyGarion
Copy link
Member Author

the failing test should be fixed after #13067 is merged

@ShellyGarion
Copy link
Member Author

Performance comparison of the old python code and the new rust code for a random_circuit:

n_qubits depth time is sec of old Python code time in sec of new rust code
5 1024 0.06 0.00
14 1024 0.47 0.02
20 1024 0.92 0.04

@coveralls
Copy link

coveralls commented Sep 3, 2024

Pull Request Test Coverage Report for Build 10719300369

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 75 of 76 (98.68%) changed or added relevant lines in 5 files are covered.
  • 120 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.005%) to 89.186%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/remove_diagonal_gates_before_measure.rs 65 66 98.48%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 5 91.98%
qiskit/visualization/gate_map.py 115 6.69%
Totals Coverage Status
Change from base Build 10708280718: 0.005%
Covered Lines: 72673
Relevant Lines: 81485

💛 - Coveralls

Cryoris
Cryoris previously approved these changes Sep 5, 2024
Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

LGTM, also great to add the phase gates 👍🏻

As you mentioned, there is MCPhaseGate which we could handle, as well as DiagonalGate or any AnnotatedOperation with a diagonal base gate. But that would be something for a follow up (we would also make sure to remove these before any further decomposition occurs).

@Cryoris Cryoris added this pull request to the merge queue Sep 5, 2024
Merged via the queue into Qiskit:main with commit 8606f05 Sep 5, 2024
15 checks passed
@ShellyGarion ShellyGarion added the Changelog: New Feature Include in the "Added" section of the changelog label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: transpiler Issues and PRs related to Transpiler performance Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port RemoveDiagonalGatesBeforeMeasure to Rust
5 participants