-
Notifications
You must be signed in to change notification settings - Fork 40
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
Move functions to base class #841
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #841 +/- ##
==========================================
- Coverage 98.42% 92.33% -6.10%
==========================================
Files 116 70 -46
Lines 18660 11211 -7449
==========================================
- Hits 18367 10352 -8015
- Misses 293 859 +566 ☔ View full report in Codecov by Sentry. |
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Show resolved
Hide resolved
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.
@erick-xanadu What was the issue with adding these methods to StateVectorLQubitDynamic
? Any plan to get this support for LK in a followup 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.
The StateVectorLQubit has no explicit storage data type.
It might be tricky moving it here, or even unsafe.
@maliasadi The idea was to reuse code. So moving these to the base class is only for increasing code reuse. LK's implementation is already in the base class. |
@AmintorDusko Happy to close this ticket then. I'll leave it up for a bit of further discussion. The disadvantage is that we would copy these methods over. Right now for example, I am working on other two methods that will call these methods. And that means we would also have to copy these over in Catalyst. |
@AmintorDusko alternatively, there could be another class between these two that implement these methods and Lightning Dynamic inherits from that one. Not sure how that would impact performance though. I know there is some static devirtualization being done through templates. |
What is preventing us from getting a pointer to the data and modifying it? All the gates are applied in this way already, so isn't it natural to do the StatePrep similarly? |
Hey @erick-xanadu, feel free to proceed and get the team's opinion on that. |
Nothing. See my comment addressing Eric. |
@AmintorDusko , added extra checks here: 7ddcc06 |
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
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.
A couple suggestions, but I think it will be ready to merge after.
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
…ectorLQubit.hpp Co-authored-by: Vincent Michaud-Rioux <[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.
LGTM, thanks @erick-xanadu . Feel free to merge once the CI is green (I think you'll need to run make format
).
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
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 @erick-xanadu! 🙌 Happy to approve after resolving my comment for setStateVector
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Show resolved
Hide resolved
…ectorLQubit.hpp Co-authored-by: Ali Asadi <[email protected]>
Context: Some of these functions are needed in Catalyst. Since Catalyst does not use LM, but instead uses LightningDynamic, the least upper bound in the class hierarchy is
StateVectorLQubit
.Description of the Change: Move these functions to
StateVetctorLQubit
.Benefits: Code-reuse
Possible Drawbacks:
Related GitHub Issues: