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

Parameterize Commutation Checker #13302

Merged
merged 8 commits into from
Oct 30, 2024
Merged

Conversation

MarcDrudis
Copy link
Contributor

Summary

Add support for basic parameterized gates in the commutation checker (props to @Cryoris). This is currently only done for rotation gates that have a single generator (e.g. done for RXX but not for XXPlusYY). This has the power to improve compiler quality, but also speeds up the CommutationChecker in cases where we have to check if gates are parameterized a lot.

Details and Comments

This works by replacing a parameterized gate by it's generator. For example, RZ(theta) commutes with a gate exactly if Z commutes with that gate. The special cases of theta mod 2pi = 0 are also handled. For compiling a 100-qubit QFT circuit (which has loads of CPhase gates), the runtime on my laptop was reduced as:

(main) Took 2.1887816429138183 +- 0.3050131081682874s
(this PR) Took 1.8230558633804321 +- 0.19875805494141444s

which is more than I expected given the small substitution.

@MarcDrudis MarcDrudis requested a review from a team as a code owner October 9, 2024 14:17
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Oct 9, 2024
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Oct 9, 2024

Pull Request Test Coverage Report for Build 11594925663

Details

  • 63 of 64 (98.44%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.03%) to 88.726%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/commutation_checker.rs 62 63 98.41%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/two_qubit_decompose.rs 1 92.09%
crates/accelerate/src/commutation_checker.rs 1 97.09%
crates/qasm2/src/lex.rs 5 92.23%
Totals Coverage Status
Change from base Build 11592501902: 0.03%
Covered Lines: 75579
Relevant Lines: 85182

💛 - Coveralls

@mtreinish mtreinish added performance Changelog: New Feature Include in the "Added" section of the changelog Rust This PR or issue is related to Rust code in the repository mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Oct 9, 2024
@Cryoris Cryoris self-assigned this Oct 9, 2024
Copy link
Contributor Author

@MarcDrudis MarcDrudis left a comment

Choose a reason for hiding this comment

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

I adressed the comments. Thank you for the feedback!

@mtreinish mtreinish added this to the 1.3.0 milestone Oct 20, 2024
@Cryoris
Copy link
Contributor

Cryoris commented Oct 30, 2024

I ran the utility scale benchmarks in test/benchmarks and this improves the performance for the QFT benchmarks by ~22% leaving the others unchanged. The depths also don't change so this is consistent with the current behavior.

Average over 10 runs with CX as basis gate
main:
-- Times:
QFT: 1.3684054851531982 +- 0.024621658803924102
Heisen: 0.19565179347991943 +- 0.014674726792643892
QAOA: 0.5207660913467407 +- 0.021566247367379065
QV: 1.3223005056381225 +- 0.021189671640295876
SU2: 3.677972507476807 +- 0.031693344070161326
BV: 0.1491406202316284 +- 0.011247038996003447
BV-like: 0.006857585906982422 +- 0.00033202630149019145
Total: 7.241094589233399

-- Depths:
QFT: 1954
Heisen: 462
QAOA: 1607
QV: 2709
SU2: 300
BV: 395
BV-like: 0

this PR:
-- Times:
QFT: 1.0807523250579834 +- 0.01748851782021482
Heisen: 0.19395751953125 +- 0.015540161362770638
QAOA: 0.4986311912536621 +- 0.017146640364266583
QV: 1.313275194168091 +- 0.014704899418210503
SU2: 3.694802403450012 +- 0.028206125743678666
BV: 0.1501666784286499 +- 0.009483460690998797
BV-like: 0.007105302810668945 +- 0.0003282014217839353
Total: 6.938690614700318

-- Depths:
QFT: 1954
Heisen: 462
QAOA: 1607
QV: 2709
SU2: 300
BV: 395
BV-like: 0

@Cryoris Cryoris added this pull request to the merge queue Oct 30, 2024
Merged via the queue into Qiskit:main with commit 047e078 Oct 30, 2024
17 checks passed
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 Community PR PRs from contributors that are not 'members' of the Qiskit repo mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library performance Rust This PR or issue is related to Rust code in the repository
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants