nemo_rl.data_plane.prefix_writer_actor#

Prefix-only TQ writes in an isolated, serial CPU Ray actor.

Cut transactions and encoding stay in the generation worker. Owned numeric columns cross the actor boundary, and a caller receives its keys only after TQ acknowledges the write. Terminal writes use their original local client.

Module Contents#

Classes#

PrefixWriterService

Execute one PUT or failed-write cleanup at a time in the writer actor.

PrefixWriterActor

Own the process-local TQ client, with no engine or GPU allocation.

RayPrefixWriterClient

The sink’s prefix client, forwarding each call to the writer actor.

Functions#

to_bytes

Expose a CPU column as raw bytes, plus its dtype, shape and jagged offsets.

from_bytes

Rebuild a column from to_bytes as a view of Ray’s buffer.

create_prefix_writer

Create one non-restarting, serial CPU writer on the generation node.

Data#

API#

nemo_rl.data_plane.prefix_writer_actor.G_LOGGER#

‘getLogger(…)’

nemo_rl.data_plane.prefix_writer_actor._WRITER_STARTUP_TIMEOUT_S#

180

nemo_rl.data_plane.prefix_writer_actor.to_bytes(
tensor: torch.Tensor,
) → tuple[numpy.ndarray, str, tuple[int, ...], numpy.ndarray | None]#

Expose a CPU column as raw bytes, plus its dtype, shape and jagged offsets.

Ray pickles a tensor by copying its data; NumPy arrays travel as separate buffers the actor reads from shared memory without a copy.

nemo_rl.data_plane.prefix_writer_actor.from_bytes(
data: numpy.ndarray,
dtype: str,
shape: tuple[int, ...],
offsets: numpy.ndarray | None,
) → torch.Tensor#

Rebuild a column from to_bytes as a view of Ray’s buffer.

class nemo_rl.data_plane.prefix_writer_actor.PrefixWriterService(client: Any)#

Execute one PUT or failed-write cleanup at a time in the writer actor.

Initialization

put_samples(
*,
sample_ids: list[str],
partition_id: str,
columns: dict[str, tuple[Any, ...]],
tags: list[dict[str, Any]],
) → None#

Write one batch; returns once TQ acknowledges it.

clear_samples(*, sample_ids: list[str], partition_id: str) → None#
get_data_plane_snapshot() → dict[str, Any] | None#
class nemo_rl.data_plane.prefix_writer_actor.PrefixWriterActor(
config: nemo_rl.data_plane.interfaces.DataPlaneConfig,
)#

Bases: nemo_rl.data_plane.prefix_writer_actor.PrefixWriterService

Own the process-local TQ client, with no engine or GPU allocation.

Initialization

ready() → dict[str, Any]#
exception nemo_rl.data_plane.prefix_writer_actor.PrefixWriterDiedError#

Bases: RuntimeError

The writer actor is gone; it is never restarted.

Initialization

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

class nemo_rl.data_plane.prefix_writer_actor.RayPrefixWriterClient(actor: Any, *, writer_pid: int)#

The sink’s prefix client, forwarding each call to the writer actor.

The actor options run one call at a time with no retries, and killing the actor fails its pending call, so nothing is acknowledged early. Close is teardown-only. Once the actor dies, every later call raises PrefixWriterDiedError rather than falling back to another client.

Initialization

_require_open() → None#
_died_error() → nemo_rl.data_plane.prefix_writer_actor.PrefixWriterDiedError#
_get(reference: Any) → Any#

Resolve one actor call, marking the writer dead if the actor is gone.

put_samples(
*,
sample_ids: list[str],
partition_id: str,
fields: tensordict.TensorDict,
tags: list[dict[str, Any]],
) → None#
clear_samples(*, sample_ids: list[str], partition_id: str) → None#
async get_data_plane_snapshot() → dict[str, Any] | None#

The writer client’s data-plane counters.

None when observability is off or the writer is closed or dead; the cuts report a dead writer. Waits behind an in-flight PUT, since the actor runs one call at a time.

close() → None#
async nemo_rl.data_plane.prefix_writer_actor.create_prefix_writer(
config: nemo_rl.data_plane.interfaces.DataPlaneConfig,
) → nemo_rl.data_plane.prefix_writer_actor.RayPrefixWriterClient#

Create one non-restarting, serial CPU writer on the generation node.