Skip to content

SRC Method#

Successive Randomized Compression#

An implementation of the SRC algorithm introduced on arXiv:2504.06475, but extending the idea to other kinds of tensor networks.

Features#

The following primitives are supported:

  1. MPO-MPS randomized contraction-compression.
  2. MPO-MPO randomized contraction-compression.
  3. MPO randomized compression.
  4. MPS randomized compression.

src_method has no tensor-network framework dependency: it takes and returns plain lists of per-site NumPy arrays, one array per site.

from src_method import apply, compress

The apply function covers cases 1 and 2 above, while the compress function covers cases 3 and 4. Both functions are pure, meaning no in-place modification ever happens. The user should manage the assignment of the returned objects, possibly overwriting the input variables. See the reference documentation for details, and the tests or benchmarks folders for usage examples.

Whether a train is an MPS or an MPO is inferred from the rank of its first site tensor, so no wrapper type is needed.

NOTE: the current implementation targets tensor networks with 3 or more sites. For smaller networks, an exact SVD-based fallback is dispatched, with a warning.

Tensor Indexing Conventions#

The array layout follows the default quimb tensor indexing conventions, so results round-trip through Quimb without any permutation:

import quimb.tensor as qtn

result = qtn.MatrixProductOperator(apply(H1.arrays, H2.arrays, chi_out=64))
  • MPO Tensors: Bulk tensors have index order ('l', 'r', 'u', 'd'). Boundary tensors (at the edges) are rank-3, dropping the outer 'l' or 'r' index.

  • MPS Tensors: Bulk tensors have index order ('l', 'r', 'u'). Boundary tensors are rank-2, dropping the outer bond index.

Where 'l'/'r' are left/right virtual bonds and 'u'/'d' are the upper/lower physical legs. Please keep this in mind when constructing or manipulating tensors directly.

Installation#

# CPU only (default)
uv pip install src_method

# With NVIDIA GPU support (CUDA 12.x)
uv pip install "src_method[gpu-nvidia]"

# With AMD GPU support (ROCm)
uv pip install "src_method[gpu-rocm]"

Or simply add it to the dependencies of your project’s pyproject.toml.

Setting up the development environment#

The code has a DevContainer configuration that will get you up and running with all dependencies installed and configured, including sane defaults for the editor.

You will need:

  1. A working Docker installation:
  2. For macOS and Windows, install Docker Desktop
  3. For Linux, install Docker Engine following the instructions for your specific distro.
  4. The Visual Studio Code editor. A recent version is recommended, e.g. >=1.78
  5. The VSCode DevContainers extension.
  6. (Optional, but highly recommended) The GitHub CLI tool.

You can clone the repository with:

git clone https://github.com/Algorithmiq/src-method.git

We recommend using a Git credential manager, such as GitHub CLI, configured to use HTTPS as protocol for Git operations.

Once the code is locally available, you can open its containing folder in Visual Studio Code. The editor will then set up the DevContainer for you. The first time you open the folder the startup will take a few minutes. Once the process is done, you will have all project dependencies installed, including the git hooks. Visual Studio Code will be already configured with all the extensions helpful for Python development.

Note that the order in which Visual Studio Code loads the extensions in the DevContainer is non-deterministic. You might have to execute the Reload Window command to get everything to work as expected after a fresh build of the container.