Skip to content

Summary

DMRG output dataclass.

Summary dataclass

Summary(
    energy: float,
    state: MPS,
    energies: List[float] = list(),
    converged: bool = False,
    n_sweeps: int = 0,
    bond_dims: List[int] = list(),
    discarded_weights: List[float] = list(),
)

Bases: AlgorithmSummary

DMRG output.

Attributes:

Name Type Description
energy float

Final ground-state energy (lowest Ritz value from the last sweep).

state MPS

Optimised MPS after all sweeps.

energies List[float]

Energy recorded at the end of each full sweep (forward + backward half-sweep).

converged bool

True if |E_new - E_old| < opts.e_tol before n_sweeps was reached.

n_sweeps int

Actual number of full sweeps performed.

bond_dims List[int]

Bond dimensions of state after convergence (length L - 1).

discarded_weights List[float]

Discarded weight at the center bond measured during each backward half-sweep (2-site scheme only; always 0.0 for 1-site).

Functions

serialize

serialize() -> Dict

Serialize the summary to a plain dict compatible with torch.save.

The MPS state is serialized via Network.serialize, which produces a weights_only-safe dict of tensors and primitives.

Returns:

Type Description
Dict

Serialized summary with keys "version", "energy", "energies", "converged", "n_sweeps", "bond_dims", and "state".

deserialize classmethod

deserialize(data: Dict, device: str = 'cpu') -> Summary

Reconstruct a Summary from a dict produced by serialize.

Parameters:

Name Type Description Default
data Dict

Dict previously returned by serialize.

required
device str

Device to place all MPS tensor blocks on. Defaults to 'cpu'.

'cpu'

Returns:

Type Description
Summary

Reconstructed summary with the MPS state placed on device.

Raises:

Type Description
ValueError

If data["version"] is not 1.

Serialization

import torch

payload = summary.serialize()
torch.save(payload, "result.pt")

# Reload
data    = torch.load("result.pt", weights_only=True)
summary = dmrg.Summary.deserialize(data, device="cpu")

See Also

  • Options — input options.
  • run — returns a Summary.