-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix pickling of NLayout
#12298
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 pickling of NLayout
#12298
Conversation
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.
One or more of the the following people are requested to review this:
|
@Mergifyio backport stable/0.46 |
✅ Backports have been created
|
Pull Request Test Coverage Report for Build 8836685971Details
💛 - Coveralls |
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, 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")] |
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.
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.
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
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)
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.
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.
* 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>
* 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>
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__
andnew
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.