-
Notifications
You must be signed in to change notification settings - Fork 192
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
Additional memory creation from partial trace during measurements #464
Comments
Copied from here:
|
From previous discussions: the density matrix is computed because:
It may be possible to avoid the density matrix computation altogether, by being clever with how the expectation values are computed in the Fock basis. |
hello back here :) I thought that I could be more specific than in my previous comment by adding some snippet code to explain what I tried. In the BaseFockState constructor (strawberryfields/backends/states.py), I added:
and changed the dm method to:
I agree that this is not ideal, but it prevents the self.dm() to reconstruct the density matrix if it has already been computed during a previous call. From what I see in PennyLane-SF, this could actually work because self.state is reset at each execute call of the device (in class Device of pennylane/_device.py) in the pre_measure method (PennyLane_sf/fock.py):
This said, I see that dm() is also called in various other methods, and this change in the code might not be without consequences for other usages than with the pennylane-sf plugin. |
Thanks for your thoughts @MichelNowak1! As you've suggested, one possible solution would be to cache calls to I'm thinking there are two alternative, but still reasonable, solutions here:
|
Thanks @co9olguy! It almost sounds like we should be working towards implementing both solutions (they don't seem to be mutually exclusive) |
First reported in PennyLaneAI/pennylane#842, we've now determined that this is a SF-specific issue.
The text was updated successfully, but these errors were encountered: