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

Update plugin by removing analytic argument for device creation #93

Merged
merged 14 commits into from
Apr 14, 2021

Conversation

antalszava
Copy link
Contributor

@antalszava antalszava commented Mar 27, 2021

Updates the plugin to cope with removing the analytic keyword argument as per PennyLaneAI/pennylane#1079.

@codecov
Copy link

codecov bot commented Mar 27, 2021

Codecov Report

Merging #93 (b89bf0a) into master (9a0305c) will not change coverage.
The diff coverage is 100.00%.

❗ Current head b89bf0a differs from pull request most recent head 8a6182a. Consider uploading reports for the commit 8a6182a to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master      #93   +/-   ##
=======================================
  Coverage   98.14%   98.14%           
=======================================
  Files           3        3           
  Lines          54       54           
=======================================
  Hits           53       53           
  Misses          1        1           
Impacted Files Coverage Δ
pennylane_lightning/_version.py 100.00% <100.00%> (ø)
pennylane_lightning/lightning_qubit.py 97.95% <100.00%> (ø)

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 9a0305c...8a6182a. Read the comment docs.

@antalszava antalszava requested review from trbromley and thisac April 1, 2021 12:58
@josh146
Copy link
Member

josh146 commented Apr 12, 2021

@thisac @trbromley just a reminder to review this one!

Copy link

@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 good! Just one question: are the PL device tests updated as well, and should then the line pl-device-test --device lightning.qubit --analytic False --skip-ops --shots=20000 in build.yml be changed here?

@@ -1,6 +1,6 @@
flaky
numpy
pennylane>=0.12
git+https://github.com/PennyLaneAI/pennylane.git
Copy link

Choose a reason for hiding this comment

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

Do we want to wait until after release before merging this (and then update the requirements to the latest release instead)?

Copy link
Member

Choose a reason for hiding this comment

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

In the past we have, but we have so many plugins now, I think it is better to merge it as-is (and simply replace it with pennylane>=0.15 once it is on PyPI).

By merging it in now, we can:

  • Have its entry in the test matrix turn green,
  • Keep track of it breaking (again!) between now and release :)

Copy link
Contributor

@trbromley trbromley 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! I had a few questions/comments, but otherwise looking good!

pennylane_lightning/lightning_qubit.py Outdated Show resolved Hide resolved
@@ -1135,7 +1134,7 @@ class TestTensorSample:

def test_paulix_pauliy(self, theta, phi, varphi, monkeypatch, tol):
"""Test that a tensor product involving PauliX and PauliY works correctly"""
dev = qml.device("lightning.qubit", wires=3, shots=10000)
dev = qml.device("lightning.qubit", wires=3, shots=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this one need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we implicitly had analytic=True before

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 This one's still not clear to me - so before we had analytic=True and shots=10000. In the test, we call dev.sample() so it would have generated 10000 samples, yet these samples were not used in dev.probability() because we were in analytic mode?

So perhaps the test didn't need to set shots or call dev.sample()?

Would this just work if we had a parametrize over shots, setting [None, 10000], so we test both analytic and non-analytic cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, changed this. Also removed the calls to dev.sample.

@@ -30,7 +30,7 @@


@pytest.mark.parametrize("theta, phi", list(zip(THETA, PHI)))
@pytest.mark.parametrize("shots", [8192])
@pytest.mark.parametrize("shots", [None])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do these ones need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, do you agree that the shots fixture is not actively used in any of the tests below? 😕 Unless it's hidden somewhere in a fixture. So we could set to any value.

In which case, ideally we would remove the paramtrize and shots argument. But ok for this PR if we want to just change to None as you have done 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, removed it

@@ -30,13 +30,13 @@


@pytest.mark.parametrize("theta, phi", list(zip(THETA, PHI)))
@pytest.mark.parametrize("shots", [8192])
@pytest.mark.parametrize("shots", [None])
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to parametrize over None (which is the default)?

Copy link
Contributor Author

@antalszava antalszava Apr 13, 2021

Choose a reason for hiding this comment

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

No, but in this PR rather changed the analytic argument rather than adjusted how the testing is done

@antalszava antalszava requested a review from trbromley April 13, 2021 19:00
@antalszava
Copy link
Contributor Author

Thanks for the comments and the catches! Updated the PR

Copy link
Contributor

@trbromley trbromley 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! Looks close to ✔️, I just had a few final questions.

@@ -1135,7 +1134,7 @@ class TestTensorSample:

def test_paulix_pauliy(self, theta, phi, varphi, monkeypatch, tol):
"""Test that a tensor product involving PauliX and PauliY works correctly"""
dev = qml.device("lightning.qubit", wires=3, shots=10000)
dev = qml.device("lightning.qubit", wires=3, shots=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 This one's still not clear to me - so before we had analytic=True and shots=10000. In the test, we call dev.sample() so it would have generated 10000 samples, yet these samples were not used in dev.probability() because we were in analytic mode?

So perhaps the test didn't need to set shots or call dev.sample()?

Would this just work if we had a parametrize over shots, setting [None, 10000], so we test both analytic and non-analytic cases?

@@ -30,7 +30,7 @@


@pytest.mark.parametrize("theta, phi", list(zip(THETA, PHI)))
@pytest.mark.parametrize("shots", [8192])
@pytest.mark.parametrize("shots", [None])
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, do you agree that the shots fixture is not actively used in any of the tests below? 😕 Unless it's hidden somewhere in a fixture. So we could set to any value.

In which case, ideally we would remove the paramtrize and shots argument. But ok for this PR if we want to just change to None as you have done 👍

@antalszava antalszava requested a review from trbromley April 14, 2021 13:48
Copy link
Contributor

@trbromley trbromley 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 for accommodating those suggestions! 💯

@antalszava antalszava merged commit 0064c24 into master Apr 14, 2021
@antalszava antalszava deleted the no_analytic_kwarg branch April 14, 2021 14:36
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