-
Notifications
You must be signed in to change notification settings - Fork 10
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 |
abs(mpo_expectation.imag), | ||
rtol=1e-05, | ||
atol=1e-08, | ||
) |
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.
Shouldn't the expectation values be the same? Why do you only compare the absolute values of the real and imaginary parts?
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, I also think that the expectation values should be the same. The diagonal matrix elements are exactly the same. For the off-diagonal matrix elements, sometimes there is a minus sign for either the real or imaginary part. I tried tinkering with the Hamiltonian to fix this, however I really don't understand why this is... 😕 If you have any ideas, please do let me know. I was planning to get back to it this week.
# 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.
The aims for this pull request: