YASTN configuration#

All YASTN tensors have to be provided with configuration, which defines:

  1. linear algebra backend,

  2. abelian symmetry group,

  3. how to handle fusion (reshaping) of tensors,

#. default data type (float64, complex128) and device (provided it is supported by backend) of tensors.

The configuration can be provided as a Python module, types.SimpleNamespace, typing.NamedTuple or similar which defines following members

  • required: backend, sym,

  • optional: default_device, default_dtype, default_fusion, fermionic, force_fusion.

The configuration can be conveninently generated using

yastn.make_config(**kwargs) NamedTuple[source]#

Create structure with YASTN configuration

Parameters:
  • backend (backend module or str) – Specify backend providing linear algebra and base dense tensors. Currently supported backends are

    • NumPy as yastn.backend.backend_np

    • PyTorch as yastn.backend.backend_torch

    Understands string inputs “np”, “torch”. Defaults to NumPy backend.

  • sym (symmetry module or compatible object or str) – Specify abelian symmetry. To see how YASTN defines symmetries, see yastn.sym.sym_abelian. Defaults to yastn.sym.sym_none, effectively a dense tensor. For predefined symmetries, takes string input from ‘dense’, ‘Z2’, ‘Z3’, ‘U1’, ‘U1xU1’, ‘U1xU1xZ2’.

  • default_device (str) –

    Tensors can be stored on various devices as supported by backend

    If not specified, the default device is 'cpu'.

  • default_dtype (str) – Default data type (dtype) of YASTN tensors. Supported options are: 'float64', 'complex128'. If not specified, the default dtype is 'float64'.

  • fermionic (bool or tuple[bool,…]) – Specify behavior of yastn.swap_gate() function, allowing to introduce fermionic symmetries. Allowed values: False, True, or a tuple (True, False, ...) with one bool for each component charge vector, i.e., of length sym.NSYM. Default is False.

  • default_fusion (str) – Specify default strategy to handle leg fusion: 'hard' or 'meta'. See yastn.Tensor.fuse_legs() for details. Default is 'hard'.

  • force_fusion (str) – Overrides fusion strategy provided in yastn.Tensor.fuse_legs(). Default is None.

Below is an example of configuration defined as a plain Python module, using NumPy backend and \(U(1)\) symmetry.

import yastn.backend.backend_np as backend
from yastn.sym import sym_U1 as sym

default_device: str = 'cpu'
default_dtype: str = 'float64'
fermionic = False
default_fusion: str = 'hard'
force_fusion: str = None