src_method

compress

Compression of a single MPS or MPO.

A thin wrapper around src_method.stack.src for one-train stacks:

  1. MPO randomized compression.
  2. MPS randomized compression.
funccompress(tensor, chi_out, *, cutoff=0.0, dtype=None, seed=None, device='cpu', resources=None) -> list[NDArray]

Applies the Successive Randomized Compression (SRC) algorithm.

Equivalent to src(tensor, ...); see src_method.stack.src for the conventions. The train type is inferred from the rank of the first site tensor:

  1. MPS: tensor is an MPS. Results in an MPS.
  2. MPO: tensor is an MPO. Results in an MPO.

Raises

  • TypeError: If chi_out is not an integer or the input tensor type is unsupported.
  • ValueError: If chi_out is not positive, if cutoff is not in [0.0, 1.0), if the train is not open-boundary, if a sub-three-site train is not exactly two sites, or if device is not recognised.
  • ImportError: If device="gpu" but cupy is not installed.
paramtensorSequence[Site]

The site arrays of the tensor network to compress (MPS or MPO).

paramchi_outint | np.integer

The desired maximum bond dimension of the output tensor network.

paramcutofffloat
= 0.0

Relative singular-value cutoff for adaptive bond truncation. When positive, bonds are trimmed to their effective rank by discarding singular values below cutoff * sigma_max at each site during the right-to-left sweep. The SVD operates on the small (chi_out, chi_out) R factor from QR, so overhead is minimal. Set to 0.0 (default) to keep all bonds at chi_out.

paramdtypeDTypeLike | None
= None

Data type of the random sketches. Defaults to the promoted floating dtype of the inputs; an explicit dtype can promote the result.

paramseedint | None
= None

An optional seed for the random number generator.

paramdevicestr
= 'cpu'

"cpu" (default, numpy) or "gpu" (cupy). Requires the optional cupy dependency for GPU execution.

paramresourcesResources | None
= None

Memory budgets and scratch space; see src_method.stack.src.

Returns

list

The site arrays of the compressed tensor network (MPS or MPO).