OQuPy icon indicating copy to clipboard operation
OQuPy copied to clipboard

Use a stable SVD function call

Open NominHanggai opened this issue 2 years ago • 4 comments

Hi OQuPy developers,

The SVD call in OQuPy fails occasionally. Is it possible for users to configure OQuPy so that it uses a stable SVD function?

Best, Mulliken

NominHanggai avatar May 06 '22 10:05 NominHanggai

Hi @Mulliken, Thank you for the question. As you might be aware, we are using the google/TensorNetwork package as a backend. If the SVD fail you are seeing is similar to my occasional experience then I believe this should be related to this issue: https://github.com/google/TensorNetwork/issues/896. The problem most likely lies with the gesdd function in LAPACK and a common workaround is to default back to gesvd if gesdd fails: https://tenpy.readthedocs.io/en/v0.5.0/_modules/tenpy/linalg/svd_robust.html

I will chase this up with the google/TensorNetwork people to see if there is either a newer version which has that fail save built in or if it could be added. If not, then we might be forced to depend on our own fork of google/TensorNetwork which I'd like to avoid for a ton of reasons. I'll get back to you sometime next week on this. Best, ~gefux

gefux avatar May 07 '22 16:05 gefux

Thanks for the reply! It will be great if the problem can be solved on the google/TensorNetwork side!

NominHanggai avatar May 07 '22 18:05 NominHanggai

Hi. I've created a pull request https://github.com/google/TensorNetwork/pull/962 with google/TensorNetwork a few days ago.

If you'd like to try a quick-fix you could simply change a few lines your installed TensorNetwork package. The error message should somewhere point you to %somewhere-on-your-computer%/tensornetwork/backends/numpy/decompositions.py. You could try to change a few lines as described here and see if it fixes your problem. (Be aware that you might have to reinstall tensornetwork if something goes wrong!) In case you decide to give this a try I'd be keen to hear if it fixed your problem. Also, it would be great if you could share a minimal failing example at some point.

Best, ~gefux

gefux avatar May 13 '22 09:05 gefux

Thanks for the solution, gefux!! I will attach a minimal failing example later.

NominHanggai avatar May 13 '22 20:05 NominHanggai