Skip to content

Commit

Permalink
Fix ParameterVector handling in QPY serialization (#7381)
Browse files Browse the repository at this point in the history
* Add ParameterVector handling to QPY serialisation

This adds special handling for `ParameterVectorElement` instances within
circuits on serialisation to QPY.  These needed to be recreated into
the correct class (as opposed to a raw `Parameter`) so that their sort
order in `QuantumCircuit.parameters` would remain the same after a QPY
round trip.  Without special handling, once there were 10 or more
elements in the vector, the naming (suffixed numbers with no leading
zeros) would cause the sort order to be wrong.

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* Add parameter vector support to PauliEvolutionGate qpy

* Add release note

* Fix docs typo

* Rename PARAMETER_VECTOR -> PARAMETER_VECTOR_ELEMENT

* Support ParameterVectorElements in ParameterExpressions

* Add compat tests for parameter vector in parameter expression

* Fix lint

* Update releasenotes/notes/fix-paramater-vector-qpy-52b16ccefecf8b2e.yaml

Co-authored-by: Jake Lishman <jakelishman@gmail.com>

* Emit warning in deserialization if a parameter vector isn't fully serialized in a qpy file

* Serialize a ParameterVectorElement global phase correctly

* Update test/python/circuit/test_circuit_load_from_qpy.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Improve docs

* Apply suggestions from code review

Co-authored-by: Jake Lishman <jakelishman@gmail.com>

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
  • Loading branch information
3 people authored Dec 9, 2021
1 parent d9ab98f commit 5c4cd2b
Show file tree
Hide file tree
Showing 4 changed files with 411 additions and 35 deletions.
Loading

0 comments on commit 5c4cd2b

Please sign in to comment.