-
Notifications
You must be signed in to change notification settings - Fork 12
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
MPS emulator for LUCJ circuits #334
base: main
Are you sure you want to change the base?
Conversation
Note that by default, i.e. after running I think that this issue transcends tenpy and becomes a more general question of whether or not to link numpy/scipy against MKL, which is a matter of personal preference. Therefore, I suggest that we leave this as is. |
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.
Thank you Bart! I'll begin with some high-level comments that will involve some code restructuring.
Thank you for reviewing this! 😃 I will implement these changes asap |
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
"""Tests for the TeNPy basic gates.""" |
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 see that in the gate tests, you do the following:
- Apply the gate to a product state as a state vector
- Apply the gate to a product state as an MPS
- Check that the expectation value on a molecular Hamiltonian matches in both cases.
Is it possible to retrieve the state vector amplitudes from the MPS? If so, then we don't need to introduce a Hamiltonian. We can just directly check that amplitudes stored by the MPS match the exact ones.
Another question is whether we can apply the evolution not to a product state, but to a random state instead. The basic gates often have trivial action on a product state. For example, applying a Givens rotation between two occupied orbitals doesn't do anything.
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.
It is possible to convert an MPS to statevector using the mps_to_full function. Yes, I agree that we should remove the MolecularHamiltonian from these gate tests, and keep the tests for the molecular Hamiltonian separate.
Generating a completely random MPS is non-trivial, since a generic random state from Hilbert space will have volume law entanglement, whereas MPS are good at representing states with area law entanglement. I presume that you mean a completely random state, and not just a random product state? One solution is to start with a random product state and then perform a TEBD RandomUnitaryEvolution to introduce some short-range entanglement. This will not result in a completely random state but it will be entangled to as much as the computational cost / bond dimension will allow.
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 uniformly random state would be ideal, but perhaps unnecessary. We should be able to represent such a state for small test sizes though, right? You can generate a uniformly random state vector using ffsim.random.random_state_vector
. Is it possible to convert such a state vector into an MPS using Tenpy? Otherwise, I think your idea of generating a random evolution should be fine.
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.
Yes, for small system sizes you may be able to convert a completely random statevector into an MPS using the full_to_mps function. However, the bond dimension will blow up quite quickly. I will try this in the first instance and if it's not tractable, I will try the random unitary evolution approach.
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.
Another thought on this, currently we have a bitstring_to_mps
utility function that can convert a product state into an MPS. If we have an arbitrary state in ffsim, which is some superposition of bitstrings, perhaps we can construct the corresponding MPS by reading off the amplitudes and then using the MPS.add function? I am imagining something like a state_to_mps
function, which is higher level than bitstring_to_mps
. This may be easier than trying to decipher TeNPy's internal functions.
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, that sounds fine with me. Is the full_to_mps
function not suitable for this task?
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.
It may be... I will check what works best
The aims for this pull request: