Skip to content

yastn/yastn

Repository files navigation

YASTN - Yet Another Symmetric Tensor Network

Test status Docs status


Python library for differentiable linear algebra with block-sparse tensors, supporting abelian symmetries

YASTN tensors can be defined with both discrete and continuous abelian groups
  • Z2 for parity conservation
  • U(1) for particle number conservation
  • direct product of abelian groups such as Z3xU(1) or U(1)xU(1)xZ2 and so on
YASTN can run with different backends

allowing for automatic differentiation (autograd) on backends which provide it.

To see YASTN in action, check
  • Matrix product states (MPS) and algorithms powered by YASTN

    Explore the entire MPS module or try out code examples running DMRG or TDVP optimizations


  • Two-dimensional tensor networks library peps-torch powered by YASTN

    Try variational optimization of iPEPS with abelian symmetries for spin models


Jump to full Documentation or get started with Examples


Installation

Install using

git clone https://github.com/yastn/yastn.git && cd yastn
pip install .

or just clone and add YASTN root to your Python import path to sucessfully import yastn.

YASTN depends on
  • Python 3.9
  • NumPy

and optionally

  • PyTorch 1.11 (for PyTorch backend)
  • SciPy (for sparse linear algebra solvers)
  • ...

Run the tests

Tests, which are also a good source of examples of usage, can be found in the folder tests. To verify that everything works, get pytest. See Installing pytest or conda install -c conda-forge pytest. Then you can test base yastn.Tensor and also yastn.mps modules

cd tests
pytest -v ./tensor
pytest -v ./mps

To test YASTN on PyTorch backend and integration of autograd features

cd tests
pytest --backend torch -v ./tensor
pytest --backend torch -v ./mps

Building docs locally

You can build documentation using sphinx. The prerequisites are

  • sphinx
  • pydata-sphinx-theme

Get them with your favourite Python package manager. For example, using conda as conda install -c conda-forge sphinx pydata-sphinx-theme. Then

cd docs && make html

The generated documentation can be found at docs/build/html/index.html