nemo_rl.data_plane.nixl.blob_format#

Blob codec: many values → one self-describing byte blob, no per-tensor serialization.

Tensors and numpy arrays are stored as their raw contiguous bytes. What the bytes mean (kind, dtype, shape) lives in two places that we own: the per-entry location meta TransferQueue hands back on every get, and the blob’s trailing index so a unit can read its own blobs without the controller (scan, checkpoint shards). Only non-tensor objects are pickled.

Layout::

[ entry_0 | pad | entry_1 | pad | ... | index (msgpack) | footer 16 B ]

Entries are 64-byte aligned.

Module Contents#

Classes#

Functions#

_align_up

_tensor_bytes

_numpy_bytes

encode_value

plan

write_tail

Write only the index and footer (len(p.index_bytes) + FOOTER_SIZE bytes).

write

_torch_dtype

decode_entry

Reconstruct a value from its bytes. Tensors and arrays are zero-copy views.

materialize

Copy a decoded zero-copy view out of the transfer buffer.

_footer

(index_off, index_len, tag) from a v3 or v2 footer at the end of blob.

read_index

read_index_file

func:

read_index of the blob stored at off in binary file f.

_entries

footer_is_valid

Data#

API#

nemo_rl.data_plane.nixl.blob_format.ALIGN#

64

nemo_rl.data_plane.nixl.blob_format.MAGIC#

1314276432

nemo_rl.data_plane.nixl.blob_format.VERSION#

3

‘<IHHII16s’

nemo_rl.data_plane.nixl.blob_format.FOOTER_SIZE#

‘calcsize(…)’

‘<IHHII’

nemo_rl.data_plane.nixl.blob_format.FOOTER_V2_SIZE#

‘calcsize(…)’

nemo_rl.data_plane.nixl.blob_format.NO_TAG#

‘bytes(…)’

nemo_rl.data_plane.nixl.blob_format.KIND_TENSOR#

‘t’

nemo_rl.data_plane.nixl.blob_format.KIND_NUMPY#

‘n’

nemo_rl.data_plane.nixl.blob_format.KIND_PICKLE#

‘p’

nemo_rl.data_plane.nixl.blob_format._align_up(n: int) → int#
class nemo_rl.data_plane.nixl.blob_format.Entry#
key: str#

None

off: int#

None

len: int#

None

kind: str#

None

dtype: str | None#

None

shape: tuple[int, ...] | None#

None

meta() → dict[str, Any]#

Location meta stored by TQ as custom_backend_meta (blob id added by the client).

static from_meta(
key: str,
m: dict[str, Any],
) → nemo_rl.data_plane.nixl.blob_format.Entry#
class nemo_rl.data_plane.nixl.blob_format.BlobPlan#
keys: list[str]#

None

buffers: list[memoryview]#

None

keepalive: list[Any]#

None

entries: list[nemo_rl.data_plane.nixl.blob_format.Entry]#

None

index_bytes: bytes#

None

nbytes: int#

None

tag: bytes#

None

property index_off: int#
nemo_rl.data_plane.nixl.blob_format._tensor_bytes(t: torch.Tensor) → tuple[memoryview, Any]#
nemo_rl.data_plane.nixl.blob_format._numpy_bytes(a: numpy.ndarray) → tuple[memoryview, Any]#
nemo_rl.data_plane.nixl.blob_format.encode_value(
key: str,
v: Any,
) → tuple[memoryview, Any, str, str | None, tuple[int, ...] | None]#
nemo_rl.data_plane.nixl.blob_format.plan(
keys: Sequence[str],
values: Sequence[Any],
tag: bytes = NO_TAG,
) → nemo_rl.data_plane.nixl.blob_format.BlobPlan#
nemo_rl.data_plane.nixl.blob_format.write_tail(
p: nemo_rl.data_plane.nixl.blob_format.BlobPlan,
out: memoryview,
) → None#

Write only the index and footer (len(p.index_bytes) + FOOTER_SIZE bytes).

For a blob whose values are sent separately. out maps to blob offset p.index_off.

nemo_rl.data_plane.nixl.blob_format.write(
p: nemo_rl.data_plane.nixl.blob_format.BlobPlan,
out: memoryview,
) → None#
nemo_rl.data_plane.nixl.blob_format._torch_dtype(name: str) → torch.dtype#
nemo_rl.data_plane.nixl.blob_format.decode_entry(
view: memoryview,
e: nemo_rl.data_plane.nixl.blob_format.Entry,
) → Any#

Reconstruct a value from its bytes. Tensors and arrays are zero-copy views.

nemo_rl.data_plane.nixl.blob_format.materialize(v: Any) → Any#

Copy a decoded zero-copy view out of the transfer buffer.

(index_off, index_len, tag) from a v3 or v2 footer at the end of blob.

nemo_rl.data_plane.nixl.blob_format.read_index(
blob: memoryview,
) → list[nemo_rl.data_plane.nixl.blob_format.Entry]#
nemo_rl.data_plane.nixl.blob_format.read_index_file(
f: Any,
off: int,
nbytes: int,
) → list[nemo_rl.data_plane.nixl.blob_format.Entry]#
Func:

read_index of the blob stored at off in binary file f.

nemo_rl.data_plane.nixl.blob_format._entries(
raw: bytes,
) → list[nemo_rl.data_plane.nixl.blob_format.Entry]#
nemo_rl.data_plane.nixl.blob_format.footer_is_valid(blob_tail: memoryview) → bool#