-
Notifications
You must be signed in to change notification settings - Fork 603
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
Add update kwarg to QuantumScript.copy #6285
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
[sc-65487] |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6285 +/- ##
=======================================
Coverage 99.70% 99.70%
=======================================
Files 444 444
Lines 42226 42234 +8
=======================================
+ Hits 42103 42111 +8
Misses 123 123 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
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, this seems helpful!
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
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, this looks good to me!
I guess we just need to ensure that the latest doc version is nice and clean 👍
Co-authored-by: Christina Lee <christina@xanadu.ai>
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
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.
🚀
Context:
We often make new, modified tapes in transforms, and occasionally an attribute of the old tape is not included. It can be unclear in some cases whether this was intentional or not. For example, in many transforms, we don't copy over
trainable_params
when making the new tape. It can be unclear whether this is because we are intending to settrainable_params
to the defaultNone
, or whether it's an oversight. We've also had at least one transform where we missed copyingshots
over until later.Description of the Change:
We add an
update
kwarg to thetape.copy
method that takes a dict with possible keysoperations
,measurements
,shots
and/ortrainable_params
. Passing a dict toupdate
changes the defined attributes while copying everything else over from the original tape.Benefits:
If we use this in transforms, we won't be able to forget to copy over tape attributes - and if we overwrite anything, it will be clearly intentional (i.e. we will have to explicitly pass
None
to theupdate
method instead of leaving the attribute out when creating a new tape).[sc-65487]