-
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
Support arbitrary controlled operations in lightning.qubit #516
Support arbitrary controlled operations in lightning.qubit #516
Conversation
Co-authored-by: Amintor Dusko <[email protected]>
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #516 +/- ##
==========================================
+ Coverage 99.02% 99.09% +0.06%
==========================================
Files 168 201 +33
Lines 23235 29202 +5967
==========================================
+ Hits 23009 28937 +5928
- Misses 226 265 +39 ☔ View full report in Codecov by Sentry. |
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.
Nice job here! I left some comments and suggestions, but I think this is in very good shape.
pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp
Outdated
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
…VectorKokkos.hpp [skip ci] Co-authored-by: Amintor Dusko <[email protected]>
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 to me! Thanks @vincentmr for the nice work!
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.
Nothing more to add! Great work!
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:
Applying a gate such as
qml.ControlledQubitUnitary(U, control_wires=range(5), wires=[5])
should be quite fast compared withqml.QubitUnitary(U, wires=range(6))
because the first requires applying a2x2
matrix to 1/32th of all state vector entries and the second applying a64x64
matrix to all entries. This also provides less control over the parametrization ofU
, which can be handy in adjoint-diff implementations.Description of the Change:
Introduce three new kind of gates: controlled gates, controlled generators and controlled matrix ops. The new gates are analogous to the current gates, generators and matrix ops. The new gates accept arbitrary controls, for example
LM::NCMultiQubitOp
takes instd::vector<std::size_t> &controlled_wires
in addition to the usual input of the other kernels. This extra input required modifying the dispatcher and all related definitions. The adjoint-diff classes also need to carrycontrolled_wires
around. All new gate kernels are implemented inGateImplementationsLM.hpp
. The Python layer also differentiate betweenControlledQubitUnitary
operations and others for now.Benefits:
Possible Drawbacks:
Some gates might be slower, but benchmarks show that this is likely limited. For example, all non-controlled 1-qubit gates have the same performance.
Related GitHub Issues: