Skip to content
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

Raise a UserWarning for a list of shots in Device.execute #1659

Merged
merged 7 commits into from
Sep 15, 2021

Conversation

antalszava
Copy link
Contributor

Adds a UserWarning to inform users that specifinyg the list of shots is only supported for QubitDevice based devices. See related comment here and the original PR: #1103

@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

❗ No coverage uploaded for pull request base (v0.18.0-rc0@3360fa5). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##             v0.18.0-rc0    #1659   +/-   ##
==============================================
  Coverage               ?   99.14%           
==============================================
  Files                  ?      197           
  Lines                  ?    14431           
  Branches               ?        0           
==============================================
  Hits                   ?    14307           
  Misses                 ?      124           
  Partials               ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3360fa5...de93444. Read the comment docs.

@antalszava
Copy link
Contributor Author

[ch7539]

Copy link
Contributor

@thisac thisac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @antalszava! Works for PL-SF as well, so that's good!

Comment on lines 410 to 414
if self._shot_vector is not None:
warnings.warn(
"Specifying a list of shots is only supported for"
"QubitDevice based devices. Falling back to executions using all shots in the shot list."
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this rely on QubitDevice never calling super().execute(...)? Could be worth adding a comment about that, so that it's clear why this doesn't affect all devices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Yep, for QubitDevice the execute method differs significantly from Device.execute. Let me add a comment.

pennylane/_device.py Outdated Show resolved Hide resolved
antalszava and others added 3 commits September 15, 2021 22:07
Co-authored-by: Theodor <theodor@xanadu.ai>
@antalszava antalszava merged commit 0e9cbdb into v0.18.0-rc0 Sep 15, 2021
@antalszava antalszava deleted the warn_shot_list_device branch September 15, 2021 20:21
josh146 added a commit that referenced this pull request Sep 20, 2021
* remove newlines in docstring (#1647)

* Fix bug in single-qubit decomposition edge case. (#1643)

* Fix bug in zyz decomposition and tidy tests.

* Update CHANGELOG.

* Tweak comments.

* Raise an error for `qml.sample` and `shots=None` in `default.qubit.jax` (#1629)

* deprecate qml.sample and shots=None for default.qubit.jax

* changelog

* formatting

* move shot adaptive test

* Streamline implementation and add matrix equivalence checks to tests.

* Update single qubit op tests.

Co-authored-by: Olivia Di Matteo <dimatteo.olivia@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>

* Fix bug when using Jax jit and `QubitStateVector` (#1649)

* Use numpy.

* Separate torch case.

* Update pennylane/devices/default_qubit.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Matplotlib circuit drawing (#1484)

* Raise a `UserWarning` for a list of shots in `Device.execute` (#1659)

* add warning for shot list in pure Device based devices; test for default.gaussian

* changelog

* PR number

* formatting

* comment

* Update pennylane/_device.py

Co-authored-by: Theodor <theodor@xanadu.ai>

* test message

Co-authored-by: Theodor <theodor@xanadu.ai>

* bugfix: raise mpl import error inside class initialization (#1667)

* mpldrawer when mpl not installed

* black

* bugfix for device shot list processing (#1666)

* fix process shots bug

* add tests and changelog

* docstrings and black

* add frob to list (#1664)

* Small change example. (#1669)

* Adds PennyLane-Lightning as a dependency (#1663)

* Add pl-lightning to requirements.txt and setup.py

* Add to requirements-ci.txt

* Temporarily add pybind11

* Update setup.py

* Add setup.py

* Add to changelog

* update changelog

* Update changelog

* Remove from requirements

* Does this fix?

* Revert

* New version

* Add diff method

* Add pennylane lightning pypi dep

* Update changelog

* Add simple test

* Remove adjoint

* Pin minimum version of lightning

* Emphasize as lightning.qubit

* Link to PL-Lightning release notes

* Update .github/CHANGELOG.md

* Update changelog

Co-authored-by: Lee J. O'Riordan <loriordan@gmail.com>

* tests/transforms/test_optimization/utils.py from rc

* tests/transforms/test_decompositions.py from rc

* Add shorter drawer example for the notes

* Add Hamiltonian expval(H) plot

* transforms test files

* updated example image

Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Romain <rmoyard@gmail.com>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Lee J. O'Riordan <loriordan@gmail.com>
antalszava added a commit that referenced this pull request Sep 21, 2021
* remove newlines in docstring (#1647)

* Fix bug in single-qubit decomposition edge case. (#1643)

* Fix bug in zyz decomposition and tidy tests.

* Update CHANGELOG.

* Tweak comments.

* Raise an error for `qml.sample` and `shots=None` in `default.qubit.jax` (#1629)

* deprecate qml.sample and shots=None for default.qubit.jax

* changelog

* formatting

* move shot adaptive test

* Streamline implementation and add matrix equivalence checks to tests.

* Update single qubit op tests.

Co-authored-by: Olivia Di Matteo <dimatteo.olivia@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>

* Fix bug when using Jax jit and `QubitStateVector` (#1649)

* Use numpy.

* Separate torch case.

* Update pennylane/devices/default_qubit.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Matplotlib circuit drawing (#1484)

* Raise a `UserWarning` for a list of shots in `Device.execute` (#1659)

* add warning for shot list in pure Device based devices; test for default.gaussian

* changelog

* PR number

* formatting

* comment

* Update pennylane/_device.py

Co-authored-by: Theodor <theodor@xanadu.ai>

* test message

Co-authored-by: Theodor <theodor@xanadu.ai>

* bugfix: raise mpl import error inside class initialization (#1667)

* mpldrawer when mpl not installed

* black

* bugfix for device shot list processing (#1666)

* fix process shots bug

* add tests and changelog

* docstrings and black

* add frob to list (#1664)

* Small change example. (#1669)

* Adds PennyLane-Lightning as a dependency (#1663)

* Add pl-lightning to requirements.txt and setup.py

* Add to requirements-ci.txt

* Temporarily add pybind11

* Update setup.py

* Add setup.py

* Add to changelog

* update changelog

* Update changelog

* Remove from requirements

* Does this fix?

* Revert

* New version

* Add diff method

* Add pennylane lightning pypi dep

* Update changelog

* Add simple test

* Remove adjoint

* Pin minimum version of lightning

* Emphasize as lightning.qubit

* Link to PL-Lightning release notes

* Update .github/CHANGELOG.md

* Update changelog

Co-authored-by: Lee J. O'Riordan <loriordan@gmail.com>

* Adjust Torch and TF backprop docstrings (#1662)

* error

* adjust TF docstring

* Diff option backprop check rc (#1658)

* update the condition for backprop diff

* add test and readjust the other test

* formatting

* diff_method='parameter-shift' for default.tensor.tf

* format tests

* Update pennylane/qnode.py

Co-authored-by: Romain <rmoyard@gmail.com>

Co-authored-by: Romain <rmoyard@gmail.com>

* V0.18.0 release notes (#1656)

* version bump

* group entries

* update the descriptions

* torch example

* contributors

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* format lines

* num

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* move q transforms

* trainable coeffs

* SISWAP adjust

* Add link to changelog

* Fix merge

* SISWAP move to improvements

* drawer example

* remove item on separate requirements file

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* QFT move

* further suggestions

* NumPy

* draw example

* no grad call for finite_diff qml.gradients

* no grad call for param_shift

* lightning

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Hamiltonian + its plot

* Hamiltonian param shift move

* bug fix phrasing

* contributors list

* Lightning adjoint plot & description

* Hamiltonian plot width

* align mid

* Revert "align mid"

This reverts commit 9b8d354.

Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Romain <rmoyard@gmail.com>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Lee J. O'Riordan <loriordan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants