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

Shot batching is made more efficient by executing all the shots in one go on Lightning Qubit #814

Merged
merged 8 commits into from
Jul 25, 2024

Conversation

maliasadi
Copy link
Member

@maliasadi maliasadi commented Jul 24, 2024

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
Shot batching is made more efficient by executing all the shots in one go on LightningQubit using shots.bin.

Description of the Change:

  • Update _measure_with_samples_diagonalizing_gates
  • Add shots_vector tests.

Benefits:

dev = qml.device('lightning.qubit', wires=20, shots=(10_000, ) * N)
for i in range(1000):
    @qml.qnode(dev)
    def circuit():
        return qml.counts(wires=0)

image
image

dev = qml.device('lightning.qubit', wires=20, shots=(10, ) * N)
for i in range(1000):
    @qml.qnode(dev)
    def circuit():
        return qml.counts(wires=0)

image
image

Possible Drawbacks:
n/a

Related GitHub Issues:

[sc-66537]

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.63%. Comparing base (073395b) to head (c0fdffa).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #814      +/-   ##
==========================================
- Coverage   98.57%   93.63%   -4.94%     
==========================================
  Files         114       17      -97     
  Lines       18069     1902   -16167     
==========================================
- Hits        17812     1781   -16031     
+ Misses        257      121     -136     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maliasadi maliasadi requested a review from a team July 24, 2024 21:28
Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Thanks @maliasadi ! Nice work!

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

Thanks @maliasadi , LGTM. A few suggestions and then I'm ready to approve. Nice speed-ups for shot-vectors (thinking about it, I think I'd prefer speed-up plots instead of the time vs. XXX above; no need to change it here though).

.github/CHANGELOG.md Outdated Show resolved Hide resolved
pennylane_lightning/lightning_qubit/_measurements.py Outdated Show resolved Hide resolved
tests/test_measurements.py Outdated Show resolved Hide resolved
maliasadi and others added 2 commits July 25, 2024 09:20
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

Code reduction, good speed-ups, nice PR @maliasadi !

Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @maliasadi !

.github/CHANGELOG.md Outdated Show resolved Hide resolved
@maliasadi maliasadi merged commit d1b4007 into master Jul 25, 2024
74 of 75 checks passed
@maliasadi maliasadi deleted the use_shots_bin branch July 25, 2024 16:03
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.

4 participants