nemo_rl.data_plane.adapters.tq_nixl#
TransferQueue glue for the NIXL data plane (data_plane.backend: nixl).
Importing this module registers the NixlStore backend with TransferQueue:
StorageClientFactory["NixlStoreClient"]-> :class:NixlKVClientStorageManagerFactory["NixlStore"]-> :class:NixlStorageManagerStorageBootstrapProvider["NixlStore"]-> :func:initialize_nixl_storage
Client. Index-addressed, like SimpleStorage: TQ’s key gidx@field names a
row, and row gidx lives on unit unit_ids[gidx % N], which keeps the row’s
field -> (blob, entry) index. put lays each owner unit’s values out as
raw bytes in one blob (:mod:nemo_rl.data_plane.nixl), WRITEs it and commits
it, which publishes its rows on the unit; it returns no custom_backend_meta,
so the TQ controller stores no locations. get asks each owner unit for its
keys’ entries (one resolve_keys per unit, which pins them), READs the ranges
and reconstructs from the unit’s entry, not from TQ’s field schema, so a TQ
shape bug cannot corrupt a read. Clearing is row-wide, by global index
(:meth:NixlStorageManager.clear_data). Clients hold no state but the unit
table, so they can join at any time. All NIXL access happens under one lock:
the TQ KV manager calls put from executor threads and get from its
event loop.
Bootstrap. Called once by transfer_queue.init in the process that
creates the TQ controller: starts the BlobDirectory and the storage units
(:mod:nemo_rl.data_plane.nixl_storage_unit). Placement is SimpleStorage style
(num_storage_units round-robin over eligible nodes, default one per node) or per node
(storage_units_per_node on each node of node_ids, which the caller
resolves from storage_unit_placement). transfer_queue.close does not stop
third-party backends, so the owner calls :func:shutdown after it.
Manager. put/get are inherited from KVStorageManager; clear_data
is row-wide; checkpointing goes through
- mod:
nemo_rl.data_plane.adapters.tq_nixl_checkpoint.
Module Contents#
Classes#
The client’s lock, which also records how long callers wait for it. |
|
Functions#
The NixlStore block checked by |
|
|
|
Unit kwargs for the SSD tier, or None when |
|
Debug aid ( |
|
Copy raw bytes into a registered buffer; torch’s parallel copy_ when large. |
|
The first spill means the units’ RAM is full: say so once, with the remedy. |
|
Unit health summed over the units, for the driver to log every step. |
|
One node id per unit to create, from the backend config block. |
|
Kill the BlobDirectory and every storage unit of a NixlStore system. |
|
Data#
API#
- nemo_rl.data_plane.adapters.tq_nixl.BACKEND_NAME#
‘NixlStore’
- nemo_rl.data_plane.adapters.tq_nixl.DEFAULT_NAMESPACE#
‘nemo_rl_nixl’
- nemo_rl.data_plane.adapters.tq_nixl.log#
‘getLogger(…)’
- nemo_rl.data_plane.adapters.tq_nixl._as_dict(cfg: Any) dict[str, Any]#
- nemo_rl.data_plane.adapters.tq_nixl._config(cfg: Any) dict[str, Any]#
The NixlStore block checked by
NixlStoreConfig.Its defaults fill what is unset, and a misspelled
ssd/nixlkey fails.
- nemo_rl.data_plane.adapters.tq_nixl.check_timeouts(
- cfg: dict[str, Any],
(transfer_timeout_s, read_pin_s, op_timeout_s)from the config.A read’s pin holds its blobs for
read_pin_s, so a READ that may run fortransfer_timeout_sneedsread_pin_sto cover it with margin (design §3.3); anything shorter is rejected.
- nemo_rl.data_plane.adapters.tq_nixl.ssd_config(cfg: dict[str, Any]) dict[str, Any] | None#
Unit kwargs for the SSD tier, or None when
ssd.enabledis off.ssd: {enabled, path, staging_bytes, pickup_s, io_threads}: when a unit’s put area cannot take a put, the put goes to a file underpath(node-local NVMe; null: each unit picks/raidor/tmpon its own node, seelocal_disk.default_ssd_dir) from birth, through an IO area ofstaging_bytesthe unit pins beside its slab (the put area keeps its configured size; a unit holdsunit_slab_bytes + staging_bytes); reads of such blobs are staged back into the same area, byio_threadsfile-I/O threads per unit. Data already in the put area never moves.Contract: data is read roughly oldest first (the
weight_fifo,in_orderandready_firstsamplers), so the oldest data stays in RAM and the newest goes to disk. Thewindowedsampler with freshest-first selection works but spills the data it reads next.
- nemo_rl.data_plane.adapters.tq_nixl._check_finite(
- tag: str,
- keys: list[str],
- values: list[Any],
Debug aid (
debug_check_finite/NVDP_CHECK_FINITE=1).Report rows whose float tensors hold NaN/inf or whose bool masks are all False, at both ends of the wire. A row reported on
getbut never onputis corruption in the data plane; a row reported on both was already like that upstream.
- nemo_rl.data_plane.adapters.tq_nixl._copy_into(
- dst: numpy.ndarray,
- src: memoryview,
- parallel_min: int,
Copy raw bytes into a registered buffer; torch’s parallel copy_ when large.
Single-threaded memcpy tops out near 14-28 GB/s on GB300; torch
copy_reaches ~107 GB/s from ~16 MB up, but costs ~0.4 ms of thread fan-out.
- class nemo_rl.data_plane.adapters.tq_nixl.TimedLock#
The client’s lock, which also records how long callers wait for it.
The numbers decide whether concurrent callers in one process contend enough to justify a finer-grained lock:
wait_ms_sum/wait_ms_maxover contended acquisitions,waitsthose longer than 1 ms. Counters change only while the lock is held, so they need no lock of their own. Re-entrant acquisition by the holder never waits.Initialization
- __enter__() nemo_rl.data_plane.adapters.tq_nixl.TimedLock#
- __exit__(*exc: Any) None#
- released()#
Let other threads use the client while the holder sleeps.
- snapshot() tuple[int, float, float]#
(waits, wait_ms_sum, wait_ms_max); plain reads, so it never waits itself.
- class nemo_rl.data_plane.adapters.tq_nixl.NixlKVClient(config: dict[str, Any])#
Bases:
transfer_queue.storage.clients.base.StorageKVClientInitialization
- owner(gidx: int) int#
The unit that owns row
gidx(TQ global index).
- _by_owner(keys: list[str]) dict[int, list[int]]#
Key positions grouped by owner unit, in key order.
- put(
- keys: list[str],
- values: list[Any],
- _put(keys: list[str], values: list[Any]) None#
Write each owner unit’s keys as blobs there; return no meta.
Failure policy (SimpleStorage’s): a blob that was committed stays published even if a later one fails; the put raises and TQ is not notified, so the new values are reclaimed by the next overwrite or the row-wide clear of those rows.
- _plan(
- unit_id: int,
- keys: list[str],
- values: list[Any],
unit_id’s keys as one blob, halved at key boundaries while over max_blob_bytes.
- _acquire(nbytes: int, deadline: float)#
A pool buffer, waiting no longer than the operation’s deadline.
- _errors(keys: list[str], by_blob: dict[str, list[int]] | None = None)#
Map store errors to what NeMo-RL sees (design §6).
by_blobmaps blob -> key indexes, to name exactly the affected keys.
- static _backing_bytes(owner: Any) int#
Size of the allocation a value lives in (not the value itself).
- _zero_copy_ok(
- e: nemo_rl.data_plane.nixl.blob_format.Entry,
- mv: memoryview,
- owner: Any,
- _layout(p: nemo_rl.data_plane.nixl.blob_format.BlobPlan) tuple#
A blob without building it: zero-copy values, and the packed part’s layout.
Big values go zero-copy, the rest (small values, the index and the footer) is packed; returns
(zero, layout, tail_off, tail, packed_bytes).
- _put_blobs(blobs: list[tuple], deadline: float) None#
Pack
(unit_id, blob_id, plan, layout)blobs back to back into one pool buffer and put them.
- get(
- keys: list[str],
- shapes=None,
- dtypes=None,
- custom_backend_meta=None,
- _get(keys: list[str]) list[Any]#
- _get_once(
- keys: list[str],
- idx: list[int],
- out: list[Any],
- deadline: float,
Resolve, READ and decode
keys[i] for i in idx; return the still-pending ones.
- abstractmethod clear(keys: list[str], custom_backend_meta=None) None#
- clear_rows(gidxs: list[int]) None#
Drop every field of rows
gidxson their owner units (awaited).
- _op_done(t0: float) None#
- _log_stats() None#
- unit_stats() list[dict[str, Any]]#
Each unit’s
stats()(one Ray call per unit).
- close() None#
- nemo_rl.data_plane.adapters.tq_nixl._warned_spill#
False
- nemo_rl.data_plane.adapters.tq_nixl._warn_on_first_spill(metrics: dict[str, float]) None#
The first spill means the units’ RAM is full: say so once, with the remedy.
- nemo_rl.data_plane.adapters.tq_nixl.unit_metrics() dict[str, float]#
Unit health summed over the units, for the driver to log every step.
retired_mb_sum/retired_mb_max, plusssd_spills_sumandssd_spilled_mb_sumwith the SSD tier on. Retired memory is lost to WRITEs that may still land, gone until the unit restarts: a rising line is a slow leak. Read through this process’s TQ client;{}when it has no nixl client.
- nemo_rl.data_plane.adapters.tq_nixl._unit_name(i: int) str#
- nemo_rl.data_plane.adapters.tq_nixl.alive_node_ids(required_node_resource: str | None = None) list[str]#
- nemo_rl.data_plane.adapters.tq_nixl.unit_node_ids(cfg: dict[str, Any]) list[str]#
One node id per unit to create, from the backend config block.
- nemo_rl.data_plane.adapters.tq_nixl._kill_named(name: str, namespace: str) bool#
- nemo_rl.data_plane.adapters.tq_nixl.shutdown(conf_or_backend_cfg: Any) None#
Kill the BlobDirectory and every storage unit of a NixlStore system.
Units are named
NixlStorageUnit#<i>; kill consecutively until a name is missing, so a larger earlier system in the same namespace is swept too.
- nemo_rl.data_plane.adapters.tq_nixl.initialize_nixl_storage(conf: Any) dict[str, Any]#
- class nemo_rl.data_plane.adapters.tq_nixl.NixlStorageManager(
- controller_info: Any,
- config: Any,
- zmq_context: Any = None,
Bases:
transfer_queue.storage.managers.base.KVStorageManagerInitialization
- async clear_data(metadata) None#
Clear whole rows by global index, like SimpleStorage.
TQ’s KV
clear_datawould name only the fields every row has (an overwrite releases its old blob on the unit, at commit).
- async save_checkpoint(checkpoint_dir: str) None#
- async load_checkpoint(checkpoint_dir: str) None#
- close() None#