-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Enable the new efficient MCX decompose #12628
Conversation
One or more of the following people are relevant to this code:
|
7ca1f4d
to
5bd449c
Compare
I try to fix errors, but I cannot fix all errors. Need help by experts. |
Thanks for spotting this, that's indeed an easy win! 🙂 Regarding the errors:
|
Thanks for handling this @t-imamichi ! One can fix the failing test replace this line:
by: decom_circ = self.complex_circuit.decompose(["mcx"], reps=2)
replace this line:
by: decom_circ = self.complex_circuit.decompose(["mcx", "gate2"], reps=2)
|
Thank you for your suggestions, @Cryoris and @ShellyGarion. |
my suggestion works with your current PR (without any further changes) |
Yes, I confirmed it. But the combination does not work unfortunately. I pushed a commit JFYI. |
Changing C3X and C4X names does not seem a good idea. There is an unpredicted error as follows.
|
You can ignore this error, it's a bug in the qasm3 exporter. It's been looked at here: #12481 |
da22adc
to
1dcf6a7
Compare
I succeeded in passing both test_decompose.py and test_export.py by changing name of C3X and C4X. But I'm not sure this is a right way. It might be a breaking change perhaps. |
Pull Request Test Coverage Report for Build 9658863540Details
💛 - 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.
Thanks @t-imamichi for taking care of this problem!
Your solution looks fine to me, but I'm also not sure if it breaks the API.
Anyway, some release notes are needed.
The failing tests are not related to this PR, and will be solved after you merge the main branch.
Following the qiskit dev meeting, it was suggested that the gates names will remain "mcx" (and not "c3x" or "c4x") in order to keep the current API, and the name changes can be done in qiskit 2.0 release. Only the tests should be updated accordingly. |
I reverted the C3X and C4X names. But due to the name conflict of C3X, C4X and MCX (all "mcx"), qasm2/test_export.py fails as follows (a random suffix is appended, e.g.,
It might be a solution to update MCXGrayCode to replace MCU1 with MCP, but it might be another breaking change. |
use regex to fetch the mcx_<random id> name
Hi @t-imamichi, I pushed a small fix for the qasm tests using regex to match the randomized gate ID, hopefully everything passes now 🙂 |
Pull Request Test Coverage Report for Build 9676110521Details
💛 - Coveralls |
thanks! this looks good, the tests are OK now, only some lint errors (line too long) |
One or more of the following people are relevant to this code:
|
Thank you for your supports, @ShellyGarion and @Cryoris. I fixed the lint errors and added reno. |
Pull Request Test Coverage Report for Build 9689789453Details
💛 - 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.
LGTM, thanks for your efforts!
* enable the new efficient MCX decompose * fix tests * revert explicit * apply review comments * update test_circuit_qasm.py * update test_decompose.py * revert C3X C4X names * fix qasm2 exporter tests use regex to fetch the mcx_<random id> name * fix lint and add reno --------- Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Something may go wrong around qpy compatibility. But I have no idea what to do. |
merged! |
thanks! |
* enable the new efficient MCX decompose * fix tests * revert explicit * apply review comments * update test_circuit_qasm.py * update test_decompose.py * revert C3X C4X names * fix qasm2 exporter tests use regex to fetch the mcx_<random id> name * fix lint and add reno --------- Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Summary
This PR enables #11993 as
QuantumCircuit.mcx
.We can reduce the number of CNOT gates as follows.
main
this PR
Details and comments