-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix parameter deserialization bugs in QPY
#13727
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
Pull Request Test Coverage Report for Build 15437163816Warning: 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 |
0de998b
to
457068f
Compare
QPY
with PauliFeatureMap
classqpy
with PauliFeatureMap
class
Fix black
934fa78
to
36835f7
Compare
One or more of the following people are relevant to this code:
|
releasenotes/notes/fix-qpy-fauli-feature-map-33292033755879ee.yaml
Outdated
Show resolved
Hide resolved
It seems like this should also be reproducible outside of the |
…yaml Co-authored-by: Julien Gacon <gaconju@gmail.com>
I know what you mean, the parameter replay sequence should be reproducible, but I have not been able to reproduce it outside of |
I don't fully understand how this bug is triggered and why we weren't able to reproduce it outside of the |
…fails for legacy ZZFeatureMap)
To summarize the changes in this PR:
|
Thank you for fixing the issue. I added a minor comment. |
Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
LGTM. I would like someone of qpy team to review it. |
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.
Sorry it took so long to review -- this looks like a good solution to me (it should maybe be noted I'm a QPY padawan still tho). I have one main concern/question about the hardcoded exceptions below 🙂
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…e element uuids from root uuid
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, thank you!
* Don't assume parameter vector names are unique * Add from_expr flag * Add reno * Specify issue number Fix black * Update releasenotes/notes/fix-qpy-fauli-feature-map-33292033755879ee.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update fix, add tests * Update reno * Update comment * Update test_circuit_load_from_qpy.py Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com> * Bump qiskit version, update docs * Avoid new warning * Assert user warning is not raised during regression tests (currently fails for legacy ZZFeatureMap) * Rename flag and add comments * Remove unnecessary logic * Document new option * Document new option * Apply suggestions from Imamichi-san's code review Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com> * Update qiskit/qpy/__init__.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Cleaner implementation: use parameter vector ROOT uuid as key, resolve element uuids from root uuid * Improve docs and comments * Fix lint * Add parameter equality tests --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
Summary
This PR fixes a series of reported issues in QPY:
The common denominator for these issues is the assumption that parameter names are unique within a circuit. This may not be true in cases where parameter re-assignment has taken place and both the old and new parameters share a name (but have different uuids). In these cases, the substitution operation is recorded in the
qpy_replay
field and should be taken into account during serialization. The bug materialized in two flavors:ParameterVector
component of aParameterExpression
(for which a newfrom_expr
flag has been added toread_parameter_vec
). This came up withNLocal
implementations (including subclasses).ParameterExpression
directly. This use case is tested intest_duplicated_param_name
, and fix by tweaking the encoded mapping to use uuids as keys instead of names.This fix tweaks the way
ParameterExpressions
are stored, so it probably needs a QPY version bump.Details and comments