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

__init__

count

Return number of occurrences of value.

index

Return first index of value.

member

Member name at path within checkpoint, if present.

override

Read var_name from checkpoint, optionally overridden by var.

read

Read entire dataset from name, reporting to log if report.

read_optional

Handle optional dataset with read, returning None if not found.

relative

Create CpPath with path relative to current one.

write

Write data available on all processes to name within current path.

Attributes

attrs

Access attributes at path within checkpoint.

checkpoint

Checkpoint, if available.

path

Path within checkpoint

member(name)

Member name at path within checkpoint, if present. Otherwise, return an empty CpPath.

Parameters:

name (str) –

Return type:

CheckpointPath

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

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:

CheckpointPath

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

property attrs

Access attributes at path within checkpoint.

checkpoint: Checkpoint | None

Checkpoint, if available.

path: str

Path within checkpoint