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 |
jakelishman
left a comment
There was a problem hiding this comment.
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.
jakelishman
left a comment
There was a problem hiding this comment.
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. |
| 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.
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.
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