-
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
Fix qpy for MCX
gates
#9391
Fix qpy for MCX
gates
#9391
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 the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 3971521387
💛 - 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.
This fix looks fine to me, thanks. You can add a use of this gate into this existing test: https://github.com/Qiskit/qiskit-terra/blob/a0466b36c7086166f780747d501b0fbcdc2863cd/test/python/circuit/test_circuit_load_from_qpy.py#L1044
The tests of QPY are in test/python/circuit
because that's where QPY itself used to live, before it got its own subpackage. In the same file there are also some larger tests of things like QFT - if there's an intermediate algorithm library object for IPE, you could add a similar test to the QFT one too.
This wants a bugfix release note too.
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.
Looks good to me, but we'll wait until everything else for 0.23.0 is merged before we merge this, to avoid holding up the release with CI.
This can get merged between rc1 and the full release, since it's a pure bugfix.
Thanks @jakelishman!! That sounds good. |
qiskit/qpy/binary_io/circuits.py
Outdated
@@ -252,7 +252,7 @@ def _read_instruction(file_obj, circuit, registers, custom_operations, version, | |||
if gate_name in {"IfElseOp", "WhileLoopOp"}: | |||
gate = gate_class(condition_tuple, *params) | |||
elif version >= 5 and issubclass(gate_class, ControlledGate): | |||
if gate_name in {"MCPhaseGate", "MCU1Gate"}: | |||
if gate_name in {"MCPhaseGate", "MCU1Gate", "MCXGrayCode"}: |
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.
I'm just curious if there are other gates in the mcx family that have the same constructor and need this. I always get lost in all the mcx variants. But it might be good to check we've got all of them covered here
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.
You were right @mtreinish, qpy also fails for other MCX gates. Namely (I think these are all):
MCXRecursive
MCXVChain
MCXGate
I can add these to the PR. I though I had tested it before realizing that I was using 2 control qubits, so the gate ended up being of type CCXGate
(of course my checks passed).
Oh, I was 2min too slow on my comments just ignore those suggestions, decreasing the control qubit counts on the gates works just as well |
* Add MCXGrayCode * Add test and reno * Add other mcx gates * Fix test Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit ad95294) Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This PR fixes #9390.
Details and comments