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
|
|
n_sweeps |
int
|
Actual number of full sweeps performed. |
bond_dims |
List[int]
|
Bond dimensions of |
discarded_weights |
List[float]
|
Discarded weight at the center bond measured during each backward
half-sweep (2-site scheme only; always |
Functions¶
serialize
¶
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 |
deserialize
classmethod
¶
Reconstruct a Summary from a dict produced by serialize.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict
|
Dict previously returned by |
required |
device
|
str
|
Device to place all MPS tensor blocks on. Defaults to |
'cpu'
|
Returns:
| Type | Description |
|---|---|
Summary
|
Reconstructed summary with the MPS state placed on |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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")