nemo_rl.data_plane.adapters.local#
Process-local data-plane adapter for colocated SFT loaders and policies.
Module Contents#
Classes#
Store a bounded set of complete SFT batches in the current process. |
Functions#
Return whether metadata identifies a process-local partition version. |
|
Wrap a prepared local batch without flattening multimodal values. |
|
Materialize local tensors and restore exact non-tensor field values. |
Data#
API#
- nemo_rl.data_plane.adapters.local._LOCAL_GENERATION_KEY#
‘local_partition_generation’
- nemo_rl.data_plane.adapters.local._CHECKPOINT_FILENAME#
‘local_data_plane_state.pkl’
- class nemo_rl.data_plane.adapters.local._LocalPartition#
- fields: tuple[str, ...]#
None
- num_samples: int#
None
- consumer_tasks: tuple[str, ...]#
None
- grpo_group_size: int | None#
None
- enums: dict[str, list[str]]#
None
- generation: int#
None
- sample_ids: list[str]#
‘field(…)’
- batch: dict[str, Any]#
‘field(…)’
- tags: list[dict[str, Any]] | None#
None
- consumed: dict[str, set[str]]#
‘field(…)’
- nemo_rl.data_plane.adapters.local.is_local_batch_meta( ) bool#
Return whether metadata identifies a process-local partition version.
- nemo_rl.data_plane.adapters.local._value_batch_size(value: Any) int#
- nemo_rl.data_plane.adapters.local._is_identity_indices(indices: list[int], batch_size: int) bool#
- nemo_rl.data_plane.adapters.local._select_batch_value(
- value: Any,
- indices: list[int],
- nemo_rl.data_plane.adapters.local._unwrap_local_value(value: Any) Any#
- nemo_rl.data_plane.adapters.local.local_batch_to_tensordict(
- fields: collections.abc.Mapping[str, Any],
- *,
- batch_size: int,
Wrap a prepared local batch without flattening multimodal values.
Tensor leaves stay as tensors. Other leaves, including
PackedTensor, useNonTensorDatabecause this adapter never serializes them.
- nemo_rl.data_plane.adapters.local.materialize_local(
- td: tensordict.TensorDict,
- layout: nemo_rl.data_plane.schema.Layout = 'padded',
- pad_value_dict: dict[str, int | float] | None = None,
- pad_to_seqlen: int = 0,
Materialize local tensors and restore exact non-tensor field values.
Not interchangeable with :func:
materialize.local_batch_to_tensordictstores each non-tensor column as oneNonTensorDataholding the whole column, whichmaterializereads as a single row. Batches written by this adapter must be read back through here.
- class nemo_rl.data_plane.adapters.local.LocalDataPlaneClient( )#
Bases:
nemo_rl.data_plane.interfaces.DataPlaneClientStore a bounded set of complete SFT batches in the current process.
Initialization
- _require_open() None#
- _partition(
- partition_id: str,
- _validate_meta( ) nemo_rl.data_plane.adapters.local._LocalPartition#
- register_partition(
- partition_id: str,
- fields: list[str],
- num_samples: int,
- consumer_tasks: list[str],
- grpo_group_size: int | None = None,
- enums: dict[str, list[str]] | None = None,
- claim_meta(
- partition_id: str,
- task_name: str,
- required_fields: list[str],
- batch_size: int,
- dp_rank: int | None = None,
- blocking: bool = True,
- timeout_s: float = 60.0,
- get_data(
- meta: nemo_rl.data_plane.interfaces.KVBatchMeta,
- select_fields: list[str] | None = None,
- check_consumption_status(
- partition_id: str,
- task_names: list[str],
- put_samples(
- sample_ids: list[str],
- partition_id: str,
- fields: tensordict.TensorDict | None = None,
- tags: list[dict[str, Any]] | None = None,
- get_samples(
- sample_ids: list[str],
- partition_id: str,
- select_fields: list[str],
- list_sample_ids(partition_id: str) list[str]#
List stored sample IDs without reading their batch payloads.
- clear_samples(sample_ids: list[str] | None, partition_id: str) None#
- save_checkpoint(
- checkpoint_dir: str | pathlib.Path,
- *,
- metadata: dict[str, Any] | None = None,
Persist the in-process partitions to
checkpoint_dir.State never leaves this process, so pickle is sufficient; callers must not load checkpoints from untrusted paths. The write goes to a sibling
.tmpdirectory and is renamed into place so a crash mid-save leaves the previous checkpoint intact.
- load_checkpoint(
- checkpoint_dir: str | pathlib.Path,
Restore partitions into a client that has not registered any yet.
- close() None#
- static _sequence_lengths(
- partition: nemo_rl.data_plane.adapters.local._LocalPartition,
- indices: list[int],