jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
467 stars 107 forks source link

Implement simple symmetry #95

Closed xiangjianqian closed 2 years ago

xiangjianqian commented 2 years ago

Can anyone show me an example of how to implement a library https://github.com/mhauru/abeliantensors with Quimb. Is it compatible with opt_einsum.

jcmgray commented 2 years ago

I suspect it's not directly compatible right now, but would be very easy to incorporate as it supports all the core functions. The main thing is simply that the .shape attribute returns blocks rather than the 'effective' tensor shape, and its tensordot, svd implementations and friends might not be immediately discoverable by opt_einsum / autoray. To use it probably one would want to simply subclass whichever symmetry tensor class and override the shape attribute, then register backend functions with opt_einsum / autoray for the desired functions.

There might still be some issues if you need compression with cutoffs and that kind of thing however.

Note also that another symmetric backend will be available at some point as a byproduct of https://github.com/jcmgray/quimb/pull/88.

xiangjianqian commented 2 years ago

Actually, The Tensor Network library https://github.com/google/TensorNetwork has a simple symmetry backend. And it has the .shape attribute that returns the acutal tensor shape. It also has tensordot,svd functions. I think it would be much easier to implement.

jcmgray commented 2 years ago

Yes, though worth noting that the data structure they chose is quite different to abeliantensors I think, and might perform quite differently across settings. If I recall, it was chosen to benefit symmetric tensors with large ndim.