-
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
Add QPY serialization for PauliEvolutionGate #7374
Conversation
This commit adds serialization for the PauliEvolutionGate class so that we can exactly reproduce a PauliEvolutionGate over QPY. This works by bumping the qpy format version and adding new structs to represent the PauliEvolutionGate and all it's child attribute types.
I've tagged this for 0.19.1 but I'm not optimistic it'll be ready in time so we should not block on this. |
This commit fixes the handling of the operator attribute in the PauliEvolutionGate. With this commit we can serialize a PauliEvolutionGate correctly with the exception of it's synthesis class which still needs to be supported.
Pull Request Test Coverage Report for Build 1555898624
💛 - Coveralls |
Ok, this should be ready for review now. I think all the use cases are working. |
releasenotes/notes/fix-pauli-evolution-gate-bf85592f0f8f0ba7.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: Jake Lishman <jake@binhbar.com>
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 now. Julien (@Cryoris), have you tested it to make sure it handles your use-case?
with io.BytesIO() as element_buf: | ||
with io.BytesIO() as buf: |
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.
No need to change this, but for the future you can avoid an extra scope by doing
with io.BytesIO() as element_buf, io.BytesIO() as buf:
the scope order is guaranteed to be left-to-right. (Assuming it's not a line-length constraint!)
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.
Ah cool, I didn't realize that
Yes, it fixes the problem locally 👍🏻 as soon as we merged it we can properly test it on the runtime image using Terra main. |
* WIP: Add qpy serialization for PauliEvolutionGate This commit adds serialization for the PauliEvolutionGate class so that we can exactly reproduce a PauliEvolutionGate over QPY. This works by bumping the qpy format version and adding new structs to represent the PauliEvolutionGate and all it's child attribute types. * Fix handling of operator in PauliEvolutionGate This commit fixes the handling of the operator attribute in the PauliEvolutionGate. With this commit we can serialize a PauliEvolutionGate correctly with the exception of it's synthesis class which still needs to be supported. * settings for synth * Add support for custom synthesis classes * Expand test coverage * Add release notes * Update release note * fix param binding in PauliEvo * allow time as an int * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/circuit/qpy_serialization.py Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/circuit/qpy_serialization.py * Rerun with latest black * Close buffers when finished * Fix release note wording * Fix lint * Adjust tests around extra layer of gates Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Jake Lishman <jake@binhbar.com> (cherry picked from commit 9af5ca1)
* WIP: Add qpy serialization for PauliEvolutionGate This commit adds serialization for the PauliEvolutionGate class so that we can exactly reproduce a PauliEvolutionGate over QPY. This works by bumping the qpy format version and adding new structs to represent the PauliEvolutionGate and all it's child attribute types. * Fix handling of operator in PauliEvolutionGate This commit fixes the handling of the operator attribute in the PauliEvolutionGate. With this commit we can serialize a PauliEvolutionGate correctly with the exception of it's synthesis class which still needs to be supported. * settings for synth * Add support for custom synthesis classes * Expand test coverage * Add release notes * Update release note * fix param binding in PauliEvo * allow time as an int * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/circuit/qpy_serialization.py Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/circuit/qpy_serialization.py * Rerun with latest black * Close buffers when finished * Fix release note wording * Fix lint * Adjust tests around extra layer of gates Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Jake Lishman <jake@binhbar.com> (cherry picked from commit 9af5ca1) Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Summary
This commit adds serialization for the PauliEvolutionGate class so that
we can exactly reproduce a PauliEvolutionGate over QPY. This works by
bumping the qpy format version and adding new structs to represent the
PauliEvolutionGate and all it's child attribute types.
Details and comments
If this can be finished and thoroughly tested in time for 0.19.1 we can include this. Otherwise we can come up with a faster workaround and then just save this for 0.20.0 (and probably QPY v4 assuming #7372 is included in 0.19.1 with a format bump to represent
ParameterVectorElement
s).TODO:
PauliEvolutionGate.operator
to not usePauliSumOp
(which is incorrect) and useSparsePauliOp
directly