MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / select

Method select

verl/verl/protocol.py:611–644  ·  view source on GitHub ↗

Select a subset of the DataProto via batch_keys and meta_info_keys Args: batch_keys (list, optional): a list of strings indicating the keys in batch to select meta_info_keys (list, optional): a list of keys indicating the meta info to select Returns:

(self, batch_keys=None, non_tensor_batch_keys=None, meta_info_keys=None, deepcopy=False)

Source from the content-addressed store, hash-verified

609 return self
610
611 def select(self, batch_keys=None, non_tensor_batch_keys=None, meta_info_keys=None, deepcopy=False) -> "DataProto":
612 """Select a subset of the DataProto via batch_keys and meta_info_keys
613
614 Args:
615 batch_keys (list, optional): a list of strings indicating the keys in batch to select
616 meta_info_keys (list, optional): a list of keys indicating the meta info to select
617
618 Returns:
619 DataProto: the DataProto with the selected batch_keys and meta_info_keys
620 """
621 # TODO (zhangchi.usc1992) whether to copy
622 if batch_keys is not None:
623 batch_keys = tuple(batch_keys)
624 sub_batch = self.batch.select(*batch_keys)
625 else:
626 sub_batch = self.batch
627
628 if non_tensor_batch_keys is not None:
629 non_tensor_batch = {key: val for key, val in self.non_tensor_batch.items() if key in non_tensor_batch_keys}
630 else:
631 non_tensor_batch = self.non_tensor_batch
632
633 if deepcopy:
634 non_tensor_batch = copy.deepcopy(non_tensor_batch)
635
636 if meta_info_keys is not None:
637 sub_meta_info = {key: val for key, val in self.meta_info.items() if key in meta_info_keys}
638 else:
639 sub_meta_info = self.meta_info
640
641 if deepcopy:
642 sub_meta_info = copy.deepcopy(sub_meta_info)
643
644 return type(self)(batch=sub_batch, non_tensor_batch=non_tensor_batch, meta_info=sub_meta_info)
645
646 def select_idxs(self, idxs):
647 """

Callers 15

test_selectFunction · 0.80
test_dataproto_no_batchFunction · 0.80
test_dataproto_no_batchFunction · 0.80
splitMethod · 0.80
_create_dataloaderMethod · 0.80
init_workersMethod · 0.80
dump_memory_snapshotMethod · 0.80
dump_memory_snapshotMethod · 0.80
compute_valuesMethod · 0.80
update_criticMethod · 0.80

Calls

no outgoing calls

Tested by 3

test_selectFunction · 0.64
test_dataproto_no_batchFunction · 0.64
test_dataproto_no_batchFunction · 0.64