Skip to content

Preserve bit locations through pickle (backport #13980) #14011

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

Merged
merged 2 commits into from
Mar 13, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Mar 13, 2025

Summary

Previously when we were pickling a DAGCircuit the bit locations fields were forgotten about. So when we loaded a DAGCircuit from a pickle the bit locations were empty. This would cause any call to find_bit() to raise an error because there was no entry for any of the bits in the dag. This commit fixes this by reconstructing the bit locations on setstate by iterating over the dag's qubits and clbits.

Details and comments

Fixes #13976


This is an automatic backport of pull request #13980 done by [Mergify](https://mergify.com).

* Preserve bit locations through pickle

Previously when we were pickling a DAGCircuit the bit locations fields
were forgotten about. So when we loaded a DAGCircuit from a pickle the
bit locations were empty. This would cause any call to find_bit() to
raise an error because there was no entry for any of the bits in the
dag. This commit fixes this by reconstructing the bit locations on
__setstate__ by iterating over the dag's qubits and clbits.

Fixes #13976

* Fix clippy

* Update docstrings

* Fix name change after rebase

(cherry picked from commit 9dcc668)
@mergify mergify bot requested a review from a team as a code owner March 13, 2025 09:29
@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 following people are relevant to this code:

  • @Qiskit/terra-core

@github-actions github-actions bot added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Mar 13, 2025
@github-actions github-actions bot added this to the 2.0.0 milestone Mar 13, 2025
@ElePT ElePT enabled auto-merge March 13, 2025 11:49
@ElePT ElePT added this pull request to the merge queue Mar 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 13, 2025
@ElePT
Copy link
Contributor

ElePT commented Mar 13, 2025

(The ubuntu wheels from the new Aer release are still in the process of being built, this is why the PR got kicked out of the queue)

@ElePT ElePT added this pull request to the merge queue Mar 13, 2025
Merged via the queue into stable/2.0 with commit b40abaa Mar 13, 2025
22 checks passed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13833810138

Details

  • 20 of 20 (100.0%) changed or added relevant lines in 1 file are covered.
  • 16 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+1.4%) to 89.537%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 94.69%
crates/qasm2/src/lex.rs 3 92.73%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 13821191064: 1.4%
Covered Lines: 57137
Relevant Lines: 63814

💛 - Coveralls

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants