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

Bosonic engine results #546

Merged
merged 20 commits into from
Feb 26, 2021
Merged

Bosonic engine results #546

merged 20 commits into from
Feb 26, 2021

Conversation

elib20
Copy link
Collaborator

@elib20 elib20 commented Feb 23, 2021

Context: The bosonic backend is useful for simulating bosonic qubits.

Description of the Change:

  • Fixes multiple measurement shots for the bosonic backend
  • Raises error if symbolic non-Gaussian state prep is attempted in the bosonic backend
  • Creates the BosonicEngine class
  • Modifies the Results class to collect ancilla samples from measurement-based gates
  • Adds/Creates Integration tests

Benefits:
Running Programs on the bosonic backend from the frontend using an engine.

Possible Drawbacks:

Related GitHub Issues:

elib20 and others added 4 commits February 23, 2021 14:39
- Allows for multiple shots for measurements (new test)
- Raises an error if symbolic non-Gaussian state prep is attempted
Defines the BosonicEngine class

Co-Authored-By: ilan-tz <57886357+ilan-tz@users.noreply.github.com>
Co-Authored-By: Josh Izaac <josh@iza.ac>
Co-Authored-By: Nicolas Quesada <991946+nquesada@users.noreply.github.com>
Ancilla samples are produced by ancillary modes used for measurement-based gates
Updates/adds new integration tests to apply to the bosonic backend
@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

Merging #546 (4d1087b) into master (618f59a) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #546      +/-   ##
==========================================
+ Coverage   98.19%   98.22%   +0.03%     
==========================================
  Files          76       76              
  Lines        8329     8360      +31     
==========================================
+ Hits         8179     8212      +33     
+ Misses        150      148       -2     
Impacted Files Coverage Δ
strawberryfields/api/result.py 100.00% <100.00%> (ø)
...trawberryfields/backends/bosonicbackend/backend.py 100.00% <100.00%> (ø)
...ryfields/backends/bosonicbackend/bosoniccircuit.py 100.00% <100.00%> (ø)
strawberryfields/engine.py 96.36% <100.00%> (+0.22%) ⬆️
strawberryfields/backends/states.py 99.83% <0.00%> (+0.33%) ⬆️

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 618f59a...4d1087b. Read the comment docs.

Deletes the run method from the BosonicEngine, since it can be inherited from LocalEngine with a minimal change.
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

@elib20 Looking good, no major blockers! 👍 Left some questions and suggestions, curious to get those addressed and could go for another round.

strawberryfields/engine.py Outdated Show resolved Hide resolved
strawberryfields/api/result.py Show resolved Hide resolved
strawberryfields/backends/bosonicbackend/backend.py Outdated Show resolved Hide resolved
strawberryfields/backends/bosonicbackend/backend.py Outdated Show resolved Hide resolved
strawberryfields/engine.py Show resolved Hide resolved
strawberryfields/api/result.py Outdated Show resolved Hide resolved
tests/backend/test_bosonic_backend.py Show resolved Hide resolved
elib20 and others added 3 commits February 24, 2021 12:21
Co-authored-by: antalszava <antalszava@gmail.com>
- discovered and fixed bug in array dimension of returned samples
- makes tests more readable
- adds ancilla information to string of Results __repr__
- adds BosonicEngine to docs

Co-Authored-By: antalszava <24476053+antalszava@users.noreply.github.com>
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.

It's getting late, but I'll have another look tomorrow unless you've merged it already. Leaving the few comments I had so far. 💯

Co-Authored-By: Theodor <6934626+thisac@users.noreply.github.com>
Copy link
Contributor

@antalszava antalszava 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! 💪 🎊Amazing addition @elib20 @ilan-tz! 🙂

Left some comments, once they are addressed, the PR is merge-ready from my side.

strawberryfields/api/result.py Outdated Show resolved Hide resolved
tests/backend/test_bosonic_backend.py Show resolved Hide resolved
elib20 and others added 3 commits February 25, 2021 16:33
Co-authored-by: antalszava <antalszava@gmail.com>
Co-Authored-By: antalszava <24476053+antalszava@users.noreply.github.com>
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.

Looks great from my side as well. Don't forget to update the changelog, if you plan to do that in this PR. 🙂 💯

strawberryfields/engine.py Outdated Show resolved Hide resolved
tests/backend/test_bosonic_backend.py Show resolved Hide resolved
@@ -555,7 +679,6 @@ def test_Pgate_decomp_equal(self, setup_eng, s, tol):
eng.run(prog)
assert np.all(eng.backend.is_vacuum(tol))

@pytest.mark.backends("fock","tf","gaussian")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these removed since they run on all backends?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! The conftest file defaults to run tests on all backends.

@elib20 elib20 merged commit 33194f6 into master Feb 26, 2021
@elib20 elib20 deleted the bosonic-engine_results branch February 26, 2021 16:08
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.

5 participants