nemo_rl.data_plane.checkpoint#

Two-phase checkpoint ownership and cancellation-safe persistence.

Capture runs under the caller’s global mutation barrier. Once it returns, the handle owns a stable view independent of live clears/replacements. Persistence may run after that barrier opens. Publication remains the caller’s responsibility.

Module Contents#

Classes#

CheckpointCapture

One retained snapshot; callers must release it even after failed saves.

Functions#

_settle

Do not leave an uncancellable thread/RPC running past cleanup.

checkpoint_io

Run blocking snapshot I/O; cancellation waits for outstanding writes.

capture_checkpoint

Capture via an adapter, releasing late results if capture is cancelled.

Data#

API#

nemo_rl.data_plane.checkpoint.LOGGER#

‘getLogger(…)’

nemo_rl.data_plane.checkpoint.T#

‘TypeVar(…)’

exception nemo_rl.data_plane.checkpoint.CheckpointReleaseError#

Bases: RuntimeError

A capture the caller holds no handle for may still be retained.

Raised when a failed or cancelled capture cannot confirm its release. The caller cannot retry it, so it must stop checkpointing.

Initialization

Initialize self. See help(type(self)) for accurate signature.

class nemo_rl.data_plane.checkpoint.CheckpointCapture#

Bases: abc.ABC

One retained snapshot; callers must release it even after failed saves.

token: str#

None

__enter__() → Self#
__exit__(
exc_type: type[BaseException] | None,
exc: BaseException | None,
traceback: types.TracebackType | None,
) → None#
abstractmethod persist(
*,
extra_metadata: collections.abc.Mapping[str, Any] | None = None,
) → None#

Write the captured view, without reading mutable live state.

Parameters:

extra_metadata – Metadata known only after capture, such as the digest of state serialized once the barrier opened. It is added to the capture’s metadata and must not repeat any of its keys.

abstractmethod release() → None#

Release after writers stop; retry release if its wait times out.

async nemo_rl.data_plane.checkpoint._settle(
task: asyncio.Task[nemo_rl.data_plane.checkpoint.T],
) → nemo_rl.data_plane.checkpoint.T#

Do not leave an uncancellable thread/RPC running past cleanup.

async nemo_rl.data_plane.checkpoint.checkpoint_io(
operation: Callable[[], nemo_rl.data_plane.checkpoint.T],
) → nemo_rl.data_plane.checkpoint.T#

Run blocking snapshot I/O; cancellation waits for outstanding writes.

Cancellation settles the local callable. A backend timeout can leave remote RPCs running; release must succeed before removing its temporary directory.

async nemo_rl.data_plane.checkpoint.capture_checkpoint(
client: Any,
**kwargs: Any,
) → nemo_rl.data_plane.checkpoint.CheckpointCapture | None#

Capture via an adapter, releasing late results if capture is cancelled.

Raises CheckpointReleaseError, even past repeated cancellation, when a cancelled capture’s release cannot be confirmed.