Skip to content
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 serialization of primitives #9076

Merged
merged 6 commits into from
Nov 17, 2022
Merged

Conversation

ikkoham
Copy link
Contributor

@ikkoham ikkoham commented Nov 4, 2022

Summary

Fix #9033

Details and comments

@ikkoham ikkoham requested review from a team and t-imamichi as code owners November 4, 2022 13:46
@qiskit-bot
Copy link
Collaborator

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:

@ikkoham ikkoham added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: primitives Related to the Primitives module labels Nov 4, 2022
t-imamichi
t-imamichi previously approved these changes Nov 4, 2022
Comment on lines 326 to 332
@combine(backend=BACKENDS)
def test_serialization(self, backend):
"""Test of serialize and deserialize"""
estimator = BackendEstimator(backend=backend)
serialization = pickle.dumps(estimator)
_ = pickle.loads(serialization)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to add a test for this and treat this as part of the API contract for BackendEstimator and BackendSampler. As I said in #9033 Backend objects are never guaranteed to be serializable and therefore these backend wrapping primitive classes can't have this guarantee either. This test only works because of the particulars of how the fake backends in terra are implemented

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I got it. I will remove them.

@coveralls
Copy link

coveralls commented Nov 4, 2022

Pull Request Test Coverage Report for Build 3487912961

  • 3 of 5 (60.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 84.563%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/primitives/backend_estimator.py 1 2 50.0%
qiskit/primitives/backend_sampler.py 2 3 66.67%
Totals Coverage Status
Change from base Build 3485075984: -0.04%
Covered Lines: 62427
Relevant Lines: 73823

💛 - Coveralls

ikkoham and others added 2 commits November 9, 2022 11:48
…2a.yaml

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@ikkoham ikkoham added this to the 0.22.3 milestone Nov 9, 2022
t-imamichi
t-imamichi previously approved these changes Nov 16, 2022
@t-imamichi
Copy link
Member

@adekusar-drl Can you try this PR with your code?

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a small suggestion for clarity in the release

@adekusar-drl
Copy link
Contributor

@t-imamichi Looks good, thanks!

@mergify mergify bot merged commit a4a6be0 into Qiskit:main Nov 17, 2022
mergify bot pushed a commit that referenced this pull request Nov 17, 2022
* fix serialization of primitives

* Update releasenotes/notes/fix-serialization-primitives-c1e44a37cfe7a32a.yaml

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

* rm tests

* Update releasenotes/notes/fix-serialization-primitives-c1e44a37cfe7a32a.yaml

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

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
(cherry picked from commit a4a6be0)
mergify bot added a commit that referenced this pull request Nov 17, 2022
* fix serialization of primitives

* Update releasenotes/notes/fix-serialization-primitives-c1e44a37cfe7a32a.yaml

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

* rm tests

* Update releasenotes/notes/fix-serialization-primitives-c1e44a37cfe7a32a.yaml

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

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
(cherry picked from commit a4a6be0)

Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
@ikkoham ikkoham deleted the primitives/serialization branch November 18, 2022 01:28
Cryoris pushed a commit to Cryoris/qiskit-terra that referenced this pull request Jan 12, 2023
* fix serialization of primitives

* Update releasenotes/notes/fix-serialization-primitives-c1e44a37cfe7a32a.yaml

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

* rm tests

* Update releasenotes/notes/fix-serialization-primitives-c1e44a37cfe7a32a.yaml

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

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: primitives Related to the Primitives module stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend based primitives are not serializable via dill
6 participants