Closed josh146 closed 2 years ago
I am interested in working on this issue, but I am a total beginner, could you point me towards some resources to get started?
Pinging @josh146 for suggestions of resources for @Hannibalcarthaga :)
Hi @Hannibalcarthaga, fantastic!
Are you looking mainly for resources on the coding side, or more to understand the concepts behind this change? For what is required on the coding side, @nquesada might be able to provide a list of steps that need to be undertaken for the PR :)
@josh146 and @nquesada I am primarily looking for resources for coding, and would like to refer to some regarding the concept as well. Thanks.
I am mostly referring to the Development guide in the Strawberry Fields documentation and the tutorials.
No worries @Hannibalcarthaga! As you note, the best place for details on SF documentation is the Strawberry Fields development guide. This guide has details on:
Cloning and installing the development version of Strawberry Fields:
git clone https://github.com/XanaduAI/strawberryfields
cd strawberryfields
pip install -e .
How to run the tests, and add new tests to SF. Strawberry Fields uses PyTest for writing and running its test suite.
Finally, it also provides a step-by-step guide to submitting a pull request: https://strawberryfields.readthedocs.io/en/stable/development/development_guide.html#submitting-a-pull-request
I hope that helps @Hannibalcarthaga! Let me know if there is anything missing that I can help you with.
Hi, @josh146 , I have modified the Gaussian backend as per thewalrus._torontonian source code, but running the pytest generates an error regarding the frontend (Quanta) sarang@sarang-Inspiron-3521:~/strawberryfields$ pytest ============================= test session starts ============================== platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 Using --randomly-seed=3026692562 rootdir: /home/sarang/strawberryfields plugins: randomly-3.8.0, cov-2.12.0, mock-3.6.1 collected 12345 items / 1 error / 12344 selected
==================================== ERRORS ====================================
___ ERROR collecting tests/frontend/test_sf_plot.py ____
ImportError while importing test module '/home/sarang/strawberryfields/tests/frontend/test_sf_plot.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/envs/Quanta/lib/python3.8/importlib/init.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/frontend/test_sf_plot.py:19: in
Hi @Hannibalcarthaga, you will need to install plotly :)
pip install plotly
@josh146 thanks, that issue is resolved, so I ran the tests again. During the "pytest -m gaussian" I got the following six errors FAILED tests/backend/test_threshold_measurement.py::TestRepresentationIndependent::test_two_mode_squeezed_measurements[GaussianBackend-False] FAILED tests/backend/test_threshold_measurement.py::TestRepresentationIndependent::test_vacuum_measurements[GaussianBackend-True] FAILED tests/backend/test_threshold_measurement.py::TestRepresentationIndependent::test_binary_outcome[GaussianBackend-True] FAILED tests/backend/test_threshold_measurement.py::TestRepresentationIndependent::test_two_mode_squeezed_measurements[GaussianBackend-True] FAILED tests/backend/test_threshold_measurement.py::TestRepresentationIndependent::test_vacuum_measurements[GaussianBackend-False] FAILED tests/backend/test_threshold_measurement.py::TestRepresentationIndependent::test_binary_outcome[GaussianBackend-False] Does this mean I have to modify the test_threshold_measurement.py similar to the backend.py? P.S. Apologies for spamming.
Hi @Hannibalcarthaga --- It does seem like the test are failing after your modifications. Could you post what the first error is saying? To run the tests specific to threshold detection you could run them by typing pytest tests/backend/test_threshold_measurement.py
Hi, @nquesada here is the error
=================================== FAILURES ===================================
_ TestRepresentationIndependent.test_vacuum_measurements[GaussianBackend-False] _
self = <test_threshold_measurement.TestRepresentationIndependent object at 0x7fa0bcd2da00>
setup_backend = <function setup_backend.<locals>._setup_backend at 0x7fa0bcd695e0>
pure = False
def test_vacuum_measurements(self, setup_backend, pure):
"""Tests Threshold measurement on the vacuum state."""
backend = setup_backend(3)
for _ in range(NUM_REPEATS):
backend.reset(pure=pure)
> meas = backend.threshold_detection_prob_displacement(mu, cov, det_pattern, hbar)
E NameError: name 'mu' is not defined
it seems like you are calling a variable, mu
, which you have not defined.
Hi, @nquesada , I am getting confused in the TestRepresentationIndependent class. The name error mu is the defined parameter in the threshold_detection_prob_displacement as per theWalrus. So when I called the threshold backend in the above mentioned class the argument mu gave an error. Is there a specific way to call the backends of (test_two_mode_squeezed_measurements, vacuum_measurements and the binary_outcomes)? Could you point me towards any documentations?
Hi @Hannibalcarthaga I recommend opening a work-in-progress pull request 🙂 Even though it's not complete and still needs more work to get the tests passing, by having a PR open, @nquesada and I (and the rest of the Strawberry Fields team) will be able to have a look at your code, and provide more specific technical help.
Hi @Hannibalcarthaga I recommend opening a work-in-progress pull request
@josh146 Hi, could you guide me here? I have forked the repository but am having a little trouble making the pull request.
Hi @Hannibalcarthaga : you can find an easy to follow guide on "Creating a pull request from a fork" in the github documentation here: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork
@josh146 Hi, I have made a PR, but I am not able to run the make docs test. With pip install -rdoc/requirements.txt command it starts installation of tensorflow. It is a very large file and my connection is not stable to install it. Any suggestions on how to resolve this?
Hi @Hannibalcarthaga, there could be two ways to aid your problem:
requirements.txt
file, care should be taken to undo the changes without committing them. There might be, however, parts of the docs that rely on TensorFlow which might result in errors.
This issue has been tagged for contributions during unitaryHACK
When using the Gaussian backend, the
MeasureThreshold
measurement operation is currently not allowed if the state has displacement (that is, the Gaussian state has a non-zero mean):https://github.com/XanaduAI/strawberryfields/blob/adb0f9919decc3a6544ddae26eb98c1afb76f7c8/strawberryfields/backends/gaussianbackend/backend.py#L262
This is because this functionality depends on the
torontonian_sample_state
function from The Walrus, which (at the time) did not support passing in a means vector.However, a recent addition to The Walrus added in this functionality via the new function
threshold_detection_prob
. It would be great to modify the Gaussian backend to support threshold detection of Gaussian states with displacement using this new functionality.