-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fix Lightning fallbacks to support PL 0.29 changes #416
Conversation
…o C++ supported ops
…tions due to differences in chosen basis
Codecov Report
@@ Coverage Diff @@
## master #416 +/- ##
==========================================
- Coverage 99.88% 99.82% -0.07%
==========================================
Files 49 49
Lines 4505 4517 +12
==========================================
+ Hits 4500 4509 +9
- Misses 5 8 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
Great work, thanks!
I just made some suggestions, but I'm happy to approve.
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
…ane-lightning into fix_sparse_wire_order
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.
I opened #419 (against this branch) to add more test cases to verify my latest comment. I think they wouldn't hurt to add, but this looks good to me either way. In other words, the tests are there should you want them - take em or leave em.
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.
I'm not sure I understand properly what is being compared, so I left a comment about this line
(not np.all(list(wires)[:-1] <= list(wires)[1:]))
Otherwise, looks good! Thanks.
Before submitting
Please complete the following checklist when submitting a PR:
All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to the
tests
directory!All new functions and code must be clearly commented and documented.
If you do make documentation changes, make sure that the docs build and
render correctly by running
make docs
.Ensure that the test suite passes, by running
make test
.Add a new entry to the
.github/CHANGELOG.md
file, summarizing thechange, and including a link back to the PR.
Ensure that code is properly formatted by running
make format
.When all the above are checked, delete everything above the dashed
line and fill in the pull request template.
Context: PR PennyLaneAI/pennylane#3585 updated how wires were handled for SparseHamiltonian types, where situations of device wires being different to operator wires required a reordering. The assumptions made in Lightning were that operator and device wires were always the same and in the same specific order --- this change broke that assumption. As such, when the two diverge Lightning does not apply the correct values to the appropriate locations.
In addition, due to the changes, fallback functionality in Lightning for non-CPP supported observables werre offloaded to
_qubit_device
with different assumptions made about the bases of said observables. In this case, where _qubit_device required the application of diagonalizing gate, Lightning by default did not, and so the results were inconsistent for said observables. This PR ensure all observable variants for prob, expval and var are offloaded to C++ functions where applicable, and raises an error where functionality support does not currently exist, rather than allowing the return of incorrect results.Description of the Change: Update wire ordering of sparse matrix defined from Hamiltonian to be reflective of matching device and operator order. Ensure appropriate fallbacks are avoided, instead favouring C++ operations. Ensure error raised when attempting out of order wires for probs.
Benefits: Fixes edge case where the sparse matrix applied is not correct.
Possible Drawbacks:
Related GitHub Issues: