Skip to content

MPO

Matrix product operator.

MPO

MPO(
    tensors: List[Tensor],
    bc: str = "OBC",
    center: Optional[int] = None,
    itag_prefix: Optional[str] = None,
)

Bases: Network

Matrix product operator.

Each site tensor has axes (left_bond, right_bond, phys_in, phys_out) where:

  • phys_in (ket, axis 2) and phys_out (bra, axis 3) both carry itag s{i:02d} at site i, differentiated by opposite directions.
  • Contracting an MPS ket (s{i:02d}, IN) against this MPO is automatic: the MPO bra (s{i:02d}, OUT) pairs with the MPS ket.

Parameters:

Name Type Description Default
tensors List[Tensor]

List of site tensors, each with exactly 4 axes (left_bond, right_bond, phys_in, phys_out). Both physical axes at site i must carry itag s{i:02d} with opposite directions.

required
bc str

Boundary condition: 'OBC' (default) or 'PBC'.

'OBC'
center Optional[int]

Orthogonality center site index, or None if unspecified.

None
itag_prefix Optional[str]

Bond itag prefix string. Defaults to 'W' when None.

None

Raises:

Type Description
ValueError

If any tensor has the wrong axis count, incorrect physical itags, physical axes with the same direction, or adjacent bond indices are inconsistent.

Functions

compact

compact(trunc: Optional[dict] = None) -> None

Compress the MPO bond dimensions in-place with norm preservation.

Performs a two-sweep canonicalization:

  1. Left-to-right sweep without truncation, moving the orthogonality center to the rightmost site. This concentrates the full operator norm into the center tensor.
  2. Normalize the center tensor to unit Frobenius norm, temporarily factoring out the overall scale.
  3. Right-to-left sweep with SVD truncation (controlled by trunc), moving the center to site 0. Because the environment is unit-normed, the truncation threshold is applied on a consistent scale.
  4. Restore the overall scale into the new center tensor, then call redistribute_norm() to spread it evenly across all sites.

Parameters:

Name Type Description Default
trunc Optional[dict]

Truncation options forwarded to canonical() during the right-to-left compression sweep. Defaults to {'thresh': 1e-14} when None.

None

redistribute_norm

redistribute_norm() -> None

Redistribute the MPO norm equally across all site tensors.

Computes the total Frobenius norm N, multiplies every site tensor by factor = N^(1/L), then divides the center tensor by N to remove the excess. The product of all scale factors is factor^L / N = 1, so the operator and its total norm are preserved. center is reset to None because the per-site rescaling breaks any prior canonical form.

Raises:

Type Description
ValueError

If center is None (the MPO must be in canonical form so the norm is concentrated in a well-defined center tensor).

ValueError

If the MPO norm is numerically zero (e.g. due to norm decay).

String Representation

repr(mpo) (and therefore the interactive display in notebooks and REPLs) renders a text diagram of the chain:

               Matrix Product Operator (MPO)                
               ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾                
           ╷   ╷   ╷   ╷     ╷     ╷   ╷   ╷   ╷            
           □───□───□───□─···─⊡─···─□───□───□───□            
           ╵   ╵   ╵   ╵     ╵     ╵   ╵   ╵   ╵            
               length: 100     max bond: 64
               center: 49      norm: 1.00e+00

Chain row — each node is one site; consecutive sites are joined by ───. When the chain is too long to show in full, a gap ─···─ is inserted and only a subset of sites near the edges and center is displayed.

Physical-index rows — the downward stub beneath each node is the physical-input (ket) index; the upward stub above is the physical-output (bra) index.

Node symbols:

Symbol Meaning
Regular site
Orthogonality center (center attribute)

Info blocklength is the number of sites L; max bond is the largest bond dimension across all virtual indices; center is the orthogonality center index (None if not set); norm is ‖O‖.

See Also

  • Network — base class providing canonical(), norm(), serialize(), and more.
  • MPS — matrix product state.
  • build_hamiltonian — creates an MPO from a list of interactions.
  • observe — use this MPO as an observable.