portc

apply

Contraction-compression of an MPO with an MPS or another MPO.

A thin wrapper around portc.stack.src for two-train stacks:

  1. MPO-MPS randomized contraction-compression.
  2. MPO-MPO randomized contraction-compression.
funcapply(left_tensor, right_tensor, chi_out, *, cutoff=0.0, oversample=1.0, dtype=None, seed=None, device='cpu', resources=None, optimize=DEFAULT_OPTIMIZE) -> list[np.ndarray]

Applies the Successive Randomized Compression (SRC) algorithm.

Equivalent to src(left_tensor, right_tensor, ...) restricted to an MPO on the left; see portc.stack.src for the conventions, deeper stacks and the bra form. The train type is inferred from the rank of the first site tensor, and dispatch follows:

  1. MPO-MPS: left_tensor is an MPO and right_tensor is an MPS. Results in an MPS.
  2. MPO-MPO: both left_tensor and right_tensor are MPOs. Results in an MPO.

Raises

  • TypeError: If chi_out is not an integer or the combination of input tensor types is unsupported, or optimize is neither a name nor a PathOptimizer.
  • ValueError: If chi_out is not positive, if cutoff is not in [0.0, 1.0), if oversample is not finite and at least 1.0, if a train is not open-boundary, if the two trains differ in length or in the physical dimensions they join, if a sub-three-site train is not exactly two sites, if optimize names no opt_einsum path optimizer, or if device is not recognised.
  • ImportError: If device="gpu" but cupy is not installed.
paramleft_tensorSequence[Site]

The site arrays of the left tensor network (MPO).

paramright_tensorSequence[Site]

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

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. Discards singular values below cutoff * sigma_max; see portc.stack.src. Set to 0.0 (default) to disable cutoff trimming. Ignored for two sites.

paramoversamplefloat | None
= 1.0

Multiplicative sketch-size factor, finite and at least 1.0, or None for the paper's recommendation; see portc.stack.src. Defaults to 1.0, no oversampling.

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 portc.stack.src.

paramoptimizestr | PathOptimizer
= DEFAULT_OPTIMIZE

The opt_einsum path optimizer of the contractions, a name or a PathOptimizer; see portc.stack.src. Defaults to "dp".

Returns

list

The site arrays of the compressed tensor network (MPS or MPO), in right-canonical form, or left-canonical form when oversampling (three sites or more).