qimpy.io.CheckpointPath
- class CheckpointPath(checkpoint=None, path='')
Bases:
NamedTuple
Combination of optional checkpoint and path within it. Useful as construction parameter for objects, to load data from checkpoint when available.
- Parameters:
checkpoint (Checkpoint | None)
path (str)
- __init__()
Methods
count
Return number of occurrences of value.
Create dataset with name within current checkpoint path.
index
Return first index of value.
Member name at path within checkpoint, if present.
Read var_name from checkpoint, optionally overridden by var.
Read entire dataset from name, reporting to log if report.
Handle optional dataset with read, returning None if not found.
Read fixed-length byte string from checkpoint as a regular string.
Create CpPath with path relative to current one.
Write data available on all processes to name within current path.
Write string str available on all processes to name within current path.
Attributes
Access attributes at path within checkpoint.
Checkpoint, if available.
Path within checkpoint
- create_dataset(name, shape, dtype, **kwargs)
Create dataset with name within current checkpoint path.
- Parameters:
name (str)
shape (Sequence[int])
dtype (Any)
- Return type:
Any
- member(name)
Member name at path within checkpoint, if present. Otherwise, return an empty CpPath.
- Parameters:
name (str)
- Return type:
- override(var_name, var, overridable=False)
Read var_name from checkpoint, optionally overridden by var. If not overrideable, raise error if var is not a default.
- Parameters:
var_name (str)
var (T | Default[T])
overridable (bool)
- Return type:
T
- read(name, report=True)
Read entire dataset from name, reporting to log if report.
- Parameters:
name (str)
report (bool)
- Return type:
Tensor
- read_optional(name, report=True)
Handle optional dataset with read, returning None if not found.
- Parameters:
name (str)
report (bool)
- Return type:
Tensor | None
- read_str(name)
Read fixed-length byte string from checkpoint as a regular string.
- Parameters:
name (str)
- Return type:
str
- relative(relative_path)
Create CpPath with path relative to current one. Specifically, relative_path is the path of the result relative to self.path.
- Parameters:
relative_path (str)
- Return type:
- write(name, data)
Write data available on all processes to name within current path. This is convenient for small tensors that are not split over MPI. For complex data, pass a real view that has a final dimension of length 2. Returns name, which is convenient for accumulating the names of written datasets during reporting.
- Parameters:
name (str)
data (Tensor)
- Return type:
str
- write_str(name, data)
Write string str available on all processes to name within current path. Data is written as a fixed-length byte string to support parallel access. Returns name, which is convenient for accumulating the names of written datasets during reporting.
- Parameters:
name (str)
data (str)
- Return type:
str
- property attrs
Access attributes at path within checkpoint.
- checkpoint: Checkpoint | None
Checkpoint, if available.
- path: str
Path within checkpoint