-
Notifications
You must be signed in to change notification settings - Fork 41
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #93 +/- ##
=======================================
Coverage 98.14% 98.14%
=======================================
Files 3 3
Lines 54 54
=======================================
Hits 53 53
Misses 1 1
Continue to review full report at Codecov.
|
@thisac @trbromley just a reminder to review this one! |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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!
tests/test_apply.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
tests/test_expval.py
Outdated
@@ -30,7 +30,7 @@ | |||
|
|||
|
|||
@pytest.mark.parametrize("theta, phi", list(zip(THETA, PHI))) | |||
@pytest.mark.parametrize("shots", [8192]) | |||
@pytest.mark.parametrize("shots", [None]) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, removed it
tests/test_var.py
Outdated
@@ -30,13 +30,13 @@ | |||
|
|||
|
|||
@pytest.mark.parametrize("theta, phi", list(zip(THETA, PHI))) | |||
@pytest.mark.parametrize("shots", [8192]) | |||
@pytest.mark.parametrize("shots", [None]) |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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
Co-authored-by: Tom Bromley <[email protected]>
…lightning into no_analytic_kwarg
Thanks for the comments and the catches! Updated the PR |
There was a problem hiding this 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.
tests/test_apply.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
tests/test_expval.py
Outdated
@@ -30,7 +30,7 @@ | |||
|
|||
|
|||
@pytest.mark.parametrize("theta, phi", list(zip(THETA, PHI))) | |||
@pytest.mark.parametrize("shots", [8192]) | |||
@pytest.mark.parametrize("shots", [None]) |
There was a problem hiding this comment.
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 👍
There was a problem hiding this 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! 💯
Updates the plugin to cope with removing the
analytic
keyword argument as per PennyLaneAI/pennylane#1079.