-
Notifications
You must be signed in to change notification settings - Fork 585
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
Update shot_adaptive to not mutate device shots #4599
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4599 +/- ##
==========================================
- Coverage 99.64% 99.64% -0.01%
==========================================
Files 375 375
Lines 33358 33342 -16
==========================================
- Hits 33239 33222 -17
- Misses 119 120 +1
☔ View full report in Codecov by Sentry. |
[sc-44399] |
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.
Looks good. Thanks!
**Context:** `shot_adaptive.py` would change device wires, run a QNode with the device, then change the wires back. We can just run the QNode with different shots without changing the device! **Description of the Change:** Instead of changing device shots, pass `shots=new_shots` as a kwarg to any QNode execution. I also removed a silly test for something hacky that users probably should not even be able to do... it's not that hard to add `@qml.qnode(qml.device("default.qubit", shots=1000))` to the top of any function : ) **Benefits:** - It will work on the new device API without any changes (I ran the tests locally with DQ2, worked perfectly) - No more unnecessary try-finally blocks - Not mutating object properties is always cool and wise
Context:
shot_adaptive.py
would change device wires, run a QNode with the device, then change the wires back. We can just run the QNode with different shots without changing the device!Description of the Change:
Instead of changing device shots, pass
shots=new_shots
as a kwarg to any QNode execution.I also removed a silly test for something hacky that users probably should not even be able to do... it's not that hard to add
@qml.qnode(qml.device("default.qubit", shots=1000))
to the top of any function : )Benefits: