-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 issue with deepcopy and builder API. #11669
Conversation
One or more of the the following people are requested to review this:
|
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.
Ah thanks, yeah, it's obvious when you see it. Can we also add tests for shallow copy and pickle
, here?
It'd be good to include some explicit assertions on exactly the clbits/cregs that should be present in both qc
and qc2
after the deep copy/copy/pickle as well, to catch the potential failure case where both calls mutate both.
Pull Request Test Coverage Report for Build 7731848487Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
Good idea(s)! Done in ba9a32c. |
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.
Thanks for finding this, and the fix!
Wait sorry, I forgot I hadn't pushed the fix to the lint failure lol |
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.
That should keep pylint happy.
Summary
Fixes an issue with
QuantumCircuit.__deepcopy__
's handling of the scope builder API introduced in #10977.Details and comments
The
_OuterCircuitScopeInterface
instance held inQuantumCircuit._builder_api
contains a reference to the outer circuit, which appears to be an issue when performing a deepcopy (we end up with a duplicated circuit inside the scope instance).To fix this, we construct a new
_OuterCircuitScopeInterface
for the deep copy instead.Resolves #11610