-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Update synth_mcx_kg24 to use relative phase Toffolis #14394
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
Conversation
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:
|
Some benchmarks to justify the change in HLS transpiler: CX Counts
Depth
U Counts
Code
|
Pull Request Test Coverage Report for Build 15348049412Warning: 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
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patelvyom - this is a great idea to replace all toffoli gates by relative toffolis, and I'm extremely happy to see that the CX counts bounds have improved by 2x!
My main comment is that we already have an rccx
method in qiskit and using it could simplify your code, and maybe make it faster (since it's written in rust).
Could you also fix your previous release notes for the plugins?
https://github.com/Qiskit/qiskit/blob/main/releasenotes/notes/add-new-mcx-plugins-2177db9195e2b680.yaml
If you make these changes in the next days, I think this PR could go into qiskit 2.1 release (planned on June 6). Otherwise, it will go into qiskit 2.2 (and require new release notes).
There is no reason to hurry here - it's up to you :)
Co-authored-by: Shelly Garion <[email protected]>
…thout x with rccx
@ShellyGarion I've addressed your comments. Let me know if you have more suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patelvyom - thanks for doing all these changes so quickly!
I have one final small comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR enhances #13922 by replacing ccx
gates with rccx
gates, thus improving the CX count by 2x!
I think it should definitely go into qiskit 2.1 release.
@alexanderivrii - do you have any final comments?
* add relative phase toffoli in ccx+x decomp * update cx counts tests * update HLS transpiler * Update qiskit/synthesis/multi_controlled/mcx_synthesis.py Co-authored-by: Shelly Garion <[email protected]> * use in-built rccx instead of custom implementation, repalce rccx_x without x with rccx * use rccx in logn_depth_ladder * update dosctring * replace inverse with regular rccx_x * update synth order in release notes * use rccx directly --------- Co-authored-by: Shelly Garion <[email protected]>
Summary
This PR enhances the recently introduced MCX synthesis methods (see #13922) by replacing standard Toffoli gates with relative-phase Toffolis, resulting in significantly improved CX gate counts.
Details and Comments
By leveraging relative-phase Toffolis, this PR reduces CX counts by up to a factor of 2 across several synthesis strategies. Notably, the CX counts for the following methods now match!
synth_mcx_2_clean_kg24
synth_mcx_1_clean_kg24
synth_mcx_n_clean_m15
Key improvements:
CCX + X
with_n_parallel_ccx_x
, using relative-phase Toffolis internally.Tagging @ShellyGarion, as you're familiar with the recent changes in this area.