nemo_rl.data_plane.adapters.tq_controller_patch#
Cheaper kv_retrieve_meta and FieldMeta.remove_samples for the TransferQueue controller.
The stock kv_retrieve_meta reads a torch tensor once per field, about a quarter of a put+get
cycle on the single-threaded controller. kv_retrieve_meta below is the stock
method with one .all(dim=0).tolist() instead; results are identical.
Stock FieldMeta.remove_samples re-checks every nested field’s label on every clear: it scans
all live rows and, if they share one shape, relabels the field from nested to regular. That costs
O(live rows) on the controller’s only request thread. The situation that triggers a relabel does
happen in NeMo-RL (for example, one row left), but nothing in NeMo-RL reads the label. Readers
of row shapes (TQ storage, and the Mooncake read path patched in transfer_queue.py) get them
from BatchMeta.get_shapes, which serves the same shape for every row under either label, so
skipping the relabel changes no data a run sees. remove_samples below skips it, so a clear
costs O(cleared rows).
test_remove_samples_serves_the_same_shapes_as_stock and
test_rows_survive_a_clear_that_stock_would_collapse pin that. Only nemo_rl/data_plane may
import transfer_queue (test_only_the_data_plane_imports_transfer_queue), so no other code
can read the label. TQ’s own test_clear_data_nested_field_becomes_regular fails under this
override by design.
The stock KV_LIST request returns every key with its custom metadata. list_keys below,
exposed as the actor method nrl_list_keys, returns only the keys for inventory checks that
compare key sets; it is NeMo-RL-only and has no upstream counterpart.
The controller is a Ray actor, so all three are applied in a subclass started by tq.init.
Delete the two overrides once the pinned TransferQueue includes both changes; list_keys has no
upstream counterpart.
Module Contents#
Functions#
Stock |
|
Stock |
|
Keys of one partition without their custom metadata; |
|
Install |
|
Check that the installed TransferQueue is the version the overrides were copied from. |
|
Return a Ray actor class that runs the controller with both overrides and |
|
Make |
Data#
API#
- nemo_rl.data_plane.adapters.tq_controller_patch.logger#
‘get_logger(…)’
- nemo_rl.data_plane.adapters.tq_controller_patch.STOCK_TQ_VERSION#
‘0.1.11’
- nemo_rl.data_plane.adapters.tq_controller_patch.kv_retrieve_meta(
- self,
- keys: list[str],
- partition_id: str,
- create: bool = False,
Stock
TransferQueueController.kv_retrieve_metawith one field-mask read.
- nemo_rl.data_plane.adapters.tq_controller_patch.remove_samples(
- self: transfer_queue.controller.FieldMeta,
- indexes: list[int],
Stock
FieldMeta.remove_sampleswithout the nested-to-regular relabel.
- nemo_rl.data_plane.adapters.tq_controller_patch.list_keys(self, partition_id: str) list[str]#
Keys of one partition without their custom metadata;
[]if it does not exist.
- nemo_rl.data_plane.adapters.tq_controller_patch.patch_field_meta() None#
Install
remove_samplesonFieldMetain this process; the controller calls it on start.
- nemo_rl.data_plane.adapters.tq_controller_patch.assert_stock_tq_version() None#
Check that the installed TransferQueue is the version the overrides were copied from.
- Raises:
RuntimeError – If the version differs, which means the TQ pin moved.
- nemo_rl.data_plane.adapters.tq_controller_patch.make_patched_controller(actor_class: Any) Any#
Return a Ray actor class that runs the controller with both overrides and
nrl_list_keys.
- nemo_rl.data_plane.adapters.tq_controller_patch.configure_controller_patch() None#
Make
tq.initstart the patched controller; call before it.