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

Create limited devices.qubit.simulate internal function #3700

Merged
merged 30 commits into from Feb 10, 2023
Merged

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Jan 30, 2023

Depends on #3683

This will be an internal function used by the next-generation Python device. The logic is extracted from the device to allow easy simulation of batches and the ability to distribute multiple simulations across different threads.

This first iteration will only support state-based measurement of observables with diagonalizing gates. Later PR's will add state-based measurements of observables with sparse or dense matrices and sample-based measurements.

This function will allow simultaneous measurement of non-commuting observables.

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.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.

@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Merging #3700 (7af3e07) into master (97aa355) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3700   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files         329      330    +1     
  Lines       28878    28909   +31     
=======================================
+ Hits        28827    28858   +31     
  Misses         51       51           
Impacted Files Coverage Δ
pennylane/devices/qubit/__init__.py 100.00% <100.00%> (ø)
pennylane/devices/qubit/apply_operation.py 100.00% <100.00%> (ø)
pennylane/devices/qubit/simulate.py 100.00% <100.00%> (ø)
pennylane/measurements/probs.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Base automatically changed from create-initial-state to master February 2, 2023 15:27
@albi3ro albi3ro added the review-ready 👌 PRs which are ready for review by someone from the core team. label Feb 9, 2023
Copy link
Collaborator

@AlbertMitjans AlbertMitjans left a comment

Choose a reason for hiding this comment

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

I love how the new device API is looking! 😍 🔥

Left some minor comments.

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
pennylane/devices/qubit/simulate.py Show resolved Hide resolved
pennylane/devices/qubit/simulate.py Show resolved Hide resolved
tests/devices/qubit/test_simulate.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/simulate.py Show resolved Hide resolved
tests/devices/qubit/test_simulate.py Outdated Show resolved Hide resolved
tests/devices/qubit/test_simulate.py Show resolved Hide resolved
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Looks good! The test suite is very comprehensive 😄 . I left some minor questions and comments.

pennylane/devices/qubit/simulate.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/simulate.py Show resolved Hide resolved
tests/devices/qubit/test_simulate.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/simulate.py Outdated Show resolved Hide resolved
Co-authored-by: Mudit Pandey <muditpandey2812@gmail.com>
Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

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

this looks good to me! just wondering: what was your motivation for putting measure in this file? every other aspect of this device has been fairly chunked up so it caught my eye, but it's all good in my books

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@AlbertMitjans AlbertMitjans left a comment

Choose a reason for hiding this comment

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

Looks good to me! 💯

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Nice work! 🎉

@albi3ro
Copy link
Contributor Author

albi3ro commented Feb 10, 2023

this looks good to me! just wondering: what was your motivation for putting measure in this file? every other aspect of this device has been fairly chunked up so it caught my eye, but it's all good in my books

Just because most of the "problem solving" is done by the measurement process. As the code for measuring gets more complicated, we can move it to another file.

@albi3ro albi3ro enabled auto-merge (squash) February 10, 2023 16:04
@albi3ro albi3ro merged commit 08511ea into master Feb 10, 2023
@albi3ro albi3ro deleted the qubit-simulate branch February 10, 2023 18:35
mudit2812 added a commit that referenced this pull request Apr 13, 2023
* add create_initial_state method to devices/qubit

* steal init docstring from Christina's PR

* fix default to output correct shape

* initialize simulate function

* fix toctree function name

* add basic execution and backpropogation tests

* default to numpy, cast wires to list before calling state_vector

* add more integration tests

* more tests

* move changelog entry to new device API section

* fix multiply jitting problem, remove like keyword

* Update pennylane/devices/qubit/__init__.py

* more tests and map wires

* qinfo tests for numpy and jax

* some more tests, docstrings

* black, remove type hint

* Apply suggestions from code review

Co-authored-by: Mudit Pandey <muditpandey2812@gmail.com>

* Update doc/releases/changelog-dev.md

Co-authored-by: Matthew Silverman <matthews@xanadu.ai>

* test clean

---------

Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Mudit Pandey <muditpandey2812@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants