Skip to content

Conversation

jakelishman
Copy link
Member

Summary

Previously the module of this was set incorrectly (stemming from its move in gh-9064), at which point the __getstate__/__setstate__ pickling wouldn't work correctly any more. Also, however, there was no __getnewargs__ and new didn't have a zero-argument form, so this wouldn't have worked either.

Details and comments

No changelog because this is a private class, and it doesn't actually seem to be causing us problems.

Previously the module of this was set incorrectly (stemming from its
move in Qiskitgh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.
@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: None Do not include in changelog labels Apr 25, 2024
@jakelishman jakelishman requested a review from a team as a code owner April 25, 2024 17:14
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

@jakelishman
Copy link
Member Author

@Mergifyio backport stable/0.46

Copy link
Contributor

mergify bot commented Apr 25, 2024

backport stable/0.46

✅ Backports have been created

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8836685971

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • 11 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 89.486%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 5 92.11%
crates/qasm2/src/parse.rs 6 97.61%
Totals Coverage Status
Change from base Build 8836396414: 0.03%
Covered Lines: 60480
Relevant Lines: 67586

💛 - Coveralls

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, this is a straightforward fix. Although I assume we're never actually pickling/deepcopying nlayout objects I think the only place we're using them are inside the .run() methods for the sabre passes (and maybe stochastic swap) which won't pass a process boundary or anything so I'm not sure this comes up. I'm not sure why/when we added the __getstate__ and __setstate__ to the pyclass (looking at the code I suspect I'm responsible) but if we have the hook points defined we should make sure they work.

@@ -91,7 +91,7 @@ impl VirtualQubit {
/// physical qubit index on the coupling graph.
/// logical_qubits (int): The number of logical qubits in the layout
/// physical_qubits (int): The number of physical qubits in the layout
#[pyclass(module = "qiskit._accelerate.stochastic_swap")]
#[pyclass(module = "qiskit._accelerate.nlayout")]
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how many of these mistakes we've had after the multiple code refactors. It only will come up if we actually pickle an object though.

@mtreinish mtreinish added this pull request to the merge queue Apr 25, 2024
Merged via the queue into Qiskit:main with commit 136548c Apr 25, 2024
mergify bot pushed a commit that referenced this pull request Apr 25, 2024
Previously the module of this was set incorrectly (stemming from its
move in gh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.

(cherry picked from commit 136548c)

# Conflicts:
#	test/python/transpiler/test_layout.py
mergify bot pushed a commit that referenced this pull request Apr 25, 2024
Previously the module of this was set incorrectly (stemming from its
move in gh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.

(cherry picked from commit 136548c)
@jakelishman jakelishman deleted the pickle-nlayout branch April 25, 2024 23:07
jakelishman added a commit that referenced this pull request Apr 25, 2024
Previously the module of this was set incorrectly (stemming from its
move in gh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.
jakelishman added a commit that referenced this pull request Apr 25, 2024
Previously the module of this was set incorrectly (stemming from its
move in gh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.
@jakelishman jakelishman added this to the 1.1.0 milestone Apr 25, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 26, 2024
* Fix pickling of `NLayout` (#12298)

Previously the module of this was set incorrectly (stemming from its
move in gh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.

(cherry picked from commit 136548c)

* Switch back to PyO3 0.20

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
github-merge-queue bot pushed a commit that referenced this pull request Apr 26, 2024
* Fix pickling of `NLayout` (#12298)

Previously the module of this was set incorrectly (stemming from its
move in gh-9064), at which point the `__getstate__`/`__setstate__`
pickling wouldn't work correctly any more.  Also, however, there was no
`__getnewargs__` and `new` didn't have a zero-argument form, so this
wouldn't have worked either.

* Switch back to PyO3 0.20

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog 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.

4 participants