-
Notifications
You must be signed in to change notification settings - Fork 604
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
Move to specify shots on the QNode #4375
Conversation
Hello. You may have forgotten to update the changelog!
|
[sc-41930] |
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 @albi3ro , I left some wording suggestions.
@@ -305,6 +305,12 @@ def run_cnot(): | |||
if name in plugin_devices: | |||
options = {} | |||
|
|||
if "shots" in kwargs: | |||
warnings.warn( | |||
"In v0.33, the shots will always be determined by the QNode. Please specify shots there.", |
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.
Could we say "Please specify shots either at QNode instantiation or when calling your QNode."
@@ -305,6 +305,12 @@ def run_cnot(): | |||
if name in plugin_devices: | |||
options = {} | |||
|
|||
if "shots" in kwargs: | |||
warnings.warn( | |||
"In v0.33, the shots will always be determined by the QNode. Please specify shots there.", |
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.
And maybe "You have provided a shots argument to a device. In v0.33, ..."
Just so it's immediately clear to users what they've done wrong.
and shots is None | ||
): | ||
warnings.warn( | ||
"Shots should now be specified on the qnode instead of on the device." |
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.
"Shots should now be specified on the qnode instead of on the device." | |
"The shots value you provided to the device does not match the value provided to the QNode." |
): | ||
warnings.warn( | ||
"Shots should now be specified on the qnode instead of on the device." | ||
"Using shots from the device. QNode specified shots will be used in v0.33." |
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.
"Using shots from the device. QNode specified shots will be used in v0.33." | |
"Using shots from the device. QNode specified shots will be used in v0.33 " | |
"and shots will no longer be permitted as a device argument." |
Closed in favor of #4388 |
We are moving to define shots as part of what we execute, not necessarily how we execute it.
We already:
QNode
override_shots
to be provided toqml.execute
QuantumTape
QuantumTape
in the new device API.These changes will allow us to have better shot distribution within batches, since each tape in a batch will be able to have a separate shot number.
This will also help PennyLane become more functional, since we will not be needing to constantly mutate the device in order to support per-call dynamic shots.
Since these warnings are inside the
QNode
and theqml.device
constructor, no changes are currently necessary for plugins other than updated tests and documentation.Example behaviour for deprecation cycle
Don't specify shots on device? No warning
Manually specify shots on device? Warning
Don't specify shots on either device or qnode? No warning
Specify shots on device but not qnode?
warning, and make qnode shots equal to device shots
Shots not none on qnode? no warning when creating the qnode, but there is a warning when putting on them on the device still.